Turn scripts with multiple messages.

sleazy_mcgee
Hi, I'm really new to Quest and I've just started making my first game, but I've run into a bit of a hurdle and I was hoping someone could point me in the right direction.

I'm trying to create a turn script that will return different messages as the integer hits different numbers. I've initially tried this by having multiple "If attribute is = [number]" scripts, but this seems to trigger the first in the sequence but not the subsequent messages.

The second problem was I wanted to have the same message printed multiple times (like for example, a phone ringing) for a limited number of turns with message changing to be more urgent the closer the timer got to zero. However I've noticed having specific numbers after an entry that reads "If attribute = >10]" (for example) will crash the script.

Any suggestions on how these things can be accomplished?

HegemonKhan
Can you work with the Code, or do you use the GUI~Editor?

(I'll help in code, as it's much faster for me, but if you need help in doing this stuff with the GUI~Editor, then just wait and someone will help you, and~or when I got the time, I'll help with the GUI~Editor too, but I don't know when that'll be, as all I do is work and sleep, sighs, and am really exhausted each day from work, and on my few days off too, I'm usually tired as well)

------------

mcgee wrote:I'm trying to create a turn script that will return different messages as the integer hits different numbers. I've initially tried this by having multiple "If attribute is = [number]" scripts, but this seems to trigger the first in the sequence but not the subsequent messages.


Attributes:

Code:

Object_name.Attribute_name = Value_or_Expression

String Attributes (examples):

Quotes on the Value or on the textual parts of the Expression

player.alias = "HK"
game.static_greeting = "Hi, my name is HK. What is your name?"
game.dynamic_greeting = "Hi, my name is " + player.alias + ". What is your name?"
rose.color = "red"
rose.petals = "4"
rose.petals_string = "4"
player.condition = "poisoned"
player.action = "walking"

Object Attributes (examples):

NO quotes on the Value, and the Value must be an actual created~existing Object in the game. Value can't be 'true' or nor 'false' or nor numerical

player.left_hand = sword
player.parent = room
game.pov = player

Integer Attributes (examples):

NO quotes on the numerical Values

player.strength = 50
HK.strength = 100
game.event_flag = 0

player.damage = player.sword.damage + player.sword.damage * player.strength / 100 - orc.plate_mail.armor_class - orc.plate_mail.armor_class * orc.endurance / 100

Boolean Attributes (examples):

Value is only 'true' or 'false' and no quotes on it

orc.dead = true
orc.dead = false
player.flying = true
player.poisoned = false
game.event_flag_1 = true

Lists (String Lists or Object Lists), examples:

HK.favorite_colors = split ("black;red", ";")
game.conditions_list = split ("poisoned;petrified;silenced;paralyzed;normal;asleep;blinded;stunned;cursed", ";")
player.locomotion = split ("bipedal;jogging", ";")
player.equipment = split ("sword;plate_mail;boots;helmet;pauldrons;vambraces;greaves;tasset;guantlets;shield", ";")

---------------

the 'if' Script:

if [EXPRESSION] Object_name.Attribute_name (operator: =, <>, >, <, >=, or <=) Value_or_Expression

mcgee wrote:However I've noticed having specific numbers after an entry that reads "If attribute = >10]" (for example) will crash the script.


~ if you're doing this in code, you need to put the script inside of this (example using a Function)

<![CDATA[ script ]]>

as it tells quest that the '>' and '<' symbols are your operators, and not your coding tags, (otherwise, you'll get errors)

<function name="xxx"><![CDATA[
if (game.y < 0) {
msg ("negative")
} else if (game.y > 0) {
msg ("positive")
}
]]></function>


----------------

these two SUPER SCRIPTS let you do 90% of what you want to do with your game, especially when used together (if~code logic mentality):

GUI~Editor:

1. run as script -> add a script -> variables -> 'set a variable or attribute' Script -> (see above)

2. run as script -> add a script -> scripts -> 'if' Script -> (see below)

---------------

the chain sequence is produced by (generic examples):

(clicking on the correct 'add a script' circle buttons is annoyingly difficult in the GUI~Editor, and this matters for your scripting ~ script block, to work, as it is the 'nesting', aka the indenting, that determines the proper 'order of operations' for the running of your scripts)

if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
-> then -> add script
else
-> then -> add script

~OR~

if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
-> then -> add script
else if [expression] -> Object_name.Attribute_name = Value_or_Expression
-> then -> add script

~OR~

if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
-> then -> add script
else if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
-> then -> add script
else
-> then -> add script

~OR (deeper~multiple layers~layering)~

if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
-> if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
->-> then -> add script
-> else if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
->-> then -> add script
-> else
->-> then -> add script
else if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
-> if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
->-> then -> add script
-> else if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
->-> then -> add script
-> else
->-> then -> add script
else
-> if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
->-> then -> add script
-> else if -> [expression] -> Object_name.Attribute_name = Value_or_Expression
->-> then -> add script
-> else
->-> then -> add script

-----------

as for examples in helping you with your questions:

http://docs.textadventures.co.uk/quest/ ... cript.html
http://docs.textadventures.co.uk/quest/ ... ripts.html

<object name="global_data_object">
<inherit name="editor_object" />
<attr name="dialogue_integer" type="int">0</attr>
<attr name="turn_integer" type="int">0</attr>
</object>

<object name="test_object_1">
<inherit name="editor_object" />
<parent>game.pov</parent>
<inventoryverbs type="simplestringlist">increase_dialogue</inventoryverbs>
<increase_dialogue type="script">
global_data_object.dialogue_integer = global_data_object.dialogue_integer + 1
</increase_dialogue>
</object>

<turnscript name="turnscript_1">
<enabled />
<script>
msg ("Dialogue Integer: " + global_data_object.dialogue_integer)
if (global_data_object.dialogue_integer = 0) {
msg ("0")
} else if (global_data_object.dialogue_integer = 1) {
msg ("1")
} else if (global_data_object.dialogue_integer = 2) {
msg ("2")
} else if (global_data_object.dialogue_integer = 0) {
msg ("3")
// etc more or less 'else if' scripts
} else {
msg ("xxx")
}
global_data_object.turn_integer = global_data_object.turn_integer + 1
</script>
</turnscript>


I'm tired now... the above isn't completed... but, see below:

mcgee wrote:The second problem was I wanted to have the same message printed multiple times (like for example, a phone ringing) for a limited number of turns with message changing to be more urgent the closer the timer got to zero.


http://docs.textadventures.co.uk/quest/
http://docs.textadventures.co.uk/quest/elements/
http://docs.textadventures.co.uk/quest/ ... timer.html
http://docs.textadventures.co.uk/quest/ ... ripts.html

look up 'Timers', use Timers with the above stuff (Turnscripts, 'set a variable or attribute' Script, and 'if' Script) to get what you want, but this is a bit advanced, so ask if you're confused on how to do it.

Silver
In your start script add this:

player.turns = 0 


Then in your room description select run a script and do this:

player.turns = player.turns + 1
if (player turns = 4) {
player.turns = 1
}
msg ("{if player.turns=1:your first message}{if player.turns=2:your second message}{if player.turns=3:your third message}")


That will rotate between 3 messages each time the room description is viewed, which might not be what you want but it's just an example of one way of doing it. For the phone you'd have to use timers. There's no way I can explain that when posting from my phone but I'll make a demo later if nobody else had answered.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums