| Storing and using flag values ... | |
|
Author | Message |
---|
acko Novice Adventurer
Number of posts : 19 Age : 53 Location : Perth, Western Australia Humor : No one drinks XXXX or Fosters in Australia !! Adventure Points : 8 Registration date : 2012-07-18
| Subject: Storing and using flag values ... Wed Jul 18, 2012 6:35 am | |
| Hi Phil & fellow TABers,
Quick question about the use of flags ...
Take this command, for example: flag1=room
Having tested this, the result is that the player's current location is stored in flag1.
What I can't work out is how I can use the value of flag1 in order to move the player.
For example, let's say the player starts in location 1 and picks up object 1. He then moves and a little while later finds himself in location 7. He then 'activates' (doesn't matter what it is or how he does this) object 1 and is immediately 'transported' to a new location, say location 50.
I can use flag1=room as soon as the player activates the object to store location 7 in flag1.
But then the player does something else whilst at location 50 that causes him to be teleported back to the location he came from, which is now stored in flag1.
Commands such as 'gotoflag1' or 'room=flag1' simply make TAB hang, presumebly because of the reference to flag1 and not an integer.
I know I could use a series of commands to do this but for every new location you would have to add to this list, as in ...
[start]flag1=1[acts]goto1[end] [start]flag1=2[acts]goto2[end] [start]flag1=3[acts]room=3#desc[end] etc ...
My question is whether there is an easier way to do this?
Thanks all
Mark
PS. Happy adventuring ... |
|
| |
catventure Admin Adventurer
Number of posts : 410 Age : 72 Location : UK Humor : Enjoys a laugh! Adventure Points : 77 Registration date : 2008-06-08
| Subject: Re: Storing and using flag values ... Wed Jul 18, 2012 10:21 am | |
| Hello Mark,
Welcome to this forum.
Don't think you can do that at present.
Bear with me and I'll make some new commands and post a new update.
I think what is required to solve your problem is 2 new actions:
gotoflagX - move player to room number held in flag X and describe.
room=flagX - set current room to be value held in flag X.
Be back later to let you know....
Phil (catventure)
|
|
| |
catventure Admin Adventurer
Number of posts : 410 Age : 72 Location : UK Humor : Enjoys a laugh! Adventure Points : 77 Registration date : 2008-06-08
| Subject: Re: Storing and using flag values ... Wed Jul 18, 2012 12:46 pm | |
| Hi Mark, OK. I've made a new release with the following new coding: *NEW ACTIONS room=flagX - set current location to be value of room integer held in flag X gotoflagX - go to the room number held in flag X and describe the room *NEW CONDITIONS room=flagX room<>flagX room>flagX room<flagX room>=flagX room<=flagX (Check the current room number held as an integer in flagX is valid) === Note you can already use the following existing ACTION "flagX=Y" but with the %room% embedded tag: flagX=%room% eg: flag21=%room% - set a flag to hold player current room number integer. Also will work as a condition: flagX=%room% - check if flagX is equal to player current room.... http://tab.thinbasic.com/Let me know if OK. Phil. PS. In the case of any program crash in the player you can always retrieve the state of the database before the crash by loading the "recover.tab" datafile (navigate to main program directory) into the Editor... |
|
| |
garethfx Experienced Adventurer
Number of posts : 85 Age : 67 Location : Wales Humor : Nothing like having a good laugh - oh and a pint! Adventure Points : 53 Registration date : 2009-09-28
| Subject: Re: Storing and using flag values ... Wed Jul 18, 2012 7:09 pm | |
| I suppose you could always use TWO flags to undertake to the goto and return to action. Basically it would be something like (in sudo code)
at location 1 "press teleport" # act flagA=%room%#room=flagX#desc
then when you need to return you could use the "press teleport"#act flagX=A#Room=flagx#desc
I think that makes some sense.
Gareth |
|
| |
catventure Admin Adventurer
Number of posts : 410 Age : 72 Location : UK Humor : Enjoys a laugh! Adventure Points : 77 Registration date : 2008-06-08
| Subject: Re: Storing and using flag values ... Wed Jul 18, 2012 7:36 pm | |
| acko wrote: - Quote :
I can use flag1=room as soon as the player activates the object to store location 7 in flag1.
But then the player does something else whilst at location 50 that causes him to be teleported back to the location he came from, which is now stored in flag1
Now you can do something like this: Response entries: [start]activate object#flag1=0#here1[acts]flag1=%room%#room=50#cmessTransporting you to room 50....#desc[end] [start]pull lever#flag1>0#room=50[acts]cmessTransporting you back to room where object was initially activated...#gotoflag1#flag1=0[end] flag1 is reset to 0 when transported back... here1 - checks that object 1 is held, worn or in current room Anyway you get the idea. Phil. |
|
| |
acko Novice Adventurer
Number of posts : 19 Age : 53 Location : Perth, Western Australia Humor : No one drinks XXXX or Fosters in Australia !! Adventure Points : 8 Registration date : 2012-07-18
| Subject: Re: Storing and using flag values ... Thu Jul 19, 2012 5:05 am | |
| Excellent, Phil, thanks for that speedy fix And thanks for an excellent tool that is good fun to use. I think the only other time I've ever tried to create a text adventure was an app that came out for the C64 back in the 80s. And I think the severe memory limitations made for an adventure of about 4 locations, 1 puzzle and 2 objects before the whole thing crashed and you were forced to reload the app via a cassette that took half an hour!! The request for 'gotoflag' came from an idea used in a series of fantasy books I read a couple of decades back now by a guy called Hugh Cook. In the books the main character had a bottle and a ring. When the ring was worn the wearer (and anybody touching him) was 'magically' transported into the bottle. Inside, the bottle was huge consisting of many different locations. The bottle remained behind and could be carried by another person. When the character removed the ring he could be transported back out of the bottle to the same location as the bottle: if the bottle hadn't moved since the character was inside then he'd appear at the same place, if the bottle had been moved somewhere else then he'd appear there instead. Anyway, with your help I've got that whole thing working now with only the need for one command as opposed to the multiple needed to do it via hard-coded flag values. It's a pity there aren't more adventure games to play other than those that come bundled with TAB. Happy Adventuring Mark |
|
| |
catventure Admin Adventurer
Number of posts : 410 Age : 72 Location : UK Humor : Enjoys a laugh! Adventure Points : 77 Registration date : 2008-06-08
| Subject: Re: Storing and using flag values ... Thu Jul 19, 2012 7:21 pm | |
| Hi Mark,
Well I am glad that the improve is a working solution for you and cuts down considerably on the coding side of things. If you decide to write an adventure and need help or want to request other improves or enhancements to coding actions or conditions, feel free to post up your suggestions and if they are reasonable and possible of inclusion I will do my level best to incorporate them into the TAB program as soon as practicable. Thanks for your comments and I hope you have some fun exploring TAB and maybe building your own unique interactive story idea. To this end the forum exists to provide answers to coding queries or to help shed light on many aspects of text adventure development and construction.
Regards, Phil. |
|
| |
Sponsored content
| Subject: Re: Storing and using flag values ... | |
| |
|
| |
| Storing and using flag values ... | |
|