Enter attributes as a function
danayel
Member Posts: 25
Is it possible to change or select attribute names by building them with a function?
eg. I have 6 actors on the screen, and each one has identical rules except that the attributes they access are numbered 1-6
shape_1
shape_2
shape_3
..
shape_6
Rather than having to manually edit every single one of them and change them from the prototype, which makes a lot more work if I want to change the prototype, could I instead give them each an attribute of self.id and reference the game level attributes as:
"game.shape_"+self.id
This would make development a LOT faster and much easier to make changes when there are a lot of identical actors on the screen.
eg. I have 6 actors on the screen, and each one has identical rules except that the attributes they access are numbered 1-6
shape_1
shape_2
shape_3
..
shape_6
Rather than having to manually edit every single one of them and change them from the prototype, which makes a lot more work if I want to change the prototype, could I instead give them each an attribute of self.id and reference the game level attributes as:
"game.shape_"+self.id
This would make development a LOT faster and much easier to make changes when there are a lot of identical actors on the screen.
Comments
http://gamesalad.com/forums/topic.php?id=4297
I am already using that logic to alter images on the fly, but this is different.
I have 6 actors on the screen, all do the exact same rules, except to different attributes.
Because of this I want to have the attribute names dynamic. Otherwise I need to edit them all to point at different attributes.
e.g. imagine you have 6 buttons, each one turns a different light on and off.
if (pressed inside) -> change(game.button1 to 'on')
if (pressed inside) -> change(game.button2 to 'on')
if (pressed inside) -> change(game.button3 to 'on')
...
Because actors can't talk to each other, I would need to set the game attributes which are read by the lights so they know to turn on/off. But I need to map one button to one light.
The other option would be to use some sort of mock binary :
010010 = lights 2 and 5 are on
Which I am doing already for some attributes, but in my game there are 36 "lights" and I can't write an int that is 36 digits long...
Hence I have location 1-6 and position (at that location) 1-6
But I still need to read 6 attributes, one for each location. The position-values are stored in mock binary in the game.location1 ... game.location6 attributes
GS is pretty dumb when it comes to attributes. They need to ALL be defined in the core settings...GS cannot create an attribute (or define an attribute definition) during runtime. Nor can it call a function or an attribute from another actor (something everyone wants). The actors can ONLY currently talk to the game or to themselves.
I recommend build the base values...then use actor IDs. to assign the unique values to the standard attribute containers...thus making each actor's values unique...but all using the same attribute names.
Otherwise...you will need 6 sets of unique attributes.
TIP:
When posting...do not use advanced "CODING JARGON" or problem presentation structure as most of the people on here will not know what you are talking about and will not be able to help. Keep it in layman's terms and more people can help...and learn from the thread. For example...there is not such thing as a function in GameSalad. There are rules and behaviors. Also...the "mock binary" thing will send 90% of the readers packing.
I thought that is what I would have to do, but hoped I had simply missed something.
I already built it to work like this, but I was just creating my actor instances and changing all the attributes in the rules and I got to wondering if there wasn't a better way, because it is taking me aaaages to do. Thinking up the rules was faster...
As for your tip. I shall attempt to. Old habits die hard though so please forgive me if I transgress again.
Not saying this helps your situation, but it's important to remember the Scene scope.
My game only has one scene and most of the actors are already unlocked (for the reasons above) so it might be useful.
Thanks again also Synthesis.
It sounds like we're trying to do similar things. I found a solution that still needs some testing on actual devices but might work for you: use a non-visible actor in the scene to track the states of other actors.
http://gamesalad.com/forums/topic.php?id=4672
http://gamesalad.com/forums/topic.php?id=4672
It's still a manual process wiring them up, it does unlock and unsync from the prototype, has to be done per scene, and can cause headaches when the actor's involved and/or scene they are in need updating. However, it can provide some relief in certain situations.
<must read whole thread before posting, must read whole thread before posting...>
:-)