How to set true and false

I was new to this and when I tried to set true and false, it show me really confused and overcomplication and I do not understand while I try to do like check on different scripts, none seem work.
What am I missing?


They call these kinds of attributes "Boolean" as in Boolean logic. T/F.

Here's a bit pasted from somewhere in the depths of the Quest documentation: https://docs.textadventures.co.uk/quest/types/boolean.html

Boolean
A Boolean can be either true or false. When using the GUI to create a script, they are called flags, and can be on or off. Boolean attributes are extremely use as they can tell us the current state of an object. It the torch on or off? Is the hat worn or not? Has the room been visited?

Note that you do not need to compare a Boolean to true or false. It is already one of the other. Instead of:

if (player.is_successful = true) {

Just do:
if (player.is_successful) {

If you want to test that it is not true, just add the not keyword:
if (not player.is_successful) {

Also note that to do any of them you need to ensure the Boolean is initialised (i.e., it has a value at the start of the game). If player.is_successful has not been set, then when you do one of the comparisons above you will get an error message.
Alternatively, use GetBoolean, which returns true if the attribute is true, or false if it is false or null (i.e., has not been set).
if (GetBoolean(player, "is_successful")) {
Or:
if (not GetBoolean(player, "is_successful")) {

They call the boolean you're trying to work with a "flag" which is either "on"=true or "off"=false.

So the scripts to set them are SetObjectFlagOn or SetObjectFlagOff and then the name of the flag goes in quotes. So to make player = "ugly" true you do

SetObjectFlagOn(player, "ugly")

Here's hoping that helps! I'm new too, but I'm loving the learning process!


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

Support

Forums