Eat command

shandlia
14 Sept 2006, 19:46
I'm having a problem with an eat command. If someone could tell me whats wrong with my code it would be greatly appreciated.

command <eat #@object#> {
if got <#@object#> and property <#@object#; edible> then {
doaction <#@object#; eat>
lose <#@object#>
}
else {if got <#@object#> and property <#@object#; nonedible> then msg <You can't eat that.>}


Object 1 properties:

define object <scimitar>
alias <scimitar>
alt <sci; scim; scimi; scimit; scimita>
look <A wickedly curved scimitar with a jade handle.>
take
prefix <a>
properties <nonedible>
end define


Object 2 properties:

define object <cupcake>
alias <a chocolate cupcake>
alt <booger; boog; boo>
look msg <A chocolate cupcake with sprinkles on top.>
take
prefix <a>
properties <edible>
action <eat> msg <You eat the chocolate cupcake.>
end define


When I try to test it this is what happens:
> eat scim
You can't eat that.

> eat cup

It doesn't eat the cupcake or anything, just hangs there with no response.

paul_one
14 Sept 2006, 22:17
The cupcake doesn't have "cup" in it's alt tag.

So the object "cup" is not there at all.
Put cup after boo, or type "eat boo" instead.

shandlia
15 Sept 2006, 00:11
somehow two items alt's got mixed thanks.

shandlia
15 Sept 2006, 00:15
Nope that wasnt it. The mix up with the alts was with my cut and paste not in the game. Cupcake does have alt of cup

> get cup
You pick it up.

> eat cup

Can pick it up using that so the problem is something else.

define object <cupcake>
alias <a chocolate cupcake>
alt <cup; cupcake>
look <A chocolate cupcake with sprinkles on top.>
take
gender <it>
properties <edible>
action <eat> msg <You eat the chocolate cupcake.>
end define

paul_one
15 Sept 2006, 00:37
Right, two things wrong with your code:

No need for a bajillion @'s.. You don't know what it does.

command <hold #@object#>
This takes what the player types after hold and tries to turn it into an object.. If it can't then it will return a "I cannot find that object" message to the player, and not execute your command.

If it DOES find an object (so what you type is either in the alt - or alias - tag's) then it changes what you type into the object's REAL name (when you do a define object <>) and put's it into a variable called "object".

When you now use "#object#" then you are using the object's REAL name.. When you use "#@object#" you are using it's alias.... Or, if you type:

command <shmack #object#>

Then #object# is using the alias, and #@object# is using the real name.
This command is really if your command could refer to things that aren't objects - or if you make your own in-game parser.

You understand?

Then second thing is you're missing a closing bracket ( } ) from the command <> part above.
This is where tabbing is important to help you out.

Shadowalker
26 Oct 2006, 07:00
If you still need help with this, I made a little demo where you can eat an apple or a pear, but not a boot. I purposely didn't name the apple 'apple,' so that you can see how the #@object# command would work.

' "Eating Test"
' Created with QDK 3.53

define game <Eating Test>
asl-version <350>
gametype singleplayer
start <Normal Room>
game author <>
game version <1.0>
game copyright <© 2006>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
command <eat #@object#> if got <#object#> then {
if type <#object#; edible> then {
msg <You eat the #@object#.>
hide <#object#>
}
else msg <The #@object# is not edible.>
}
else msg <You don't have the #@object#.>
end define

define type <edible>
end define

define synonyms
end define

define room <Normal Room>
prefix <a>

define object <Apple1red>
alias <red apple>
alt <apple>
take
prefix <a>
article <it>
gender <it>
type <edible>
end define

define object <Pear1big>
alias <big pear>
alt <pear>
take
prefix <a>
article <it>
gender <it>
type <edible>
end define

define object <boot>
take
prefix <a>
article <it>
gender <it>
end define

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define