ID:1454291
 
(See the best response by Kaiochao.)
Code:
obj
InventBox
var
free
icon = 'inventBox.dmi'
layer = 2
free = "TRUE"
box1
icon_state = "r1c1"
screen_loc ="Imap:1:13,6:21"
//box 2 blabla
//box 3 blabla etc


mob
proc
UpdateInvent()
var
num

for(num=1,num<=24, num++) //loops through each invent box
var/obj/InventBox/box[num]
if(box[num].free = "TRUE")


Problem description:

"if(box[num].free = "TRUE")" gives me an error of: 122:error: .: missing comma ',' or right-paren ')'

I am trying to loop through each inventBox obj to check if they are "free". if they are, then I replace box[num] obj with a different obj, by setting box[num].screen_loc = null (so it doesn't show up on the map) and put the new obj in its screen_loc

but the if statement is giving me a syntax error it seems.. so I'm not sure how to get around that yet

I have even tried this: and still get the error
if(var/obj/InventBox/box[num].free = "TRUE")



That's not how you search for objects. You'd be able to find it if you did this:
for(var/obj/InventBox/box)

That loops through every object of that type that exists. Narrow down your search from there. You can also create a list before you search if you know exactly where you need to search, and search through that list rather than every instance.
Best response
You can't use the [] operators like that outside of string literals. It actually means something entirely different.

It also doesn't make sense that you're trying to modify a variable of a type path. You need actual instances of that type to use, using "new".

It looks like you might be able to use basic math to create your boxes at their proper positions instead of having a bunch of different types of them.

You need to be taking advantage of a list to store your objects so you can actually access them.

Your if() at the end is using = (assignment) instead of == (comparison), which is also bad.
Alright I think I understand it better now. thanks!

I managed to do what I wanted to do