flag issues

For help with creating games using Quest

Moderators: Pertex, Alex, sgreig, Cryophile, jaynabonne

insidethecircle
Posts: 33
Joined: Wed Sep 09, 2009 9:22 am

flag issues

Postby insidethecircle » Thu Aug 18, 2011 12:45 pm

hello
i got my head around quest version 4 but am 'experienced technical difficulties' at the moment...

i think its just a simple stumbling block getting my head around the new way of doing things so i'm hoping you could give me sample code so i can understand how to solve the following problem.

what im looking for is to create a situation that starts a script that

1.prints a message 'You are still at sea.' if a flag x does exist.
2.prints a message 'You awake on a boat adrift at sea.' if a flag x does not exist.
then a script that creates flag x

im sure that there are loads of ways to do this but im looking for a way with flags just so i can get a foot hold onto the scripting of quest 5

...feel free to giggle / point at laugh at my situation.
thanks

Jhames
Posts: 31
Joined: Thu Jan 01, 2009 6:20 pm

Re: flag issues

Postby Jhames » Thu Aug 18, 2011 2:39 pm

I don't know how to use flags in Q5.
But....

Is very easy doing that with attributes.
So go to the tab or your room, for example "Boat", and go to "attributes". Press add.
Name it with "inside", in the dropbox click boolean, and leave true unmarked.

Now you can make a script, for example "After entering the room"
Add new script.
Select Script - If

And make the condition.
Object attribute equals - Object [Boat] Attribute [inside] = false
Print: You are still at sea.
Else
Object attribute equals - Object [Boat] Attribute [inside] = true
Print: You awake on a boat adrift at sea.

To change the attribute.. in the script go to Variables Set A Variable Or Attribute, and... this is important:
In the box of Set variable, put the name of the object point attribute.

So, in the example look like this (Respect the upper and lower case):

Set variable [Boat.inside] = expression [true]

More or less this is the code:

Code: Select all

  <object name="Boat">
    <inherit name="editor_room" />
    <inside type="boolean">false</inside>
    <enter type="script">
      if (Boat.inside = false) {
        msg ("You are still at sea.")
        Boat.inside = true
      }
      else {
        msg ("You awake on a boat adrift at sea.")
      }
    </enter>
  </object>


I hope this help you.

The Pixie
Posts: 437
Joined: Mon Aug 01, 2011 7:43 am

Re: flag issues

Postby The Pixie » Thu Aug 18, 2011 7:19 pm

Boolean attributes are flags. The SetObjectFlagOn function just sets an attribute to true.

insidethecircle
Posts: 33
Joined: Wed Sep 09, 2009 9:22 am

Re: flag issues

Postby insidethecircle » Mon Aug 22, 2011 12:52 pm

thanks for the help. that is greatly appreciated - ive got some time off in a bit so im hoping to figure all the technical hurdles before i can crack on 'proper'
thanks:)

insidethecircle
Posts: 33
Joined: Wed Sep 09, 2009 9:22 am

Re: flag issues

Postby insidethecircle » Tue Aug 23, 2011 11:53 am

ok.
last night i put this code together based on what you said regarding the attributes - so the code changes a room description relative to entering a room or still being in a room by using attributes.

ive added the code just in case anybody else might like to see how it works
thanks once again


<!--Saved by Quest Editor v5.0-->
<asl version="500">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="attributes flag test">
<autodescription type="boolean">false</autodescription>
<showdescriptiononenter />
<enablehyperlinks type="boolean">false</enablehyperlinks>
</game>
<object name="boat">
<inherit name="editor_room" />
<visited_boat type="boolean">false</visited_boat>
<description type="script">
if (boat.visited_boat = true) {
msg ("You are still at sea.")
}
if (boat.visited_boat = false) {
msg ("You awake to find yourself alone on a boat adrift at sea.")
boat.visited_boat = true
}
ocean.visited_ocean = false
</description>
<object name="player">
<inherit name="defaultplayer" />
</object>
<exit alias="down" to="ocean">
<inherit name="updowndirection" />
</exit>
</object>
<object name="ocean">
<inherit name="editor_room" />
<visited_ocean type="boolean">false</visited_ocean>
<description type="script">
if (ocean.visited_ocean = true) {
msg ("You are still under the sea.")
}
if (ocean.visited_ocean = false) {
msg ("You dive into the ocean and find yourself deep under water.")
ocean.visited_ocean = true
}
boat.visited_boat = false
</description>
<exit alias="up" to="boat">
<inherit name="updowndirection" />
</exit>
</object>
</asl>

insidethecircle
Posts: 33
Joined: Wed Sep 09, 2009 9:22 am

Re: flag issues

Postby insidethecircle » Tue Aug 23, 2011 11:57 am

i figured out how to make to create a flag system that allows you to script different messages. i think the difference between quest 4 and 5 is that, in 5, you need to create the flag before you can use it.

<!--Saved by Quest Editor v5.0-->
<asl version="500">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="flag system">
<autodescription type="boolean">false</autodescription>
</game>
<object name="room">
<inherit name="editor_room" />
<description type="script">
if (not GetBoolean(player, "game")) {
msg ("room description 2")
}
if (GetBoolean(player, "game")) {
msg ("room description 1")
SetObjectFlagOff (player, "game")
}
</description>
<beforefirstenter type="script">
SetObjectFlagOn (player, "game")
</beforefirstenter>
<object name="player">
<inherit name="defaultplayer" />
<look type="string"></look>
</object>
</object>
</asl>

TextingStories
Posts: 58
Joined: Thu May 10, 2012 1:32 am

Re: flag issues

Postby TextingStories » Tue Jun 19, 2012 5:48 am

Jhames wrote:I don't know how to use flags in Q5.
But....

Is very easy doing that with attributes.
So go to the tab or your room, for example "Boat", and go to "attributes". Press add.
Name it with "inside", in the dropbox click boolean, and leave true unmarked.

Now you can make a script, for example "After entering the room"
Add new script.
Select Script - If

And make the condition.
Object attribute equals - Object [Boat] Attribute [inside] = false
Print: You are still at sea.
Else
Object attribute equals - Object [Boat] Attribute [inside] = true
Print: You awake on a boat adrift at sea.

To change the attribute.. in the script go to Variables Set A Variable Or Attribute, and... this is important:
In the box of Set variable, put the name of the object point attribute.

So, in the example look like this (Respect the upper and lower case):

Set variable [Boat.inside] = expression [true]



Ok, I understood everything and did everything (While changing the names of rooms to my game for "outside" and needing a "letter" as the flag to say "I am out side waiting for something" Else "there is a cat".), but I am lost at the part about changing an attribute. Everything before that does not work until you also create the changing of the attribute? I know I tried it and it just keeps telling me "I am outside waiting for something..." with or with out the letter in inventory. In your post it says
To change the attribute.. in the script
(In the Script Tab?)
go to Variables Set A Variable Or Attribute,
(Or is that the Attributes Tab?)
and... this is important:
In the box of Set variable, put the name of the object point attribute.

sgreig
Posts: 391
Joined: Wed Feb 15, 2012 10:16 pm
Location: Winnipeg, MB, Canada
Contact:

Re: flag issues

Postby sgreig » Tue Jun 19, 2012 11:38 am

You're probably better off asking your questions in a new thread rather than posting to one that's been dormant for almost a year.

TextingStories
Posts: 58
Joined: Thu May 10, 2012 1:32 am

Re: flag issues

Postby TextingStories » Tue Jun 19, 2012 5:52 pm

But if I made a whole new post, I most likely would not be able to describe what I needed anyway. So I figured this thread shows exactly what I need to the exact part I am stuck at. It should save every one some time and grief.


Return to “Quest Forum”

Who is online

Users browsing this forum: Baidu [Spider] and 6 guests

cron