The official "Spieltgeist needs help" thread

Spieltgeist
28 Jul 2013, 18:57
I figure I'll just use one thread for all future help I'll need instead of making a new thread each time.

My newest problem is getting menus to work correctly. I followed the tutorial but every time I try to get it to run, I get the utterly confounding "Error running script: Error compiling expression 'yesno': Unknown object or variable 'yesno'"

I specified yesno as a NewStringList() in the game's start up script
yesno = NewStringList()
list add (yesno, "Yes")
list add (yesno, "No")


Just like that. But it doesn't seem to actually do anything. Here's the code for when the menu actually gets called.

if (GetBoolean(Victim, "killanyway")) {
ShowMenu ("place holder text", yesno, false) {
if (result = "yes") {
msg ("<br/>long unpleasant text scene")
}
else if (result = "No") {
msg ("There's sure to be a weapon around here somewhere.")
}


This is the same problem for all the menus as well. Like I said I followed the tutorial for this one, and tried using the name "menulist" instead of yesno and got the same problem. Any ideas?

HegemonKhan
28 Jul 2013, 19:33
luckily, this is a very simple fix, one small thing that you're missing in your understanding here:

Commands, Functions, Turnscripts, Object Types, and Objects don't need any parents (they don't need to be attached to anything).

Attributes (strings, scripts, booleans, integers, doubles, lists, dictionaries, verbs ~ I think, and etc) need parents (they need to be attached to something).

all you got to do, is to add your "yesno" simplestringlist attribute to (for example) a global~permanent object, such as for an example, your Game Object.

<game name="blah">
<yesno type="simplestringlist">yes; no</yesno>
</game>


and then in your code, you need this:

show menu ("Do you choose Yes or No?", game.yesno, false) {
// whatever script
}


for this to really make sense, think of using a "strength" integer attribute. A "strength" attribute for what? You can't just have a "floating" strength attribute, not attached to anything. Quest needs attributes to be attached to something, such as objects, like "HK" and "orc", HK.strength vs orc.strength, hehe :D

HegemonKhan
28 Jul 2013, 19:57
[Edited just now, due to forgetting to change game.yesno to global_lists_object.yesno in the showmenu script]

err, let me do this again, using your code, so that it is clear as to what you need to do (an example only as I'm not quite sure how you're setting this up):

(I'm going to create a "global lists object", in this case. It's a little more "advanced" then simple using the Game Object, as it lets you organize your code stuff better for yourself, for example, all of our created lists, will be ~stored as~attached to~ this global lists object)

<global_lists_object type="object">
<inherit name="editor_object" />
<parent>null</parent>
</global_lists_object>

<verb name="blah">
firsttime {
global_lists_object.yesno = NewStringList()
list add (global_lists_object.yesno, "Yes")
list add (global_lists_object.yesno, "No")
on ready {
if (GetBoolean(this.Victim, "killanyway")) {
ShowMenu ("place holder text", global_lists_object.yesno, false) {
if (result = "yes") {
msg ("<br/>long unpleasant text scene")
} else if (result = "No") {
msg ("There's sure to be a weapon around here somewhere.")
}
}
}
}
} otherwise {
if (GetBoolean(this.Victim, "killanyway")) {
ShowMenu ("place holder text", game.yesno, false) {
if (result = "yes") {
msg ("<br/>long unpleasant text scene")
} else if (result = "No") {
msg ("There's sure to be a weapon around here somewhere.")
}
}
}
}
}
</verb>

Spieltgeist
28 Jul 2013, 20:06
Mhm! That fixed it alright. I'll have to remember to attach these list thingies onto other things. Thanks a lot friend. I think that's about all the problems I had for today. Tune in next week when I mistype a variable and break the entire game!

Spieltgeist
28 Jul 2013, 20:12
Actually, that might be a good feature for future version. An easy to add list system in the same fashion of the way one would add an object.

HegemonKhan
28 Jul 2013, 20:26
yep, it's really useful, you can use (nonparented: <parent>null</parent>) objects as "data storage" objects, here's some ideas for them:

"global_events_object"
"global_flags_or_booleans_object"
"player_storage_object"
"global_monsters_object"
"global_items_object"
"dialogue_lists_or_dictionaries_object"
"game_storage_object"
"global_spells_object"
"global_weapons_object"
"global_armors_object"
"global_npcs_object"

for an example of using it:

<command name="fight">
<pattern>fight #text#</pattern>
<script>
if (text = "red orc") {
monster = GetObject (global_monsters_object.orc_list.red_orc)
fight_function (player,monster)
} else if (text = "lion") {
monster = GetObject (global_monsters_object.animal_list.lion)
fight_function (player,monster)
} else if (text = "fire dragon") {
monster = GetObject (global_monsters_object.dragon_list.fire_dragon)
fight_function (player,monster)
} else {
msg ("blah")
}
</script>
</command>

<function name="fight_function" parameters="monster">
// blah blah blah scripts
</function>

<global_monsters_object type="object">
<inherit name="editor_object" />
<parent>null</parent>
<orc_list type="objectlist">green_orc;blue_orc;red_orc</orc_list>
<dragon_list type="objectlist">earth_dragon;water_dragon;air_dragon;fire_dragon</dragon_list>
<animal_list type="objectlist">snake;wolf;lion;tiger;bear</animal_list>
</global_monsters_object>