Third description

OurJud
I know this is similar to the night time thread, but rather than get confused discussion two similar, but slightly different problems, I thought I'd take a different angle.

TP's tutorial http://forum.textadventures.co.uk/viewtopic.php?f=18&t=4807#p31888 for prompting different exterior conditions would seem to be the answer, but I'm not perfectly clear on how to do it as it doesn't address the 'first time / otherwise' script that I use on all my locations.

What I want is this:

1st visit = detailed description, setting the scene and exits

2nd / subsequent visit(s) = brief description with exits

I then want to simulate the passing of a day in the narrative, and have the descriptions be slightly different again (certain doors locked... whatever)

As I say in the other thread, I tried this by setting / calling flags, but one or the other of the other descriptions would show along with the one controlled with the flag.

The Pixie
You want to do this a bit differently, as you have two different flags, one for nighttime and one for visited.

if (GetBoolean(this, "visited")) {
if (GetBoolean(game, "night")) {
msg("It is night and you have been here before")
}
else {
msg("It is day and you have been here before")
}
}
else {
if (GetBoolean(game, "night")) {
msg("It is night and here is a detailed description")
}
else {
msg("It is day and here is a detailed description")
}
}


I think rooms have a flag called visited that is set already by Quest (there is definitely a flag, not sure of the name).

A better approach might be to use text processors or scripts to add extra description if it is your first visit. For example, have a script that fires when you first enter a room that does your detailed description; the terse description applies each time.

Whatever way you do it, you are looking at four descriptions.

OurJud
Thanks, TP.

I've not really understood any of that I'm afraid. Is that code exactly as I would use it? And if this is the script looking for different flags, where do I set the flags?

I've also got the fact that many of my rooms already set/look for flags, which can only add to my confusion when trying to add these.

Silver
Firstly you need to work out how you're going to change the passage of time. Timers or turn timers seem the obvious (only?) choice. So you'll need two, one called night and one called day. In the before game starts scripts get it to set flag day and start timer day.

Then in timer day after whatever passage of time completes set a script to do three things:
Unset flag day
Set flag night
Start timer night

Then do the same in timer night:
Unset flag night
Set flag day
Start timer day.

The game should then forever jump between those two timers. I guess experiment with how long they should be.

Then for the room descriptions You need to think about a way to construct it in three pieces that work together or independently. So I wouldn't have any of the texts reliant on each other. You can do that but it'd be a lot more work.

eg.

You arrive at a park. It gives you a nostalgic feeling of grazed knees and lolipops, happier times from childhood. The moon overhead casts a huge shadow from the seesaw over the concrete below. There is also a swing and slide here looking a little rusty from spending years in the rain.

In your text description (assuming the flag text processor works in TA mode, it suggests it might not...):

You arrive at a park. {once:It gives you a nostalgic feeling of grazed knees and lolipops, happier times from childhood.} {If Night: The moon overhead casts a huge shadow from the seesaw over the concrete below.} {If Day: The paint on the seesaw glistens under the midday sun.} There is also a swing and slide here looking a little rusty from spending years in the rain.

Actually I suspect that won't work as the flag check isn't to an object which the TA mode needs. So just get the room description to run a script.

If object (whatever you put the flags on) has flag day
print message: You arrive at the park. The paint on the seesaw glistens under the midday sun. {once:It gives you a nostalgic feeling of grazed knees and lolipops, happier times from childhood.} There's also a blah blah.

Else
print message: You arrive at a park. {once:It gives you a nostalgic feeling of grazed knees and lolipops, happier times from childhood.} The moon over head casts a shadown from the seesaw on the concrete below. There's also a blah blah.

OurJud
Silver wrote:Firstly you need to work out how you're going to change the passage of time. Timers or turn timers seem the obvious (only?) choice. So you'll need two, one called night and one called day. In the before game starts scripts get it to set flag day and start timer day.

Sorry if I didn't explain properly, but this night level isn't intended only as a way of portraying the passing of time, it actually has a purpose in terms of the game's mechanics, and will only happen once.

The player only gets once chance on their first attempt, to gather certain information from a number of sources. If they fail by taking the wrong action or asking the wrong questions/not asking any questions, that's it, in terms of that particular approach. Those sources will then be closed to them.

However, when this happens, I send them back to their apartment for some sleep, and this triggers the night level, during which they are able to get the information using different methods (break-ins, etc). During this night time level I will give them far more guidance so that they don't fail to gather the necessary information a second time. This means, depending on how good the player is, they may never even see the night time level.

Jay has now showed me how to successfully trigger the night time descriptions. I was on the right lines, but just nesting the flags and 'elses' in the wrong order.

The Pixie
Go to the Room tab of a room, and Where it says Description, change Text to Run script. Go to the seventh icon, Code view, and paste the above code in.

The visited flag is set automatically by Quest. You will need to set the night flag on the game object whenever it becomes night.

game.night = true

HegemonKhan
'flags' is just a general term for Attributes, that you use to check upon (if~else if~else) their value (which is a 'state' of something within your game) to determine an action~event:

examples of 'flags' in use:

using a Boolean Attribute:
(limited to only 2 'states' )
orc.dead = false
if (orc.dead = true) {
-> msg ("The orc is already dead, silly.")
} else if (orc.dead = false) {
-> msg ("You attack and kill the orc.")
-> orc.dead = true
}
// Flag (Boolean Attribute): orc.dead = (true or false)
// State (Value of the Boolean Attribute): (true or false)
// Check (if~else if~else): if (orc.dead = true) { (script1) } else if (orc.dead = false) { script2 }
// Action~Event: (script1 or script 2)

using an Integer Attribute:
(unlimited 'states' )
orc.dead = 0
if (orc.dead = 1) {
-> msg ("The orc is already dead, silly.")
} else if (orc.dead = 0) {
-> msg ("You attack and kill the orc.")
-> orc.dead = 1
}
// Flag (Integer Attribute): orc.dead = (0 or 1)
// State (Value of the Integer Attribute): (0 or 1)
// Check (if~else if~else): if (orc.dead = 0) { (script1) } else if (orc.dead = 1) { script2 }
// Action~Event: (script1 or script 2)

using a String Attribute:
(unlimited 'states' )
orc.dead = "0"
if (orc.dead = "1") {
-> msg ("The orc is already dead, silly.")
} else if (orc.dead = "0") {
-> msg ("You attack and kill the orc.")
-> orc.dead = "1"
}
// Flag (String Attribute): orc.dead = ("0" or "1")
// State (Value of the String Attribute): ("0" or "1")
// Check (if~else if~else): if (orc.dead = "0") { (script1) } else if (orc.dead = "1") { script2 }
// Action~Event: (script1 or script 2)

using a String Attribute:
(unlimited 'states' )
orc.dead = "red"
if (orc.dead = "blue") {
-> msg ("The orc is already dead, silly.")
} else if (orc.dead = "red") {
-> msg ("You attack and kill the orc.")
-> orc.dead = "blue"
}
// Flag (String Attribute): orc.dead = ("blue" or "red")
// State (Value of the Boolean Attribute): ("blue" or "red")
// Check (if~else if~else): if (orc.dead = "blue") { (script1) } else if (orc.dead = "red") { script2 }
// Action~Event: (script1 or script 2)

and etc Attributes too:

Object Attribute
List Attribute
Dictionary Attribute
Object Type (Inherited) Attribute

-----------

the 'firsttime~otherwise' Script~Function:
(limited to only 2 'states' )
firsttime {
-> msg ("You attack and kill the orc.")
} otherwise {
-> msg ("The orc is already dead, silly.")

HegemonKhan
an example of deep nesting (multiple layers) of flags:

orc.dead = false
orc.cash = 100
orc.damage = 50
orc.life = 500
orc.weapon = iron_sword
orc.speed = GetRandomInt (0,100)

player.cash = 0
player.damage = 100
player.life = 999
player.weapon = steel_sword
player.speed = GetRandomInt (0,100)

Object: player
Object: orc
Object: unarmed
Object: iron_sword
Object: steel_sword

if (orc.dead = true) {
if (orc.cash = 0 and orc.weapon = unarmed) {
msg ("The orc is dead, and you've already looted its corpse of cash and equipment, silly.")
else if (orc.cash = 0 and orc.weapon = iron_sword) {
iron_sword.parent = player
orc.weapon = unarmed
msg ("You loot the iron sword from the dead orc's corpse.")
} else if (orc.cash > 0 and orc.weapon = unarmed) {
player.cash = player.cash + orc.cash
orc.cash = 0
msg ("You loot the cash from the dead orc's corpse.")
} else if (orc.cash > 0 and orc.weapon = iron_sword) {
wooden_sword.parent = player
orc.weapon = unarmed
player.cash = player.cash + orc.cash
orc.cash = 0
msg ("You loot the cash and iron sword from the dead orc's corpse.")
}
} else if (orc.dead = false) {
if (player.speed > orc.speed) {
msg ("You attack the orc.")
orc.life = orc.life - player.damage
if (orc.life <= 0) {
orc.dead = true
msg ("You kill the orc.")
} else if (orc.life > 0) {
msg ("The orc attacks you.")
player.life = player.life - orc.damage
if (player.life <= 0) {
msg ("The orc killed you.")
msg ("GAME OVER")
finish
}
}
} else if (player.speed < orc.speed) {
msg ("The orc attacks you.")
player.life = player.life - orc.damage
if (player.life <= 0) {
msg ("The orc killed you.")
msg ("GAME OVER")
finish
} else if (player.life > 0) {
msg ("You attack the orc.")
orc.life = orc.life - player.damage
if (orc.life <= 0) {
orc.dead = true
msg ("You killed the orc.")
}
}
} else if (player.speed = orc.speed) {
if (RandomChance (50) = true) {
msg ("You attack the orc.")
orc.life = orc.life - player.damage
if (orc.life <= 0) {
orc.dead = true
msg ("You kill the orc.")
} else if (orc.life > 0) {
msg ("The orc attacks you.")
player.life = player.life - orc.damage
if (player.life <= 0) {
msg ("The orc killed you.")
msg ("GAME OVER")
finish
}
}
} else {
msg ("The orc attacks you.")
player.life = player.life - orc.damage
if (player.life <= 0) {
msg ("The orc killed you.")
msg ("GAME OVER")
finish
} else if (player.life > 0) {
msg ("You attack the orc.")
orc.life = orc.life - player.damage
if (orc.life <= 0) {
orc.dead = true
msg ("You killed the orc.")
}
}
}
}
}

The Pixie
HegemonKhan wrote:'flags' is just a general term for Attributes, ...

Specifically for Boolean attributes, so they have only two states. When called a flag in the UI, it is either off or on, when called a Boolean attribute in code it is either false or true.

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

Support

Forums