A way to reuse flags in the same scenerio

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: A way to reuse flags in the same scenerio
Shock Trooper
Member # 3276
Profile #0
Since flags can get confusing, here is a failsafe use for some flags that are used only in the current town.

Step One: Define variables equal to the number of flags you plan to use.

Step Two: In INIT_STATE, use get_flag for the flags to reuse and have a variable equal that flag.
i = get_flag(2,5);

or something like that.

Step Three: also in INIT_STATE, AFTER the variables of the respective flag's values, clear the flags to zero.
set_flag(2,5,0);

Step Four: In EXIT_STATE, have the variables set the flag back again.
set_flag(2,5,i);

And poof! The flags are reuseable. Once done with in the current town, and exited, then they are reset back again. Best applies to two or more story dungeons, since Variables are cleared upon traverse up and down.
I have not worked on outdoor scripts much, but I am pretty sure the same thing can apply to a single or a section of outdoors.

Be sure the right variable is put in the right flag.

Example for use:
You have a two story cave. You want something the player does in the upper affect the lower and stuff in lower affect upper. You have switches, and in your mind, they are numbered. You can recall the switches by using flags 0,1 0,2 etc for switches numbered that. Use the above method to failsafe it.
It might be useless, but hey. It's still a fun thing to try.

EDIT: The flags, that way, will reset when the player renters the part of the dungeon that has INIT_STATE. So for the INIT_STATE of only the first part, set a flag beginining with the town number (9) for example that is Town Number,0. like 9,0. Have it equal one after all the flag storing and flag clearing is done. And make an if statement so all that flag clearing crap ONLY happens when 9,0 == 0. And the flag will only go back to 0 on exit state, so add that chunk of code
....
set_flag(9,0,0)
....
9 = town number...
....
for exit state. That means the flags wont rest again until after they are restored on EXIT_STATE.

[ Tuesday, July 27, 2004 17:51: Message edited by: GIFTSare2adominable ]
Posts: 249 | Registered: Saturday, July 26 2003 07:00
Off With Their Heads
Member # 4045
Profile Homepage #1
Wow. Yeah, either that, or take notes like a normal person.

I don't know if the BoA docs recommended this (I don't think they did), but the BoE docs recommended using flags whose x-coordinates agreed with your town number -- ie using flags (0,0), (0,1), (0,2), ... , (0,29) in town 0, flags (1,0), (1,1), ... , (1,29) in town 1, etc. Then just take notes on what your flags mean.

It's not like you'll ever run out. I don't know why you would want to reuse them. That sounds far too dangerous.

EDIT: Reading your method a bit further, I have no idea why you're messing around with variables. Just set the flags directly, and it should have the same effect.

[ Tuesday, July 27, 2004 19:31: Message edited by: Kelandon ]

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.
Smoo: Get ready to face the walls!
Ephesos: In conclusion, yarr.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Agent
Member # 2820
Profile #2
So, what you are saying is that you want to document the previous value of a flag when you enter a town in which you want to reuse certain flags, and then it is reset when exited. For all practical purposes, the flag's scope will only be inside the town. You should remember that there is a limit to how many variables you can declare in a single script, but this could be useful for those who like to have multipurposes for flags.

Warn players about forcefully leaving the town with the editor.

EDIT: Now for my personal opinion: I do not think that this is a good idea. You have up to 30 flags for each town number + outdoor sections. Mind you that you can have 100 outdoor sections, and even the largest scenarios didn't have that many, though the flags will still be there.

I like running the extra flags in town over to the flags for outdoor sections that don't exist.

[ Tuesday, July 27, 2004 20:16: Message edited by: Keep ]

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
The Establishment
Member # 6
Profile #3
Flags act as permanent, global, predefined variables, at least for the duration of the scenarios. This strategy seems unnecessary and really confusing. Just keep notes on existing flags and you should be fine.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Apprentice
Member # 3857
Profile #4
I had objected that town variables are not stored in savefiles but, as keep has noted below and I have just checked, they ARE saved. Please ignore this post :)

[ Wednesday, July 28, 2004 13:35: Message edited by: void* ]
Posts: 21 | Registered: Sunday, January 4 2004 08:00
Agent
Member # 2820
Profile #5
Variables are saved, don't worry about that one too much.

[ Wednesday, July 28, 2004 13:03: Message edited by: Keep ]

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00