1
Ask a Question / Manipulating game attribute lists with global custom blocks
« on: January 06, 2016, 07:23:19 am »
Hi!
I'm learning how to use the global custom blocks (aka static functions) to clean up my codes. Here's a problem I got.
To keep in one same place various parameters I use in the game, I'm keeping 5 different lists that were defined as game attributes. One is a list of actor types, another is a list of layers, and so on.
During the game, I want to update/empty/change these lists when I switch scenes.
I've built a global custom block to reinitialise these global lists, with the blocks "set MYLIST to create new list". And it works great.
I've also built another global custom block to refill these global lists, using input parameters (for instance "add [ACTOR TYPE] to actortype global list") with the block "add [something] to [some list]". But this fails. When I test it from within my behaviour "list of all static functions", it works, but not anywhere else. The static function is not even called. No error message either.
I tried to create a local copy of the global list, to add the new value to this copy, and then overwrite the global list with the updated temporary list... but I cannot create a local copy (a local attribute) within a global block; and making the temporary list a game attribute also fails.
My question is thus: can we fill a game attribute list with global blocks? if not, how could we do that?
(right now, I'm rebuilding entirely the lists with "when created" events, for each scene, with copied-pasted checks and safeguards... always a few pages worth of code, when I'm sure it should take far less if I could write these static functions)
Any idea? Thanks in advance!
I'm learning how to use the global custom blocks (aka static functions) to clean up my codes. Here's a problem I got.
To keep in one same place various parameters I use in the game, I'm keeping 5 different lists that were defined as game attributes. One is a list of actor types, another is a list of layers, and so on.
During the game, I want to update/empty/change these lists when I switch scenes.
I've built a global custom block to reinitialise these global lists, with the blocks "set MYLIST to create new list". And it works great.
I've also built another global custom block to refill these global lists, using input parameters (for instance "add [ACTOR TYPE] to actortype global list") with the block "add [something] to [some list]". But this fails. When I test it from within my behaviour "list of all static functions", it works, but not anywhere else. The static function is not even called. No error message either.
I tried to create a local copy of the global list, to add the new value to this copy, and then overwrite the global list with the updated temporary list... but I cannot create a local copy (a local attribute) within a global block; and making the temporary list a game attribute also fails.
My question is thus: can we fill a game attribute list with global blocks? if not, how could we do that?
(right now, I'm rebuilding entirely the lists with "when created" events, for each scene, with copied-pasted checks and safeguards... always a few pages worth of code, when I'm sure it should take far less if I could write these static functions)
Any idea? Thanks in advance!