• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

is it possible to draw variables on objects with codes?

C

Callam

Guest
hi, im working on a game that involves drawing hundreds of variables on objects. each object has its own unique variable ( a counter) attached to it. currently im using drag n drop and have done 50 this way. the position for the count is -5, -5. obviously this is a very long procss and will become even more so the more i add. i have looked for solutions but none seem to exist. Im not sure if its the way i have it setup or what.

heres how i have it set up

object - game

draw, applies to object 1, variable.example1, -5, -5, relative
draw, applies to object 2, variable.example2, -5, -5, relative


 
M

Marcus12321

Guest
Make them all children of a parent object. Have the parent objects draw event draw the variable on the sprite.
 
D

Dennis Ross Tudor Jr

Guest
You can use any of the drawing text functions to draw text.
To access a variable in another object you can use the (.) dot accessor
obj_whatevere.someVariable<-- this is how you access the someVariable from the obj_whatever object.
 

Weird Dragon

Wizard
GMC Elder
@Callam,
There is something that confuses me. You said in the first post:

"each object has its own unique variable ( a counter) attached to it."

Then there is an image of a lot of variables where the values get drawn, but all these variables are global thus not really unique to the objects. Why make the variables global if they are supposed to be unique to specific objects?
 

chamaeleon

Member
Too many variables. Should be a map or some other suitable data structure that one can iterate over or look up based on name.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Can you do a For loop in D&D? If you can that would make that unholy mess of variables easy
 

FrostyCat

Redemption Seeker
Then there is an image of a lot of variables where the values get drawn, but all these variables are global thus not really unique to the objects. Why make the variables global if they are supposed to be unique to specific objects?
This happens because modern GM education normalizes having no grasp of variable scope, events and basic organization patterns.
Can you do a For loop in D&D? If you can that would make that unholy mess of variables easy
Legacy D&D only has an analogue of the repeat statement, which you turn into a for statement somewhat by adding two more "Set Variable" actions (one for the initialization and the other for the increment).
 
Last edited by a moderator:
Well, modern (and old) GM education is basically "I don't know how to do this thing. I have never opened the manual and never will. If there's not a youtube video that has exact step by step instructions on how to accomplish the exact thing I'm trying to do, I'll post on the forums and then copy and paste the answer without the slightest understanding."
 

Joe Ellis

Member
This happens because modern GM education normalizes having no grasp of variable scope, events and basic organization patterns.

Legacy D&D only has an analogue of the repeat statement, which you turn into a for statement somewhat by adding two more "Set Variable" actions (one for the initialization and the other for the increment).
I kind of agree with this, but there's only 3 scopes, global. var and normal, I mean, everyone gets global.variable,
the main thing is var, cus its only in that script, its hard to understand at first but pretty simple once you know,

plus, using other.variable, can be avoided if you do a var for that variable, it can be a life saver with a with, cus whatever instance you're with will still read the var in that script

And also, the repeat loop is far faster than the for loop, it's the best, I will NEVER use a for loop in my whole career in gml, while loops are fine, if there needs to be a check at the end of every cycle, if not, repeat until the loop is done

But @Callam, just learn gml, it'll be easier to handle
 
Last edited:
Top