Login
Remember
IF Answers
Ask a Question

# Quest: if's, exits, blocking and attributes

0 votes
36 views
asked Oct 23 in Authoring by Toris (1 point)
edited Oct 23 by Toris

So these forums have been very useful, thanks a ton for that.
I've tried using gamebook version, but it seems rather limited, and I couldn't find dictionary functions to make attributes work properly and still so much more the text version does better.

Looking for Text Adventure Answers please**

So First Question is:

How do you make page links available if a stat is high enough?

example:

{if player.cunning>25:}
I want the following to be displayed

{command:go to Room4: So cunning you get to go here!}

Now I'm adding the commands to the text description, and I can't quite get it right.

Second Question:
The next thing I am having trouble with is blocking a path (exit) after it has been used.
Player has a choice of going to Room2, Room3, or Room4, player can't go to Room4 till their cunning is increased, so that isn't displayed yet, So player picks Room2, then Room2 links back to the Original Room1, but now I want Room2 to be blocked, that choice has already been taken and is no longer valid.

I've dabbled in exits and if's there as well, but can't quite get that right.

Last Question (For Now)
How do you display stats on a page without using the show panes interface? I'm looking to make it feel like more of a choose your own adventure, but with stats still recorded and shown.

I hopefully want it in descriptions, or maybe at header.
Maybe there is a way to have the option to remove inventory, compass, place and objects from the screen, but keep status?

Any answer, would be very useful, thanks.

- exit
- status-attributes
- descriptions
- quest
- if-script

commented Oct 23 by hegemonkhan (161 points)
Do you want our responses~answers for Gamebook version or the Text Adventure version? Which are you using? (It's unclear from your post, at least for me)

## 1 Answer

0 votes
answered Oct 23 by hegemonkhan (161 points)
edited Oct 23 by hegemonkhan

if you're asking about how to do this stuff in Gamebook, I'm not that familar with it, as I've not yet used, nor studied it, much, however, hopefully this can help you with how to move amongst the Pages in code:

http://ifanswers.com/1246/what-script-creates-a-link-to-a-page

for scripting in GameBook, you need to set the 'page type' to either: [script] or [script+text]

also, if you want the scripting to be done as 'within text' (aka: 'msg' ~ 'print a message' Scripts), then you'd use the 'text prcoessor commands':

http://docs.textadventures.co.uk/quest/text_processor.html

otehrwise, the normal scripting syntax looks like this in code:

    if (player.cunning > 25)
    {
            msg ("So cunning, you get to go here!")
            // the goto page scripting shown in the link above as a text processor command, or as normal scripting: but I don't know what its syntax looks like and am too lazy to make a gamebook game to look it up
          // in a text adventure it's:
          // player.parent = destination_room_name
          // or:
          // MoveObject (name_of_object_you_want_to_move, name_of_destination_object)
          // MoveObject (player, destination_room_name)
    }

http://docs.textadventures.co.uk/quest/attributes/parent.html
^^^^^^^^^^^
http://docs.textadventures.co.uk/quest/elements/object.html
^^^^^^^^^^
http://docs.textadventures.co.uk/quest/elements/

and

http://docs.textadventures.co.uk/quest/functions/corelibrary/moveobject.html

as for blocking, a simple way is using the 'visited' built-in Attribute (I don't know if the 'visited' Attribute exists in GameBook or not):

    if (room_X.visited)
    {
            msg ("You can't go back to that room anymore")
    }
    else
    {
            // an example using Text Adventure code:
            // msg ("You go to room_X")
            // player.parent = room_X
    }

if the GameBook doesn't have the 'visited' Attribute, you're going to have to make your own Attribute, either a Boolean or Int (Integer) or String Attribute, to check for (not sure if you can add Attributes to the 'Page' Objects or not, I think you can though if I remember Pixie answering this for someone, but I could be wrong ~ if you can't, you can add the Attributes to the 'player' or 'game' object instead):

before going to room_X:

Boolean: room_X.visited (or call it something else, lol) = false

Integer: room_X.visited = 0

String: room_X.visited = "0"

after going to toom_X:

Boolean: room_X.visited = true

Integer: room_X.visited = 1

String: room_X.visited = "1"

and the check for it (lazy horizontal code form, not fully explained nor all variations that you can do, just a quick brief incomplete examples):

Boolean:

if (roomX.visited = false) { player.parent roomX } else { msg ("You can't go back to room_X anymore") }

Integer:

if (roomX.visited = 0) { player.parent roomX } else { msg ("You can't go back to room_X anymore") }

String:

if (roomX.visited = "0") { player.parent roomX } else { msg ("You can't go back to room_X anymore") }

a way to do it (in code for text adventure):

during game play, you literally just type in the 'Pattern' of simple-short-ness: info

    <command name="character_information_screen">
            <pattern>info</pattern>
            <script>
                    ClearScreen
                    msg ("Name: " + player.alias)
                    msg ("Sex: " + player.sex)
                    msg ("Age: " + player.age_integer + "(" + player.age_string + ")")
                    msg ("Strength: " + player.strength)
                    msg ("Endurance: " + player.endurance)
                    msg ("Agility: " + player.agility)
                    // etc stats
                    wait
                    {
                            ClearScreen
                    }
            </script>
    </command>

// outputs example:

Name: HK
Sex: male
Age: 18 (adult) // I wish I was 18 still, lol
Strength: 100
Endurance: 100
etc etc etc

commented Oct 23 by hegemonkhan (161 points)
ask if you got any questions, as this was a quick and incomplete, non-comprehension, non-fully-explaining, answer. So ask if you're confused by anything, or if you need any specifics on how to do something, as this answer post of mine is generalized, and won't work unless you understand scripting well, already knowing how to do exactly what I just generalize for you, lol.
commented Oct 23 by Toris (1 point)
Thanks a ton, I was able to insert the if stat statement with the following in the description. And working on Text adventure.
{if player.gunnery>30: So you can go here now {command:go to Gladius Alliance: Gladius}}
Was simply putting things in the right position.
The main problem seems to be where to put things, or where to set them.
Right now I am trying to do something like
player.strength=player.strength+player.endurance/5
player.strength int 20
player.endurance int 20
but have it a constant game thing, so either strength can be increased on it's own, or when endurance is increased so is strength. But not sure where to place it or set it up in the player file. I was thinking as a Function but can't quite get it right.
I'm also trying to do it without player input controls, only linking, so no commands entered, just pick/choose and go along on the story.
I'll take a look above again soon, already was able to solve a few questions for the answers here. So thanks again!
commented Oct 23 by hegemonkhan (161 points)
edited Oct 23 by hegemonkhan
if you simply mean as in being a constant variable, in quest those are (so long as the Object that contains them, exists, of course):
Attributes
simply add attributes to Objects:
'whatever' Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)
(Object Name: whatever)
Attribute Name: whatever
Attribute Type: (string, int~integer, double~floating point~float, boolean, script, object, lists, dictionaries, etc)
Attribute Value: whatever (depends upon Attribute Type though)
or, in code's scripting, it's just:
Object_name.Attribute_name = Expression_or_Value
~OR~
Object_name.Attribute_name
player.strength
player.strength = 100
player.strength = player.strength + 1
game.state = 0
game.strength = 20
orc.damage = 10
orc.dead = false
orc.dead = true
player.left_hand = shield // the 'shield' must be an existing~created Object, of course
player.right_hand = sword // same for 'sword'
player.condition = "poisoned"
player.condition = "normal"
player.condition = "asleep"
player.damage = player.sword.physical_damage + player.sword.physical_damage * (player.strength / 100) - (orc.mail.physical_resistance + orc.mail.physical_resistance * (orc.endurance / 100))
or, as the 'creation' tag block, in code, some examples:
<game name="xxx">
<attr name="gameid" type="string">xxx</attr>
<attr name="author" type="string">HegemonKhan</attr>
<attr name="category" type="string">RPG</attr>
<attr name="HK_strength" type="int">0</attr>
<attr name="strength" type="int">0</attr>
<attr name="orc_strength" type="int">0</attr>
<attr name="start" type="script">
character_creation_function()
</attr>
</game>
<object name="player">
<attr name="alias" type="string">HK</attr>
<attr name="strength" type="int">100</attr>
</object>
<object name="orc_1">
<attr name="alias" type="string">orc</attr>
<attr name="strength" type="int">25</attr>
</object>
-------------------------------
if you mean as in a 'global event', you'd use a Turnscript or the special 'changed' Script:
for a simple quick example (being poisoned, losing 50 life, and impractically-lol gaining +5 strength, every internal turn):
<game name="xxx">
</game>
<object name="room">
<object name="player">
<attr name="life" type="int">999</attr>
<attr name="strength" type="int">0</attr>
<attr name="condition" type="string">poisoned</attr>
</object>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
if (player.life > 0 and player.condition = "poisoned")
{
player.life = player.life - 50
player.strength = player.strength + 5
}
else if (player.life <= 0 and player.condition = "poisoned")
{
msg ("You died from the poison in your veins")
msg ("GAME OVER")
finish
}
<script>
</turnscript>
OR (a completely different example, lol, dealing with leveling up, raising your strength by 5)
<object name=player>
<attr name="level" type="int">0</attr>
<attr name="experience" type="int">0</attr>
<attr name="changedexperience" type="script">
if (player.experience >= player.level * 100 + 100)
{
player.experience = player.experience - (player.level * 100 + 100)
player.level = player.level + 1
invoke (player.changedexperience)
}
</attr>
<attr name="changedlevel" type="script">
player.strength = player.strength + 5
</attr>
</object>
commented Oct 23 by hegemonkhan (161 points)
edited Oct 23 by hegemonkhan
here's some links for you:
http://forum.textadventures.co.uk/viewtopic.php?f=18&t=5559
http://forum.textadventures.co.uk/viewtopic.php?f=18&t=4988
http://docs.textadventures.co.uk/quest/guides/running_a_script_when_an_attribute_changes.html (not that explanative, grr. check the 'library and code sections, one of pixie's threads explains the special 'changed' script much better than this link does)
http://docs.textadventures.co.uk/quest/elements/turnscript.html
http://forum.textadventures.co.uk/viewtopic.php?f=10&t=3348&start=120#p22483
http://forum.textadventures.co.uk/viewtopic.php?f=10&t=3348&start=120#p22486 (the key~legend for it, sorry about the abrevs... is very old code, I know better now, lol)
http://docs.textadventures.co.uk/quest/
http://docs.textadventures.co.uk/quest/guides/
http://docs.textadventures.co.uk/quest/guides/character_creation.html
http://forum.textadventures.co.uk/viewforum.php?f=18 (more guides: libraries and code samples)
commented Oct 24 by Toris (1 point)
So I apologize for not quite figuring it out. The changes attribute might be close to what I'm looking for. Probably a turn script.
So under player Attribute:
Object player
Attribute
player.strength = int 20
Key
Strength
Strength:!
In a room I can add in the script player.strength+5 to increase it.
player.endurance = int 20
Key: Endurance
Endurance:!
Now I tried to enter a script for endurance under the player object. I wanted it to be:
player.endurance=20+player.strength/5
When I do that I just get that expression in my stat line.
I want it so I can have endurance increased on it's own, or when strength is increased endurance is updated to increase as well. I'm not sure if it would create a loop of sorts.
So guess the question is how do I make one stat affect another?
commented Oct 24 by hegemonkhan (161 points)
edited Oct 24 by hegemonkhan
just having a script doing what you want is only half of the job, the other half of the job is in getting that script to trigger~activate when you want it to, as having a script that does what you want, but it never triggers~activates, doesn't do you any good.
------------
examples of 'increaser' scripts:
GUI~Editor: add new script -> variables -> 'set a variable or attribute' Script -> (see below)
in-code: player.strength = player.strength + 1
player.strength = player.strength + 5
player.strength = player.strength * 5 // multiplier, so not technically an addition 'increaser'
player.strength = player.endurance + 5
player.strength = player.endurance + player.agility
---------
and now, when or getting, the script to then fire~trigger~activate:
Turnscripts (global, unless you want it locally only for certain rooms)
~OR~
the special 'changed' Script
----------
if you want an Attribute altered, when another Attribute alters, then you need the special 'changed' Script (well, it's easier to implement than with a Turnscript, anyways):
<object name="player">
<attr name="strength" type="int">0</attr>
<attr name="endurance" type="int">0</attr>
<attr name="changedendurance" type="script">
player.strength = player.endurance
<attr>
</object>
about the special 'changed' Script:
when the Attribute in the 'changedATTRIBUTE' tag, changes, the subsequent script(s) trigger~activate~fire
so, in the example above, when the endurance changes, then its scripts activate~trigger~fire, which in the simple example above, makes the 'strength' attribute's value be equal~changed to the new value of the 'endurance' attribute.
or, using your example of:
player.endurance=20+player.strength/5
<object name="player">
<attr name="strength" type="int">5</attr>
<attr name="endurance" type="int">21</attr>
<attr name="changedstrength" type="script">
player.endurance=20+player.strength/5
<attr>
</object>
when your 'strength' changes, your 'endurance' gets re-calculated~re-set to the result of the formula~expression of: 20+player.strength/5
for example explanation:
player.strength = 5
// 20 + (5 / 5)
player.endurance = 21
// you drink a strength elixir that gives you +5 strength (player.strength = player.strength +5):
player.strength = 10
// the 'changed' Script is activated, due to your strength changing (from 5 to 5+5=10):
// 20 + (10/5) = 20 + 2 = 22
player.endurance = 22
-------
I hope you're not using (for example) 'player.endurance = int 20' as this is incorrect syntax.
------
maybe you might want to post your full game code, or add it as an attachment, or if you want to keep it private, you can pm or email or whatever it to me. As I need to know exactly what you're doing, to see what you're doing right and wrong, as it's unclear from what you've been posting here so far.
----------------
the 'STATUS ATTRIBUTES' is merely the DISPLAYMENT of your Attributes during game play in the right side's 'status' pane.
this 'STATUS ATTRIBUTES DISPLAYMENT', GETS updated (via an internal turn, so to update your Attribute's displayment, you need to have the altering Script put in a Turnscript or the special 'changed' Script: you do NOT put your altering script into the STATUS ATTRIBUTES), it does NOT alter your Attributes.
commented Oct 25 by hegemonkhan (161 points)
edited Oct 25 by hegemonkhan
if you want to just increase an Attribute... you need to control it... lol
as this isn't very practical:
game starts -> strength is increased by 1 after every internal turn -> strength = 100 -> strength = 10000000 -> strength = 1000000000000000
you need to control when and~or how~why it increases
for example, limiting stat increases upon 'experience~level' stats is the most well known way ("leveling up").
another way would be to limit it based upon a multiple of some stat:
+5 strength every 100 days:
<turnscript name="global_turnscript">
<enabled />
<script>
if (game.days % 100 = 0)
{
player.strength = player.strength + 5
}
game.days = game.days + 1
</script>
</turnscript>
Turnscripts fire every internal turn, so ever action (click on something or typing and hitting enter) you do, the Turnscript's Scripts are triggering, which in this case, checks for if the game.days is a multiple of 100 (day = 100, day = 200, day = 300, etc), then it will increase your strength by 5.
---------
the '%' math operator is known as 'modulus', it's just a division operation, except it finds the remainder.
and if the remainder is 0, then you've got a multiple of that number you're dividing by (100):
99 % 100 = R: 99 -> 99 is not a multiple of 100
100 % 100 = R: 0 -> 100 is a multiple of 100
150 % 100 = R: 50 -> 150 is not a multiple of 100
200 % 100 = R: 0 -> 200 is a multiple of 100
etc etc etc
commented Oct 25 by hegemonkhan (161 points)
here's Pixie's guide on using the special 'changed' script:
http://forum.textadventures.co.uk/viewtopic.php?f=18&t=5307
and here's my guide on STATUS ATTRIBUTES:
http://forum.textadventures.co.uk/viewtopic.php?f=10&t=5387&p=37393&hilit=statusattributes#p37375
(includes a full sample game for you to see~study)
commented 6 days ago by Toris (1 point)
Awesome Thanks a ton!
I had to alter it a bit, and add another attribute/stat, but the changed script was exactly what I wanted to use
So right now it goes like this
player.endurance=0
player.strength=10
player.power=10
changed.strength=Script player.endurance=player.power+player.strength/5
changed.power=Script player.endurance=player.power+player.strength/5
So endurance would become 12
if player chooses one path and their player.power goes up by +5, then endurance becomes 17
if player chooses another path, their player.strength goes up by +5, then power becomes 13.
Power sort of is a hidden stat, or secondary term for endurance
I was running into trouble when I used:
changedstrength Script
player.endurance= 20+player.strength/5
Every time I added to endurance or to strength it would reset to 20 and calculate, instead of being a progressive continual checking, which is understandable.
So hopefully what I did makes sense, because it seems to be working at the moment!
Now time for me to review about blocking exits and once I firmly figure that out I'll have pretty much what I want for the adventure!
commented 6 days ago by hegemonkhan (161 points)
edited 6 days ago by hegemonkhan
let's call this 'setting ~ re-setting' an Attribute:
player. strength = 10
I (set or re-set) the player's strength to 10, replacing whatever was its value (?unknown? or 'null') beforehand
player.strength = 3
again, I (set'ted or re-set'ted) the player's strength to 3, replacing whatever was its value (10) beforehand.
---------------------------
to actually increase (or as you call it, "progressive") an Attribute:
player.strength = player.strength + 5
// you can use multiplication (*) too, or subtraction (-), division (/), or exponentials (** or whatever the operator symbols are for it) ~ obviously subtraction~division lower your stats, whereas addition~multiplication, raises your stats.
// also, you can use any value, not just '5', as well as using another stat's value too, actually you can do any complexity of formula~equation~expression that you want:
//
// here's my own generalized-skeleton syntax that I use to explain the syntax form:
// Object_name.Attribute_name = Object_name.Attribute_name OPERATOR Value_or_Expression
//
// (ignore the non-logic of this expression below, lol), for an example:
// player.damage = player.damage + player.weapon.damage * (player.strength / 100)
----------------------------------------------
sorry for not explaining this originally (in my first post on this stuff ~ I didn't have the time then, as I was in a rush ~ tons of school work to get done, lol)
---
the VARIABLE (with the Assignment Operator) being used:
player.strength =
first half of the formula~expression being used:
player.strength
last half of the formula~expression being used:
+ 5
the formula's~expression's (only) OPERATOR being used:
+
the full formula~expression being used:
player.strength + 5
the full syntax (the entire code statement) being used:
player.strength = player.strength + 5
-----
anyways, here's the *CONCEPTUAL* explanation~demonstration of what is going on with it:
----
initial (old) value: player.strength = 0
---
old value: player.strength = 0
player.strength (new) = player.strength (old: 0) + 5
player.strength (new) = (0) + 5
player.strength (new) = 5
new value: player.strength = 5
---
old value: player.strength = 5
player.strength (new) = player.strength (old: 5) + 5
player.strength (new) = (5) + 5
player.strength (new) = 10
new value: player.strength = 10
---
old value: player.strength = 10
player.strength (new) = player.strength (old: 10) + 5
player.strength (new) = (10) + 5
player.strength (new) = 15
new value: player.strength = 15
---
old value: player.strength = 15
player.strength (new) = player.strength (old: 15) + 5
player.strength (new) = (15) + 5
player.strength (new) = 20
new value: player.strength = 20
---
etc etc etc
---
and lastly, to hopefully confirm your understanding between the two (setting~re-setting and increasing~progressing) operations:
let's say you now just drank a stat-lowering 'poison apple' in the game, setting~re-setting your strength back to being 0:
player.strength = 0
---
err... lastly, lastly, we finally found a cheat item in the game, giving us godly stats:
player.strength = 100000000000000000000000000
---
lastly lastly lastly, then we level up again, gaining our +5 strength:
player.strength = player.strength + 5
// conceptually: player.strength = player.strength (old: 100000000000000000000000000) + 5
// new value: player.strength = 100000000000000000000000005
------------------
here's another demonstration: transactions (buying~selling):
buying:
player.cash = 100
shop_owner.cash = 500
sword.price = 100
sword.parent = shop_owner
player.cash = player.cash - sword.price
// player.cash = (100) - (100) = 0
shop_owner.cash = shop_owner.cash + sword.price
// shop_owner.cash = (500) + (100) = 600
sword.parent = player
Selling:
(separate example: starting over, *not* continuing from having already done the buying transaction ~ the only difference in the initial stuff~values is the ownership of the sword, obviously)
player.cash = 100
shop_owner.cash = 500
sword.price = 100
sword.parent = player
player.cash = player.cash + sword.price
// player.cash = (100) + (100 / 2) = 150
// you never get full price in games, lol, usually, only get half the item's worth
shop_owner.cash = shop_owner.cash - sword.price
// shop_owner.cash = (500) - (100 / 2) = 450
sword.parent = shop_owner

## Related questions

- Online version of Quest: How do I change the value of Status Attributes?
- Quest Gamebook: How to use AND OR and NOT inside an "if" command?
- Quest Gamebook: Return to a previous page with multiple links, and make link already chosen inactive
- I need help with attributes.
- Quest - Why can't I unlock the door?

...