Property problem and Inventory Question

dennis
17 Feb 2005, 01:40
Hello
I have two questions:

Im making a torch that uses a property: Bulb=false/true
The torch is a container that can have bulbs in it - putting a bulb in the lamp sets the property to true.

This works well. But then I have another propery: Lit=False/true
My plan is to use custom player command "Light torch"

With the criteria: If player has battery and torch propery Bulb=true
then set lit=true.

This doesnt work - and I cant figure out why.
If I simply use the command: if "light" then lit=true that works. And I can get both my torch properies to true.

But not with the added criteria of needing to have a battery in ones inventory and the bulb=true. It simply jumps to the 'else' in stead.

My second question is shorter and rather embarrasing.
How do I get a put in item out of its container?

Grateful for any answers or the meagrest of hints.

Regards
Dennis

Christopher
17 Feb 2005, 01:55
If you posted the relevent code I could help.

dennis
17 Feb 2005, 10:18
That would be great! Here it is.
Is that why I cant seem to get my candle out of the lamp???

' "lamptest"
' Created with QDK 3.53 - UNREGISTERED VERSION

!include <Typelib.qlb>

define game <lamptest>
asl-version <350>
gametype singleplayer
start <Itemarium>
game author <Dennis Gustafsson>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
background <blue>
foreground <white>
command <light lamp> if got <Lighter> and got <lamp> and property <lamp; candle=true> then {
property <lamp; lit=true>
msg <Light!>
}
else msg <No luck..>
command <light lamp> if got <Lighter> and got <lamp> and property <lamp; bluecandle=true> then {
property <lamp; bluelit=true>
msg <Blue Light!>
}
else msg <It is still dark.>
end define

define synonyms
end define

define room <Itemarium>
description <You are in the itenarium.>

define object <Candle>
take
type <TLTcontainable>
properties <size=2; weight=2>
action <lit=true> msg <Light!!>
action <contained> property <lamp; candle=true>
end define

define object <Blue candle>
take
type <TLTcontainable>
properties <size=2; weight=2>
action <contained> property <lamp; bluecandle=true>
end define

define object <lamp>
take
type <TLTobject>
type <TLTcontainer>
type <TLTcontainer>
properties <candle=false; bluecandle=false; lit=false; bluelit=false; listHeader=In the lantern is fitted with; sizeLimit=2; weightLimit=2; listHeader=In the lantern is fitted with; sizeLimit=2; weightLimit=2>
end define

define object <Lighter>
take
end define

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define

MaDbRiT
17 Feb 2005, 11:22
Dennis

The code you've posted doesn't allow the player to even take the candles, let alone put them in the lamp or take them out again :shock:

If you want the player to be able to take the candles at any point you need to make them typelib regular objects - if you want the candle(s) to start the game in the lamp, you need to "tick the box" accordingly in QDK.

Here's what the code looks like after making the candles regular objects...


' "lamptest"
' Created with QDK 3.52 - UNREGISTERED VERSION

!include <Typelib.qlb>

define game <lamptest>
asl-version <350>
gametype singleplayer
start <Itemarium>
game author <Dennis Gustafsson>
game info <Created with QDK 3.52 - UNREGISTERED EVALUATION VERSION.>
background <blue>
foreground <white>
command <light lamp> if got <Lighter> and got <lamp> and property <lamp; candle=true> then {
property <lamp; lit=true>
msg <Light!>
}
else msg <No luck..>
command <light lamp> if got <Lighter> and got <lamp> and property <lamp; bluecandle=true> then {
property <lamp; bluelit=true>
msg <Blue Light!>
}
else msg <It is still dark.>
end define

define synonyms
end define

define room <Itemarium>
description <You are in the itenarium.>

define object <Candle>
take
type <TLTobject>
type <TLTcontainable>
properties <size=2; weight=2>
action <lit=true> msg <Light!!>
action <contained> property <lamp; candle=true>
end define

define object <Blue candle>
take
type <TLTobject>
type <TLTcontainable>
properties <size=2; weight=2>
action <contained> property <lamp; bluecandle=true>
end define

define object <lamp>
take
type <TLTobject>
type <TLTcontainer>
type <TLTcontainer>
properties <candle=false; bluecandle=false; lit=false; bluelit=false; listHeader=In the lantern is fitted with; sizeLimit=2; weightLimit=2; listHeader=In the lantern is fitted with; sizeLimit=2; weightLimit=2>
end define

define object <Lighter>
take
end define

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define



and here is game output showing it works...


(Start of new game)


You are in the itenarium.

> take lamp
Taken.

> take candle
Taken.

> put candle into lamp

> x lamp
Nothing out of the ordinary.
In the lantern is fitted with a Candle.

> take candle from lamp
Taken.



You might want to change your lamp's 'header for listing', it jars terribly. :oops:

Hope this helps

Al (MaDbRiT)

Anonymous
17 Feb 2005, 16:06
I could get the candle and put it into the lamp with my original code..

Anyway now I can take candles and put them in the lamp.
And take them from lamp as well. Sweet. Thanks a bunch!

But now I've made them regular object:
So what does "regular object" mean exactly. It's not self explanatory..


Any chance of a theory on why the lamp won't change it's lit=false to lit=true
when I type light lamp? (with the candle fitted and lighter in inventory)


Hrmm.. Yes the prose might not be pretty in the example.
I'm using small testfiles to solve my problems with my scripts - keeping my lab away from the "game" file as yet.

This is only my second day :)

MaDbRiT
17 Feb 2005, 16:59
Dennis wrote:

I could get the candle and put it into the lamp with my original code..



Hmmm - I think this may be because you have an old version of typelib in which "get" isn't trapped but "take" is due to a coding oversight by yours truly :oops: With the 'fixed' typelib your code should not work as it was...


Anyway now I can take candles and put them in the lamp.
And take them from lamp as well. Sweet. Thanks a bunch!

But now I've made them regular object:
So what does "regular object" mean exactly. It's not self explanatory..



A "regular" object is a 'takeable object' that can be taken by the player and carried around - as distinct from a scenery object that cannot. To be honest this just sets a few 'default' parameters to let typelib manage the object properly and is a hangover from earlier code. It works and it is quite convenient as a shorthand way to set up a takeable object' so I left it in...


Any chance of a theory on why the lamp won't change it's lit=false to lit=true
when I type light lamp? (with the candle fitted and lighter in inventory)



I confess I haven't even looked at that glitch, confining myself to the typelib queries that as the author I am best placed to answer, but my immediate guess is a syntax error. I am at work presently but I will take a look later this evening and post something that works for you.

Al (MaDbRiT)

dennis
17 Feb 2005, 19:37
Thank you for a very thurough explanation.

Before youy dig too deeply into this, sacroificing too much of your spare time.

I'am testing the free downloadable version of QDK. I soon found that some of the sample games on the site had more options for the objects, so I found some libraries in one of the game's directories and copied that.

Maybe there is a version conflict between the QDK and the game's (ESPER:Drom Bennach) Library file. (This might be info the administrator does not want known - aplogize in that case - please delete the post in that case.)

I must confess I'm pretty usless at coding - I'm more of an art/design type - so I'll wholly dependent on QDK.

Anyhow - Maybe I should just purchase the full program. I've been careful because I've been let down by adventure creation tools in the past.

I have a good feeling about Quest though..

Kind Regards
Dennis

Anonymous
17 Feb 2005, 22:26
Hi Dennis

Here's the lamp and candle sample - tweaked around to work...

' "lamptest" 
' Created with QDK 3.52 - UNREGISTERED VERSION

!include <Typelib.qlb>

define game <lamptest>
asl-version <350>
gametype singleplayer
start <Itemarium>
game author <Dennis Gustafsson>
game info <Created with QDK 3.52 - UNREGISTERED EVALUATION VERSION.>
background <blue>
foreground <white>

command <light lamp> {
if got <lighter> and got <lamp> then {
if property <lamp; hasBluecandle> then {
property <lamp;bluelit>
msg <Blue light!>
}
else {
if property <lamp; hasCandle> then {
property <lamp;lit>
msg <White light!>
}
else msg <There's no candle in the lamp to light.>
}
}
else msg <You can't do that.>
}

end define

define synonyms
end define

define room <Itemarium>
description <You are in the itenarium.>

define object <Candle>
type <TLTobject>
type <TLTcontainable>
properties <size=2; weight=2>
action <lit=true> msg <Light!!>
action <contained> property <lamp; hasCandle>
end define

define object <Blue candle>
type <TLTobject>
type <TLTcontainable>
properties <size=2; weight=2>
action <contained> property <lamp; hasBluecandle>
end define

define object <lamp>
type <TLTobject>
type <TLTcontainer>
properties <listHeader=The lantern is fitted with; sizeLimit=2; weightLimit=2>
end define

define object <Lighter>
type <TLTobject>
end define

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define


You should be able to load the code above into QDK to see how I set it up, but here are a few guidelines to what I changed.

Because the properties used to tell whether the candles are in the lamp and whether they are lit or not are boolean (i.e they are either true or false) you don't need to declare then in the objects - by not being there they are automatically evaluated to 'false' in any test.

I've changed the name of the variables slightly to reflect this e.g. I use a test to see if the lamp has the property 'hasbluecandle' - if it doesn't the test = false, if it does the test = true, you don't need to specify the '=true' or = "false" as part of the property test (in fact to do so makes the property a string variable not a boolean at all)

The light lamp command needed a bit more re-working, the second iteration of the 'command <light lamp>' you coded originally could never be called as written because the prior one matches exactly the same player input and being first in line would always take precedence.

Instead I've used a little nested test condition here so that the one command actually serves for both blue or white candles - it also provides useful places to slip in 'can't do' messages with meaningful reasons, I added one as an example. ("There's no candle in the lamp")

Hopefully this will all make sense once you get the code into QDK and see how it works...

Welcome to Quest by the way - I think you will find it is quite unique with its combination of ease of use (through QDK) and programming 'muscle', through hand coded ASL. I don't think there is anything else that allows you to mix and match an easy use GUI and hand written code into the same project in such a cool way.

Al (MaDbRiT)

p.s. If you want a copy of the most current typelib, e-mail me and I'll send it to you.

dennis
19 Feb 2005, 14:14
Hi Al. Just to let you know I've dropped you two mails.. In case you didn't get them for some reason..

Anonymous
19 Feb 2005, 15:34
Dennis

Not received any mail from you... are you using my e-mail address as per my profile?

Al (MaDbRiT)

dennis
19 Feb 2005, 16:17
Yes Sir I have.

And they have not bounced back to me..

dennis
19 Feb 2005, 18:39
Hello

I have a problem with 'our' lamp.

I need to figure out a way to reset the propery "hasredcandle" once the candle is removed from the lamp.

As the code now stands the lamp will have two candles in it even if both of them are removed.

I have yet to figure out how to remove a set property. Is it possible?Or do I need to resort to experimenting with variables again?. (Shudder)

dennis
19 Feb 2005, 18:44
Any chance of a "clear property" and/or "clear #flag#" at all? :)

I think Im Dead
19 Feb 2005, 19:18
instead of taking or removing a property, you go...

if ( $objectproperty(lamp; hasredcandle)$ = 1 ) then {
msg <You remove the red candle.|n>
property <lamp; hasredcandle=0>
}

and vice versa

paul_one
20 Feb 2005, 02:39
Close ITID...

They are using Boolean properties... So instead you just use:
"property <lamp; NOT hasredcandle>"

It basically removes the property from the list, so true = there, false = not there.

Anonymous
20 Feb 2005, 08:50
Dennis wrote

Yes Sir I have.

And they have not bounced back to me..



How odd - I've certainly not got them! Maybe AOL is being over-jealous on its spam filtering again! Were you posting from a HOTMAIL account or something equally spam infested?

probably best to just tell me what was in the e-mail here or in a PM!

Al (MaDbRiT)

Anonymous
20 Feb 2005, 08:54
Dennis

And just for completeness - CW (Computer Whizz) is exactly right with his how to kill of the "true" state of the hasbluecandle boolean - as I'm sure you will have discovered if you have tried :-)

you may well want to make sure you can only have 1 candle in the lamp at a time of course!

Al (MaDbRiT)

Anonymous
20 Feb 2005, 14:15
Phew.. what a nightmare.
Now my lantern works... Thanks to everyone!

I've learned about condition parameters, variables and object variables (and the difference between the two) functions and the importance of pre-planning what you are doing. I've had to re-write a bazillon times - and my brain hurts. (I'vbe probably forgotten about how it works tomorrow)

Thank you, thank you everyone!

Only one obstacle remains - I'd like to use the word 'Remove' - In "remove candle from lantern." But there is a pre-programmed usage of this word with clothing. I though Game Properties commands overruled the built in ones.. But I was wrong.

Final Question:
What is the to use be able to use: "Get candle from lantern", "Take candle from Lantern" and "Remove candle from lantern" without making the get,take and remove commands unusable for common game functions?