Making a night time level

OurJud
I want to trigger a night time level if my player fails to gather certain information on their first attempt (the night time level will give them a second chance to gather the information a different way).

I thought this would be fairly straightforward (what a fool am I?) by using flags, but because I already have two descriptions for each of my locations (a detailed one for 1st visit, less detailed for subsequent visits) this is proving difficult.

The basic idea was to set a flag on the player called 'nightlevel' at the point at which he's failed in certain tasks. After some narrative about it having been a long day and him wanting to get some rest, I 'move' him back to his apartment. I thought I could then simply check for the 'nightlevel' flag at each of the locations, and give a night time description. Once they successfully complete the task they failed at the first time, I remove the flag and move him back to his apartment, ready to start a new day and continue the story.

The problem seems to be getting the game to ignore the other room descriptions if the flag is present, and only print the night time description.

Would I be right in saying a room can't have more than two descriptions triggered?

Would the script that checks for the 'nightlevel' flag have to be the first thing in the block of scripts in the room descriptions?

Another way, of course, would be to simply create night versions for each room, i.e 'gas station' and 'gas station night', and just move the player to the night time version of the rooms during the night stage. However, this would be a lot of work as it means creating a whole set of exits too.

Any ideas how I could achieve this?

I tried TP's method here, but couldn't get the desired effect. Again, I think it's because I already have two descriptions for each of my rooms. Many are already checking for other flags too - which doesn't help matters.

viewtopic.php?f=18&t=4807#p31888

george
There's not a limit on how many descriptions a room can have. Did you try Pixie's technique with the switch from that post you linked? Though I would modify the switch a little, I think you can switch on words like "night", "day", etc. rather than numbers. Makes it easier to keep track of things.

OurJud
george wrote:Did you try Pixie's technique with the switch from that post you linked?

Yes. I can get the night time description to show, but one of the other descriptions shows too, depending on whether it's my first or second visit there.

OurJud
I'm doubling up all my rooms at the moment, calling them '[room name] night' but it's an absolute nightmare.

What I'm doing is effectively making the whole game again, but set at night. There's got to be an easier way that that!

Simplify, simplify, simplify! Scrap the night level (it was a nice idea, but only aesthetic).

Have a day pass by, helps the pacing of the story, but have the player wake up the next day, so that I don't have to worry about the descriptions.

jaynabonne
You need to put the original room description in an "else" off of your nightlevel flag if. It sounds like you're doing:

if (player.nightlevel) {
// print night level stuff
}

// original description with the two prints.

In this structure, after the nightlevel code runs, it falls through and does your normal room description. Instead you want it more like:

if (player.nightlevel) {
// print night level stuff
} else {
// original description with the two prints.
}

If it's a night level, you don't want to do the other (original) code.

OurJud
Thanks, Jay. I shall experiment with that.

Would all the other flags and elses I already have in place for other things, be treated differently with this nesting, too?

Just tried a very simple three room test, using 'first time / otherwise' scripts' and a night time description, the way you described, and it worked :)

You would not believe how long I struggled with this last night... well, you probably would, but I just couldn't figure out the damn nesting!!

Thank you :)

OurJud
As I expected, rooms that already contain flags get me very muddled when it comes to inserting the night time level.

Take this storage hut, for instance. I have two flags checking for whether or not the player had already gained entry, so how would I add a night version to this?

if (not GetBoolean(player, "inhut")) {
msg ("It looks like a storage hut.<br/><br/>East will take you back to the entrance.<br/>")
}
else if (GetBoolean(player, "inhut")) {
msg ("The door to the storage hut lies open,<br/><br/>East will take you back to the entrance.<br/>")
}


For the night version, I'm also going to have to somehow incorporate 'use torch' scripts into this too :shock:

The Pixie
I would be selective about which rooms get nighttime descriptions. Does the description for the storage hut change at night? If not, leave it as it is.

An alternative approach would be to build up a description in your script. In this example, I have a variable called s, to which more text is added, depending on the game state, before getting doosplayed.
s = "It looks like a storage hut."
if (GetBoolean(player, "inhut")) {
s = s + " The door lies open."
}
if (GetBoolean(game, "night")) {
s = s + " At this time of night it looks very dark."
}
s = s + "East will take you back to the entrance."
msg(s)

OurJud
The Pixie wrote:I would be selective about which rooms get nighttime descriptions. Does the description for the storage hut change at night? If not, leave it as it is.

More so than anywhere else, in fact, as it's on a derelict industrial park with no lighting - which is why I'm going to have to try and work some torch use into there too.

The Pixie wrote:
An alternative approach would be to build up a description in your script. In this example, I have a variable called s, to which more text is added, depending on the game state, before getting doosplayed.
s = "It looks like a storage hut."
if (GetBoolean(player, "inhut")) {
s = s + " The door lies open."
}
if (GetBoolean(game, "night")) {
s = s + " At this time of night it looks very dark."
}
s = s + "East will take you back to the entrance."
msg(s)

I'll try adding this, see what happens.

Silver
If you're struggling at this stage I really wouldn't bring torch use into it. Then it isn't just the description being either night or day. You'll have to set scripts for every single object depending on whether it's day, night or night with the torch on.

OurJud
Wonderful! Thanks, TP.

The one tiny thing is that the "At this time of night it looks very dark." doesn't trigger on the night level, but it doesn't really matter as the daytime description for outside the hut is okay, even at night. It's only when I go into the hut that the darkness needs to happen, and this is triggered as desired.

Thanks again.

OurJud
Silver wrote:If you're struggling at this stage I really wouldn't bring torch use into it. Then it isn't just the description being either night or day. You'll have to set scripts for every single object depending on whether it's day, night or night with the torch on.

I don't want to tempt fate, but I don't think my method would need to do all that. It's a small storage hut, so once the player has turned on their torch, it would illuminate all the objects.

hopefully it's a simple case of: Player can't see >> turn on torch >> player has torch? >> Yes >> Player can see.

Silver
Could be. I forget you're doing things a bit differently. The very first room in my game has light and dark states. Considering it's one room, it has been a lot of work. Although mine is a bit more complex than a torch on and off.

But for example, if the room is dark the default for examining an object is "You can't see that." So a possible issue you'll come up against is:
use torch
>you can't see that.

jaynabonne
Make the torch a weak light source when it's off and a strong one when it's on. Then you'll always be able to see it, and it will illuminate the room when switched on.

OurJud
Silver wrote:Could be. I forget you're doing things a bit differently. The very first room in my game has light and dark states. Considering it's one room, it has been a lot of work. Although mine is a bit more complex than a torch on and off.

But for example, if the room is dark the default for examining an object is "You can't see that." So a possible issue you'll come up against is:
use torch
>you can't see that.

LOL - we all have our ways, don't we? It's all very interesting, actually.

I don't use light and dark scripts or anything, I just use the narrative. As for the objects, if it's dark, I don't include them in the description until the player switches on their torch, so they're not likely to say 'get book' as I never told them it was there (as it was dark and they couldn't see it).

As for the torch, I just set a command for 'use torch; switch on torch; etc', then run a script to check if they're carrying it. If they are, I run a description of the newly lit room.

OurJud
The Pixie wrote:I would be selective about which rooms get nighttime descriptions. Does the description for the storage hut change at night? If not, leave it as it is.

An alternative approach would be to build up a description in your script. In this example, I have a variable called s, to which more text is added, depending on the game state, before getting doosplayed.


having a bit of a problem getting the game to remember if the door to the hut has been previously opened on the night section. It works fine on the day section and the sequence should be:

"It looks like a storage hut" >> Enter hut >> "it's locked" >> kick door >> "The door smashes in" >> enter >> "You are inside the hut" >> leave >> "It looks like a storage hut and the door is smashed in" >> enter hut >> "You are inside the hut"

But at night, I get:

"It looks like a storage hut" >> Enter hut >> "it's locked" >> kick door >> "The door smashes in" >> enter >> "You are inside the hut. It's pitch black" >> leave >> "It looks like a storage hut" >> enter hut >> "it's locked"

This sequence uses two rooms; hut (exterior) and hutinside (interior)

On the description for the hut (exterior) I run the following script supplied by TP:

s = "It looks like a storage hut."
if (GetBoolean(player, "inhut")) {
s = s + " The door lies open."
}
if (GetBoolean(game, "night")) {
s = s + " At this time of night it looks very dark."
}
s = s + "East will take you back to the entrance."
msg (s)

And on the command pattern for 'open door; enter hut; etc' I run the script:

if (not GetBoolean(player, "inhut")) {
msg ("You try the door, but it's locked and rattles loosely in the frame. It appears to be very flimsy.")
}
else if (GetBoolean(player, "inhut")) {
MoveObject (player, hutinside)
}

I think I need to add the night condition to the last script, but can't figure out how.

Silver
jaynabonne wrote:Make the torch a weak light source when it's off and a strong one when it's on. Then you'll always be able to see it, and it will illuminate the room when switched on.


Yep, that solves it. And make all the other things you want to be able to see when it's dark weak light sources too (admittedly there might not be any, I had quite a few...)

OurJud
Sorry to bump, but can anyone with the know-now run their eyes over this to see where I'm going wrong?

having a bit of a problem getting the game to remember if the door to the hut has been previously opened on the night section. It works fine on the day section and the sequence should be:

"It looks like a storage hut" >> Enter hut >> "it's locked" >> kick door >> "The door smashes in" >> enter >> "You are inside the hut" >> leave >> "It looks like a storage hut and the door is smashed in" >> enter hut >> "You are inside the hut"

But at night, I get:

"It looks like a storage hut" >> Enter hut >> "it's locked" >> kick door >> "The door smashes in" >> enter >> "You are inside the hut. It's pitch black" >> leave >> "It looks like a storage hut" >> enter hut >> "it's locked"

This sequence uses two rooms; hut (exterior) and hutinside (interior)

On the description for the hut (exterior) I run the following script supplied by TP:

s = "It looks like a storage hut."
if (GetBoolean(player, "inhut")) {
s = s + " The door lies open."
}
if (GetBoolean(game, "night")) {
s = s + " At this time of night it looks very dark."
}
s = s + "East will take you back to the entrance."
msg (s)

And on the command pattern for 'open door; enter hut; etc' I run the script:

if (not GetBoolean(player, "inhut")) {
msg ("You try the door, but it's locked and rattles loosely in the frame. It appears to be very flimsy.")
}
else if (GetBoolean(player, "inhut")) {
MoveObject (player, hutinside)
}

I think I need to add the night condition to the last script, but can't figure out how.


HegemonKhan
@OurJud,

key:

nocturnal: sleep during the day, awake at night
diurnal (or however it's spelled): sleep during the night, awake during the day

here's an example of working with two flags:

you can do it in either order:

Order 1:

if (game.daytime_or_nighttime = "nighttime") {
if (player.sleep_behavior = "diurnal") {
player.sleeping = true
} else if (player.sleep_behavior = "nocturnal") {
player.sleeping = false
}
} else if (game.daytime_or_nighttime = "daytime") {
if (player.sleep_behavior = "diurnal") {
player.sleeping = false
} else if (player.sleep_behavior = "nocturnal") {
player.sleeping = true
}
}


OR

Order 2:

if (player.sleep_behavior = "diurnal") {
if (game.daytime_or_nighttime = "daytime") {
player.sleeping = false
} else if (game.daytime_or_nighttime = "nighttime") {
player.sleeping = true
}
} else if (player.sleep_behavior = "nocturnal") {
if (game.daytime_or_nighttime = "daytime") {
player.sleeping = true
} else if (game.daytime_or_nighttime = "nighttime") {
player.sleeping = false
}
}


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

so the same is true for your 'dark~light' and 'inside~outside' Flags:

if (dark)
-> if (inside)
->-> script1
-> else if (outside)
->-> script2
else if (light)
-> if (inside)
->-> script3
-> else if (outside)
->-> script4

OR

if (inside)
-> if (light)
->-> script1
-> else if (dark)
->-> script2
else if (outside)
-> if (light)
->-> script3
-> else if (dark)
->-> script4

The Pixie
OurJud wrote:Sorry to bump, but can anyone with the know-now run their eyes over this to see where I'm going wrong?

The code you posted should work fine. Where are you setting player.inhut? I would look there and see if it is missed at night (or post your whole game).

That said...
if (not GetBoolean(player, "inhut")) {
msg ("You try the door, but it's locked and rattles loosely in the frame. It appears to be very flimsy.")
}
else if (GetBoolean(player, "inhut")) {
MoveObject (player, hutinside)
}

You do not need the second if statement here. Try this:
if (not GetBoolean(player, "inhut")) {
msg ("You try the door, but it's locked and rattles loosely in the frame. It appears to be very flimsy.")
}
else {
MoveObject (player, hutinside)
}

The game does the test in the first line. If it is true, it does the first block (bit in {}), if it is not true, it does the block after the else. No need to check it is not true at that point - it has to be to get there (sometimes you do want to test if something else is true, so you will see if tests there, but they should be testing something else).

OurJud
The Pixie wrote:Where are you setting player.inhut? I would look there and see if it is missed at night (or post your whole game).

Thanks, HK, I'll try and get my head around that at some point.

TP, thank you so much. That was exactly the problem. I set the inhut flag inside the hut, but as you so rightly point out, I hadn't set it for the night version. It's funny how when you look at things with a fresh mind, you see them straight away.

Although that's not to say I would have done without you pointing out it was that which may have been causing the problem.

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

Support

Forums