Newbie Gamebook Confusion

werew
I've started with quest not that long ago, and have been full steam ahead on a gamebook project, but I've run into a bit of functionality that I'd like to add and can't seem to figure out how to do for the life of me.

I'm basically trying to add relationship levels to the characters in the story, so that if you get someone on your side, they'll be more likely to help you... but I'd rather it be a scale than using a simply "if" command so that the relationship level can be anywhere from -5 to 10 (or anything that works). I've tried using the "set variable" script, to no avail. I'm not sure if I just don't understand what I'm doing, am getting something small wrong, or am completely using the wrong kind of script for what I'm trying to do.

Is this possible with gamebooks? I'm so lost with the tutorial/wiki, as I can't seem to find mention of doing something like that... but even sending me to the right page might help, if such a tutorial exists and I haven't found it.

My fail attempt can be seen in my game file under LifeintheOrder -> nursery cave -> pleasebemyfriend 0 FIX SCRIPT. I also tried to use script on the page "pursue590 0", but that page isn't returning an error like the other one is (I dunno if that means I did it right, or that it just didn't fuss at me....)

Thanks in advance!

jaynabonne
The problem is that a variable is local to the script where its set. So it won't persist to other pages. You can use attributes instead, by storing into an object's attribute (e.g. "game.count" or "player.someattr").

It does look like there are some built-in gamebook function for doing what you want: counters. You can set a counter, increase and decrease a counter by one, or change a counter by an arbitrary amount. That would allow you to keep track the way you've been trying. I don't see a method to retrieve a counter, but it's just attached to the game object. You can test the value of the counter at some point with an "if" script.

If that won't work for you, let me know, and we can see if there's something better.

HegemonKhan
The problem with the ' set a variable or attribute ' Script in the GUI~Editor, is that it forces the "=", whereas for a range (or as you call it, a scale, if I understand your question, lol), you need the "<", ">", "<=", ">=", "and", and~or "or".

------

I never used gamebooks, but for text adventure, we'd do this:

-----

Operators and~or Conditionals:

less than: <
greater than: >
lesser than or equal to: <=
greater than or equal to: >=
equals to: =
not equals to: <>
// example: if (HK.dead <> true) -> ' if HK is alive ', VS, if (HK.dead=true) -> ' if HK is dead '
not equals to: not
// example: if (not HK.dead=true) -> ' if HK is alive ', VS, if (HK.dead=true) -> ' if HK is dead '
and: and
// example: if (periodic_element.Cesium and periodic_compound.H2O), then... big explosion!
or: or
// example: we want to be facing to the right: if (you.turn_45_degrees_to_the_right_once or you.turn_45_degrees_to_the_left_thrice), then... you're facing to the right

------

run as script -> add a script -> scripts -> if -> [EXPRESSION] -> Object.Attribute >= Value and Object.Attribute < Value ->
-> then -> // whatever script(s)

in code, it'd look like this (an example):

<function name="age_integer_to_string_function"><![CDATA[
if (game.pov.age_integer >= 0 and game.pov.age_integer < 4) {
game.pov.age_string = "baby"
} else if (game.pov.age_integer >= 4 and game.pov.age_integer < 13) {
game.pov.age_string = "child"
} else if (game.pov.age_integer >= 13 and game.pov.age_integer < 20) {
game.pov.age_string = "teen"
} else if (game.pov.age_integer >= 20) {
game.pov.age_string = "adult"
}
]]></function>


---------

or using your 'relationship' Attribute (an example):

if (npc.relationship_integer < 0) {
-> npc.relationship_integer = 0
} else if (npc.relationship_integer > 100) {
-> npc.relationship_integer = 100
}
if (npc.relationship_integer >= 0 and npc.relationship_integer < 33) {
-> npc.relationship_string = "enemy"
} else if (npc.relationship_integer >= 33 and npc.relationship_integer < 66) {
-> npc.relationship_string = "neutral"
} else if (npc.relationship_integer >= 66 and npc.relationship_integer <= 100) {
-> npc.relationship_string = "friend"
}
if (npc.relationship_string = "enemy") {
-> // ' fight ' scripts
} else if (npc.relationship_string = "neutral") {
-> // ' dialogue ' scripts
} else if (npc.relationship_string = "friend") {
-> // ' give gifts like items or equipment or spells to you ' scripts

werew
Thanks guys, I'm a lot less confused. I'll try fussing around with the things you've said and figure out what will work. :) (and no doubt get confused again and have to return but one step closer, eh?)

EDIT: With only a little trial and error, counters works perfectly! Thanks again you two :) (also {counter:countername} returns the value of the counter. I don't think I'll need it but it's good to know)

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

Support

Forums