Newb - Lighting

jpatton
Hi, I teach a scripting class and we are working on an adventure game using VBScript. It's very simple as there is not a lot of capability inherent to the scripting language. So I decided I would write what they are doing in one of the IF languages, and poking around I stumbled upon Quest.

Firstly let me say, very well put together program had on critical error that caused the QDK to exit abruptly, I had an object named Chandelier and when I either tried to rename it the wrong way it said there was already an object with that name, threw an error, and exited. That sucked because I lost my work, but now I save after more or less each room creation or object creation, most likely wise decision regardless.

Secondly, I love how easy it is to quickly put a game together. I wasn't sure initially how to build a map for my students, then I found this online maze creator which worked out well. Using Quest I was able to quickly input 34 rooms all connected for an initial walk-through in like 10min!

Ok, enough praise, my question is this, I want to have a series of rooms to be initially dark, and they must posses the flashlight to move anywhere. You should see a semblance of Zork here, if they don't have the flashlight they die on their next move unless it's to leave the room. I have read a few of the posts, and I think I would do this as a flag, but I'm not 100% sure. Is this possible using just the QDK? I have no knowledge of the underlying language at all.

I think I can figure out how to verify if the flag is dark, using one of those conditional scripting commands, I'm just missing where I would set the initial flag in the room. Ok, well, I thought I could verify, here is what I just tried.

Sorry if I ramble.

I have a room called lobby west, on the property sheet, on the misc tab, under the properties and actions button I defined a property HasLight and set it equal to No.

Same room, under the script tab, in the enter room section it reads: If "HasLight" is equal to "No" Then Print "You have entered a dark room."

What I understand currently by looking at my properties I should get 'You have entered a dark room.' upon entering lobby west. But I don't see that, so I have something set wrong. If someone could help I would really appreciate it. Perhaps that same person could show me or guide me on how to let a flashlight turn on and off once you have taken it. I'll worry about having the flaslight's batteries run out for another time.

Thanks again for your help!

Jeff

Anonymous
Hi Jeff and welcome to Quest :)

As you have no doubt discovered, Quest doesn't have the facility for 'dark places' built in, we are left to our own devices to implement this in whatever way we see fit.

The real problem here lies with the Quest GUI showing a list of objects etc in the current location. Although it is relatively easy to suppress the textual description of the 'darkened' room in the text window, it is a bit more tricky to hide away the objects that are shown in the objects pane.

Depending on how many rooms you need to have dark, it might be easier to just make duplicate rooms (an empty dark version + the real room) and swop your player between them according to posession of a light source. If there are lots and lots of potentially dark rooms it might be better to write something a bit more sophisticated to deal with it.

You might have noticed too that Quest supports 'libraries' to extend the basic functionality and it would be entirely possible to write an include library that would add the capacity to make rooms dark / lit with a single click inside the QDK, a very useful facility.

Al (MaDbRiT)

Anonymous
Hi (again) Jeff,

Following on from my last post, here's a little demo with three rooms (two initially dark) and a lamp.

You can cut, paste & save the code below as (say) 'dark.asl' and it should run in Quest and be able to be loaded into QDK to see how I made it work.



' "Dark Room Demo"
' Created with QDK Pro 3.53

define game <Dark Room Test>
asl-version <350>
gametype singleplayer
start <hall>
game author <Al (MaDbRiT)>
game version <.09a>
game info <Created with QDK Pro 3.53>
command <turn on lamp; turn lamp on> {
msg <The lamp is almost dazzling in its brightness.>
move <lamp_on;inventory>
show <lamp_on>
hide <lamp_off>
if (#(quest.currentroom):darkRoomFor#<>!) then {
goto <#quest.currentroom):darkRoomFor#>
}
}
end define

define synonyms
end define

define room <hall>
prefix <the>
look <A shabby hallway.>
south {
if got <lamp_on> then {
goto <kitchen>
}
else goto <dark_kitchen>
}

west {
if got <lamp_on> then {
goto <cloakroom>
}
else goto <dark_cloakroom>
}

define object <lamp_on>
alias <lamp>
prefix <a>
look <a powerful battery powered lamp, it throws a strong light.>
take
hidden
end define

define object <lamp_off>
alias <lamp>
prefix <a>
look <a powerful battery powered lamp, it looks like it would give _
a strong light if you turned it on.>
take
end define

end define

define room <kitchen>
prefix <the>
look <A filfthy kitchen, it ought to carry a health warning.>
north <hall>
end define

define room <dark_kitchen>
alias <darkness>
indescription <You are in complete darkness.>
look <It's pitch black in here, you can't see a thing.>
north <hall>
properties <darkRoomFor=kitchen>
end define

define room <cloakroom>
prefix <the>
look <Indescribable, it would look better in the dark.>
east <hall>
end define

define room <dark_cloakroom>
alias <darkness>
indescription <You are in complete darkness.>
look <It's pitch black in here, you can't see a thing.>
east <hall>
properties <darkRoomFor=cloakroom>
end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define


Hope this helps, if there is anything in the above that you don't follow please ask.

Al (MaDbRiT)

007bond
Not that Jeff would know about this list, but I think that this should be another thing put on the list to put into the next version of ASL. It's kind of like my room type thing, where you have like hallway, park, front or back yard, and so on, except this is lighting in a room. An idea I must admit I've never thought of before as a useful thing in Quest.

EagleWing
007bond wrote:Not that Jeff would know about this list, but I think that this should be another thing put on the list to put into the next version of ASL. It's kind of like my room type thing, where you have like hallway, park, front or back yard, and so on, except this is lighting in a room. An idea I must admit I've never thought of before as a useful thing in Quest.


:roll: Why does it have to be added to the program? A well written library would do the job equally well - and Al has demonstrated how easy it would be to add one.

If you've never before thought of dark-rooms as being useful in Quest then you haven't thought very much about actually writing IF. Cellars, dungeons and night scenes are fairly common in IF. The first and last are also pretty common in real life, I believe!

Frank

paul_one
I have nothing to say/add to the conversation... So I will say something anyway!

007 again shows ignorance. Al once again shows intelligence, and EagleWing again gives a great point.

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

Support

Forums