My question here is how do I specify the light lamp command to be light lamp with matches.
command <light lamp> {
if got <matches> then {
exec <light lamp with matches>
}
else {
if not property <lamp; lit> then {
msg <You should find something to light it with.>
}
else {
msg <The lamp is already lit.>
}
}
}
command <light lamp with matches> {
if got <matches> then {
if not property <lamp; lit> then {
msg <You light the lamp.>
property <lamp; lit>
}
else {
msg <The lamp is already lit.>
}
}
}verb <light: OnLight> msg <You cannot 'light' that.>command <light #@object#> {
if action <#object#; OnLight> then {
doaction <#object#; OnLight>
else {
msg <You cannot 'light' that.>
}
}command <light #@object1# with #@object2#> {
if action <#object1#; OnLight> then {
property <#object1#; with = #object2#>
doaction <#object1#; OnLight>
}
else {
msg <You cannot 'light' that.>
}
}define object <lamp>
take
properties <with = NULL>
action <OnLight> {
set string <this; $thisobject$>
if not property <#this#; lit> then {
if (#(this):with# = NULL) then {
if got <matches> then {
property <#this#; with = matches>
doaction <#this#; OnLight>
}
else {
msg <You should find something to light it with.>
}
}
else {
if (#(this):with# = matches) then {
msg <You light the lamp.>
property <#this#; lit>
}
else {
set string <str; #(this):with#>
msg <You cannot light the lamp with #(str):prefix# #@str#.>
}
}
}
else {
msg <The lamp is already lit.>
}
property <#this#; with = NULL>
}
end define
verb <tie: OnTie> msg <You cannot 'tie' that.>
command <tie #@object1# to #@object2#> {
if action <#object1#; OnTie> then {
property <#object1#; to = #@object2#>
doaction <#object1#; OnTie>
}
else {
msg <You cannot 'tie' that.>
}
}
define object <Post> {
properties <CanTieRopeOnMe>
end define
define object <Rope> {
properties <to = NULL>
action <OnTie> {
'check to make sure 'to' doesn't equal NULL. If it does,
'inform they player that they must tie the rope to
'something, they can't just 'tie rope'.
'if 'to' doesn't equal NULL, check if the object it refers to
'has the 'CanTieRopeOnMe' property. If so, tie the
'rope to that object, otherwise send a denial message to
'the player.
}
end define' Created with QDK Pro 4.1 Beta
!include <stdverbs.lib>
define game <>
asl-version <410>
start <test>
game info <Created with QDK Pro 4.1 Beta>
command <tie rope to post> {
if got <rope> then {
if here <post> then {
msg <You tie the rope to the post.>
lose <rope>
flag on <ropedown>
unlock <shaftentrance; down>
hide <rope> } else msg <There is no post here.> } else {
msg <You don't have any rope.> }
}
end define
define options
debug on
panes on
abbreviations on
end define
define room <shaftentrance>
look <there is a shaft down>
down locked <bottomofshaft; The shaft is too deep to jump down. You will need to find another way down.>
define object <rope>
take
displaytype <Object>
article <it>
gender <it>
use on <post>
end define
define object <post>
look if flag <ropedown> then msg <A metal post with a rope tied to it.> else msg <A metal post.>
displaytype <Object>
article <it>
gender <it>
end define
end define
define room <bottomofshaft>
look <You are at the bottom of the shaft. A rope leads up.>
up <shaftentrance>
end define
Freak wrote:http://www.inform-fiction.org/manual/html/s50.html#p402
Overcat wrote:
[snip]
Since Quest's verbs can only specify one noun (one object), you cannot implement 'verb OBJECT with OBJECT' as a verb (such as 'light lamp with matches'). So here is a command that mimics the logic of a verb:command <light #@object1# with #@object2#> {
if action <#object1#; OnLight> then {
property <#object1#; with = #object2#>
doaction <#object1#; OnLight>
}
else {
msg <You cannot 'light' that.>
}
}
This second command behaves in exactly the same way as the verb, save that it sets a property (called 'with') on the object being lit to the object that is making the lighting possible. (It sets the 'with' property of the lamp to 'matches'.) In the verb and the command no script has been written that actually lights the lamp yet: that's to be done in the OnLight action of the lamp itself, which both the verb and the command call:define object <lamp>
take
properties <with = NULL>
action <OnLight> {
set string <this; $thisobject$>
if not property <#this#; lit> then {
if (#(this):with# = NULL) then {
if got <matches> then {
property <#this#; with = matches>
doaction <#this#; OnLight>
}
else {
msg <You should find something to light it with.>
}
}
else {
if (#(this):with# = matches) then {
msg <You light the lamp.>
property <#this#; lit>
}
else {
set string <str; #(this):with#>
msg <You cannot light the lamp with #(str):prefix# #@str#.>
}
}
}
else {
msg <The lamp is already lit.>
}
property <#this#; with = NULL>
}
end define
The above action (OnLight) first checks to see if the lamp is already lit. If it's not, the script looks to see if an attempt was made to light this object (the lamp) with anything. We store any object that was used to try to light the lamp in a 'with' property on the lamp itself. By default this property is set to NULL, and as you can see at the end of the OnLight action, it is reset to NULL after any attempt to light the lamp has been made. If the 'with' property is NULL, a check is made to see if the player possesses the matches. If they do, we set the 'with' property to 'matches' and recall the OnLight action immediately. If they do not possess the matches, we tell the player they need to find something to light the lamp with.
If the 'with' property does not equal NULL, we check to see if it equals 'matches'. If it does, the lamp is lit. If it doesn't (as when the player tries to light the lamp with, say, a 'shoe'), a message is sent to the player indicating that they cannot light the lamp with whatever object they tried to light it with. (IE, "You cannot light the lamp with a shoe.")
[snip]
define type <item>
take
weight = 10
size = rather small
action <OnAttack> {
set string <this; $thisobject$>
msg <Now why would you attack #(this):prefix# #@this#?>
}
action <OnInspect> {
set string <this; $thisobject$>
msg <The #@this# weighs #(this):weight# stones and is #(this):size#.>
}
end definedefine object <apple>
look <Just an apple>
prefix <an>
type <item>
end defineverb <attack: OnAttack> msg <You can't 'attack' that.>
verb <inspect: OnInspect> msg <You can't 'inspect' that.>define object <someObject>
properties <weight = 10; size = rather small>
end define
define type <someType>
weight = 10
size = rather small
end definedefine type <lightable>
with = NULL
action <OnLight> {
set string <this; $thisobject$>
if not property <#this#; lit> then {
if (#(this):with# = NULL) then {
set string <lightingObject; $GetValidLightingObject$>
if (#lightingObject# <> NULL) then {
property <#this#; with = #lightingObject#>
msg <(with #(lightingObject):prefix# #@lightingObject#) |xn>
doaction <#this#; OnLight>
}
else {
msg <You should find something to light it with.>
}
}
else {
if type <#(this):with#; lighting> then {
set numeric <i; $objectproperty(#(this):with#; uses)$>
if (%i% > 0) then {
property <#this#; lit>
dec <i>
property <#(this):with#; uses = %i%>
doaction <$thisobject$; AfterLight>
if (%i% = 0) then doaction <#(this):with#; WhenEmpty>
}
else {
doaction <#(this):with#; UseWhenEmpty>
}
}
else {
set string <str; #(this):with#>
msg <You cannot light the lamp with #(str):prefix# #@str#.>
}
}
}
else {
msg <The #@this# is already lit.>
}
property <#this#; with = NULL>
}
action <AfterLight> {
}
end definedefine object <lamp>
take
prefix <an unlit>
look <Just a lamp.>
type <lightable>
action <AfterLight> {
msg <The lamp sputters, almost dies out, then burns brightly.>
property <$thisobject$; prefix = a lit>
}
end defineError 438 - Object doesn't support this property or method
in QDKGame.InitialiseTypes
command <light #@object1# with #@object2#> {
if action <#object1#; OnLight> then {
property <#object1#; with = #object2#>
doaction <#object1#; OnLight>
} else {
msg <You cannot 'light' that.>
}
}command <light #@object1# with #@object2#> {
if got <#@object1#> then {
if action <#object1#; OnLight> then {
property <#object1#; with = #object2#>
doaction <#object1#; OnLight>
} else {
msg <You cannot 'light' that.>
}
} else {
msg <You don't have that.>
}
}define room <BottomOfShaft>
alias <bottom of the shaft>
prefix <the>
look <The mine seems to have been abandoned for some time.>
description {
msg <You are at the bottom of the shaft.|n>
if got <Lamp> and flag <LampOn> or here <Lamp> and flag <LampOn> then
msg <#quest.lookdesc#> else
msg <It is very dark!>
}
end definedefine room <BottomOfShaft>
alias <bottom of the shaft>
prefix <the>
look <The mine seems to have been abandoned for some time.>
description {
msg <You are at the bottom of the shaft.|n>
if got <Lamp> or here <Lamp> and flag <LampOn> then
msg <#quest.lookdesc#> else
msg <It is very dark!>
}
end define
Carrot wrote:
...
I am also trying to set a flag LampOn so that I can control rooms that need illumination. But again here I am struggling.
I have it working in a simpler test file where I have added the verb Light and therefore all I need to do is Light Lamp (this was for testing only, as I wanted to use the Light X with Y formula.
The only problem I have with that is that while I have the conditional script set to check for the object in your inventory or in the room, unless you are holding the lit lamp, the room goes dark again
I have trieddefine room <BottomOfShaft>
alias <bottom of the shaft>
prefix <the>
look <The mine seems to have been abandoned for some time.>
description {
msg <You are at the bottom of the shaft.|n>
if got <Lamp> and flag <LampOn> or here <Lamp> and flag <LampOn> then
msg <#quest.lookdesc#>
else msg <It is very dark!>
}
end define
anddefine room <BottomOfShaft>
alias <bottom of the shaft>
prefix <the>
look <The mine seems to have been abandoned for some time.>
description {
msg <You are at the bottom of the shaft.|n>
if got <Lamp> or here <Lamp> and flag <LampOn> then
msg <#quest.lookdesc#> else
msg <It is very dark!>
}
end define
description {
msg <You are at the bottom of the shaft.|n>
if got <Lamp> and flag <LampOn> then
msg <#quest.lookdesc#> else
if here <Lamp> and flag <LampOn> then
msg <#quest.lookdesc#> else
msg <It is very dark!.>
}
end define
And added a further conditional statement. It now looks like this:
command <light #@object1# with #@object2#> {
if got <#@object1#> then {
if action <#object1#; OnLight> then {
property <#object1#; with = #object2#>
doaction <#object1#; OnLight>
} else {
msg <You cannot 'light' that.>
}
} else {
msg <You don't have that.>
}
}
But doesn't seem to have made any difference.
Carrot wrote:BTW - I downloaded Lighting&Lightables. It opens fine in QDK 4.0.5, but when I open it in 4.1 beta I get the following message...Error 438 - Object doesn't support this property or method
in QDKGame.InitialiseTypes
Would just like to report I am getting this error witht hte new version of L&L as well in 4.1, but still works fine in 4.0.5
You should find something to light it with
(with a set of matches) You must possess the lamp to light it.
Overcat wrote:Would just like to report I am getting this error witht hte new version of L&L as well in 4.1, but still works fine in 4.0.5
Which is odd, because I wrote that with 4.1 beta. Perhaps one of us is not using the latest version. Will reinstall to see if that's the case on my end.
---edit---
Nope - works for me after reinstalling latest 4.1 beta. Are you sure you've downloaded and installed the newest version?
which seems a bit strange that you can try to light a lamp if you don't have the lamp or the matches, but as soon as you have the matches you can't try to light the lamp.
I know all I have to do is give the error msg from command <light #@object1# with #@object2#> to overide that in define type <lightable>
4:04:31 PM INIT: Quest Pro 4.1 (build 4.1.60)
4:04:31 PM INIT: Opening file C:\Users\Jonathan\Documents\Desktop\LLmodified.asl on 09/06/2009
4:04:31 PM ERROR: No script given for 'afterlight' action data
4:04:31 PM ERROR: No script given for 'afterlight' action data
4:04:31 PM ERROR: No script given for 'afterlight' action data
4:04:31 PM ERROR: No script given for 'afterlight' action data
4:04:31 PM ERROR: No script given for 'whenempty' action data
4:04:31 PM ERROR: No script given for 'whenempty' action data
4:04:31 PM INIT: Finished loading file.
4:04:32 PM ERROR: No string variable 'quest.doorways.out' defined.
4:04:32 PM ERROR: No string variable 'quest.doorways.dirs' defined.
4:04:32 PM ERROR: No string variable 'quest.doorways.places' defined.