Organize Multiple npc routes

I've been relying on putting flags on things for a while now but i dont thing it will work with this concept

my latest game has the player encounter and play with 'intimate' routes with a few characters as well as a character that show up if none of the routes are started after a certain point in the story (not timer-based)

How can I do this? the if script only has 1 condition, right?


"How can I do this? the if script only has 1 condition, right?"
Short answer... no...
if (this=2 and that=2 or other<>5) {
then do something strange here
}
else if (this=5 and that=0 and other=4) {
then do something stranger
}
else {
msg("I have no idea what you want!")
}


@darklizard short answer isn't a good explanation


short answer isn't a good explanation

Hello.

In DL's defense, he was providing a vague example, assumedly because you provided no example code.

Let's say the player object has three attributes, this, that, and other.

player.this is set to the value 5

player.that is set to the value 0

player.other is set to the value 4

Here's a slightly less vague example script using those attributes:

if (player.this = 2 and player.that = 2 and not player.other = 4){
  msg ("This is 2, that is 2, but other is not 4.")
}
else if (player.this = 5 and player.that = 0 and player.other = 4){
  msg ("This is 5, that is 0, and other is 4.")
}
else {
  msg ("Neither this, that, nor the other are currently worth anything special.")
}

In this example, it would print, "This is 5, that is 0, and other is 4."


http://docs.textadventures.co.uk/quest/scripts/if.html


(filler for getting my edited post, updated/posted)


Boolean Logic (and Boolean Algebra) ("Truth Tables") (used in programming and at the hardware with the circuitry designs of its computer chip components/parts: Logic Gates) (and also with human language, sentences/paragraphs/prose/writing, in Philosophy-Logic via its Symbolic Logic):

https://en.wikipedia.org/wiki/Truth_table

https://en.wikipedia.org/wiki/Boolean_algebra

https://www.mi.mun.ca/users/cchaulk/misc/boolean.htm

https://en.wikipedia.org/wiki/Logic_gate

https://philosophy.lander.edu/logic/symbolic.html (at the bottom, there's page arrows, there's a bunch of pages you can read, to learn the basics of symbolic logic)

https://philosophy.lander.edu/logic/symbolic_topics.html (index page for the symbolic logic in the link above)


Definition logic operation:

true -> TRUE
false -> FALSE

Negation ('NOT') logic operation:

not true -> FALSE
not false -> TRUE

'AND' logic operation:

true and true -> TRUE
true and false -> FALSE
false and true -> FALSE
false and false -> FALSE

'OR' logic operation:

true or true -> TRUE
true or false -> TRUE
false or true -> TRUE
false or false -> FALSE


example:

// needed pre-set-up code/scripting (for completeness) for this example of mine:

create ("example_object")

example_object.boolean_stringlist_variable = NewStringList ()
list add (example_object.boolean_stringlist_variable, "true")
list add (example_object.boolean_stringlist_variable, "false")

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

// this is just code/scripting that randomly selects the boolean values (true/false) for the Boolean Attributes ('example_object.cleaned_room' and 'example_object.mowed_lawn')

example_object.cleaned_room = StringListItem (example_object.boolean_stringlist_variable, GetRandomInt (0, ListCount (example_object.boolean_stringlist_variable) - 1))

// randomly selected:
//
// example_object.cleaned_room = true
// or:
// example_object.cleaned_room = false

example_object.mowed_lawn = StringListItem (example_object.boolean_stringlist_variable, GetRandomInt (0, ListCount (example_object.boolean_stringlist_variable) - 1))

// randomly selected:
//
// example_object.mowed_lawn = true
// or:
// example_object.mowed_lawn = false

----------

// 'AND' Boolean Logic:

// (if you do both chores, and only if you do both chores, do you get $5)

if (example_object.cleaned_room and example_object.mowed_lawn) {
  player.allowance = player.allowance + 5
  msg ("Since you did both chores, cleaning your room and mowing the lawn, you get $5")
} else if (example_object.cleaned_room) {
  msg ("While you cleaned your room, you didn't mow the lawn, and you needed to do both chores, to get $5")
} else if (example_object.mowed_lawn) {
  msg ("While you mowed the lawn, you didn't clean your room, and you needed to do both chores, to get $5")
} else {
  msg ("You didn't do any chores, and you needed to do both chores, to get $5")
}

// which is the same as this:

if (example_object.cleaned_room) {
  msg ("You cleaned your room")
  if (example_object.mowed_lawn) {
    msg ("You also mowed the lawn")
    player.allowance = player.allowance + 5
    msg ("In doing both chores, you get $5")
  } else {
    msg ("While you cleaned your room, you didn't mow the lawn, and you needed to do both chores, to get $5")
  }
} else if (example_object.mowed_lawn) {
  msg ("You mowed the lawn")
  if (example_object.cleaned_room) {
    msg ("You also cleaned your room")
    player.allowance = player.allowance + 5
    msg ("In doing both chores, you get $5")
  } else {
    msg ("While you mowed the lawn, you didn't clean your room, and you needed to do both chores, to get $5")
  }
} else {
  msg ("You didn't do any chores, and you needed to do both chores, to get $5")
}

// in other words, the 'and' logic operator/operation is the same as nested 'ifs':

if (CONDITION_1 and CONDITION_2 and CONDITION_3 and CONDITION_4 and CONDITION_5 and CONDITION_6 and CONDITION_7 and CONDITION_8 and CONDITION_9 and CONDITION_10) {
  msg ("TRUE")
} else {
  msg ("FALSE")
}

// is the same as this:

if (CONDITION_1) {
  if (CONDITION_2) {
    if (CONDITION_3) {
      if (CONDITION_4) {
        if (CONDITION_5) {
          if (CONDITION_6) {
            if (CONDITION_7) {
              if (CONDITION_8) {
                if (CONDITION_9) {
                  if (CONDITION_10) {
                    msg ("TRUE")
                  } else {
                    msg ("FALSE")
                  }
                } else {
                  msg ("FALSE")
                }
              } else {
                msg ("FALSE")
              }
            } else {
              msg ("FALSE")
            }
          } else {
            msg ("FALSE")
          }
        } else {
          msg ("FALSE")
        }
      } else {
        msg ("FALSE")
      }
    } else {
      msg ("FALSE")
    }
  } else {
    msg ("FALSE")
  }
} else {
  msg ("FALSE")
}

--------

// 'OR' Boolean Logic:

// (if you do at least one of the chores, it doesn't matter which one, or if you do both chores, you get $5)

if (example_object.cleaned_room or example_object.mowed_lawn) {
  if (example_object.cleaned_room) {
    msg ("You cleaned your room")
  }
  if (example_object.mowed lawn) {
    msg ("You mowed the lawn")
  }
  player.allowance = player.allowance + 5
  msg ("Since you did at least one of the two chores, you get $5")
} else {
  msg ("You didn't do any chores, and you only needed to do at least one of the chores, to get $5")
}

// which is the same as this:

if (example_object.cleaned_room) {
  if (example_object.mowed lawn) {
    msg ("You also mowed the lawn")
  }
  player.allowance = player.allowance + 5
  msg ("Since you did at least one of the two chores, you get $5")
} else if (example_object.mowed_lawn) {
  if (example_object.cleaned_room) {
    msg ("You also cleaned your room")
  }
  player.allowance = player.allowance + 5
  msg ("Since you did at least one of the two chores, you get $5")
} else {
  msg ("You didn't do any chores, and you only needed to do at least one of the chores, to get $5")
}

I think I get how it works now...
I'll give it a try and see how it goes...


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

Support

Forums