So this is gonna be short and simple, I'm trying to make some variables go up in a function, for what im doing is checking if a tile has been mined and if it has it goes into the def and checks them, depending on the tile it gives you a certain item or block, say you mine dirt, it gives you one dirt but the problem here being i cant add to a variable outside a def in a def.
meaning INC DIRT,1 does nothing to add one dirt so im wondering how i can do like INC DIRT,1 in a def then move that added dirt out of the def onto the already ready variable in my normal code without having to check every item again. (aka +1 a variable from outside the def)
idk if anyone still checks here but quick answers are always nice.
thanks
Adding to a variable from a DEF
Root / Programming Questions / [.]
SwanBotCreated:
'You'd have to either modify a global variable: VAR DIRT DEF MINE_DIRT INC DIRT END 'Or return a value: VAR DIRT DEF MINE_DIRT(DIRT) RETURN DIRT+1 END DIRT=MINE_DIRT(DIRT) 'Or use an array: DIM DIRT[1] DEF MINE_DIRT DIRT INC DIRT[0] ENDI assume you're already using an array to store inventory data, so the 3rd solution is probably the best here.
well the thing is that here we are already specifying the dirt but then to add a different item a would have to repeat the def many times, like ADD_DIRT(DIRT) then ADD_SNOW(SNOW) and so on for every possible number, now right now it checks the tile then sends the tile number to the def where it goes like IF ARRAY==32 THEN INC DIRT,1 (and does some other ones of that for other tiles) so how can i make it return only the variable that was added to without specifying the variable to add to in the def (not in it but the line that goes in my code) also i might use the array idea..?'You'd have to either modify a global variable: VAR DIRT DEF MINE_DIRT INC DIRT END 'Or return a value: VAR DIRT DEF MINE_DIRT(DIRT) RETURN DIRT+1 END DIRT=MINE_DIRT(DIRT) 'Or use an array: DIM DIRT[1] DEF MINE_DIRT DIRT INC DIRT[0] ENDI assume you're already using an array to store inventory data, so the 3rd solution is probably the best here.