'get input' inside a code loop
TinFoilMkIV
07 May 2015, 04:31I'm wondering if there's a way to create a code loop that contains a 'get input' command. It seems as though the 'get input' will wait for the trigger to activate the code contained within itself, however any code outside of it is still executed, resulting in an error stating that only one 'get input' may be active at a time, an breaking the code loop.
an example of what I was attempting is this
so requesting input, where failing to enter an acceptable response prompts the same 'get input' until the player enters an option that the game allows.
an example of what I was attempting is this
loop = true
while (loop) {
get input {
if (result = "keyword") {
msg ("you may continue")
loop = false
//stuff happens
}
else if (result = "leave") {
msg ("you give up, for now...")
loop = false
//go back
}
}
}
so requesting input, where failing to enter an acceptable response prompts the same 'get input' until the player enters an option that the game allows.

Pertex
07 May 2015, 06:20you can do this by calling a recursive function:
<function name="input">
get input {
on ready {
if (result = "keyword") {
msg ("you may continue")
// stuff happens
}
else if (result = "leave") {
msg ("you give up, for now...")
// go back
}
else {
msg("false")
input()
}
}
}
</function>
TinFoilMkIV
07 May 2015, 14:42Yea I came to that conclusion while I was away. I think I may store these functions inside room or controller object attributes, as I'd really like to avoid cluttering up the global function list with things like 'player_inventory_drop_menu1()' or 'combat_general_commands_menu()'
Most of this stuff is really going to apply to a single room or block of code so I'm thinking storing it in an attribute may be the best option for now.
Most of this stuff is really going to apply to a single room or block of code so I'm thinking storing it in an attribute may be the best option for now.
HegemonKhan
07 May 2015, 17:26you can use Objects for data storage:
<game name="xxx">
</game>
<object name="global_data_object">
<attr name="gender_stringlist_attribute" type="simplestringlist">male;female</attr>
<attr name="xxx" type="script">
// blah scripts
</attr>
<object name="sword_1">
<alias>claymore</alias>
// etc Attributes
</object>
// etc other Objects and~or Attributes
</object>
// or, you can do locally too:
<object name="room">
<object name="room_local_data_object">
<attr name="gender_stringlist_attribute" type="simplestringlist">male;female</attr>
// etc other Objects and~or Attributes
</object>
</object>
// and you can also put scripts into Functions, which are global (I don't think Functions can be local).
// you can also put scripts into Commands, which are global (I don't think Commands can be local).
// there's also Turnscripts and Timers, both of which can be global or local.
// you can also use the 'game' Game Object to store data too (though I don't like to crowd this up, prefering to use the independent 'Data' Object
TinFoilMkIV
07 May 2015, 23:20yea, although if the script strictly pertains to one room, might as well make it an attribute of that room.