Using Self

Anonymous
In the Infocom games I remember you could do things to self:
(I'm not trying to be perverted, really).
look self to get inventory or to see what miserable shape you are in.
hit self to see why so abusive.
kill self to end game.
feed banana to self to eat banana.

How do I implement the self object?
I'm very new to programming and only about 2 hours new to Quest.

Is there a library that exists that has these types of commands?
Also is there a violent library for things like kill, hit, strangle, and so forth?

Thanks

GameBoy
well, make a custom command like.... kill self, and just make it end the game. this is so simple, but im to lazy and tired to post code right now. ITID will probably post some for you, nice and easy stuff this.

Also is there a violent library for things like kill, hit, strangle, and so forth?



CW is making a battle system

Anonymous
There are probably a dozen different ways to do this in Quest but what I like to do is create an object called “self” and stick it in the inventory. Make it invisible and not droppable. This way you can use all the regular Quest functions like any other object. This is just an example of what I mean.


' "Self test"
' Created with QDK Pro 3.52

define game <Self test>
asl-version <350>
gametype singleplayer
start <startroom>
game info <Created with QDK Pro 3.52>
command <hit #@object#> if ( #object# = self ) then {
msg <You beat your self up.>
set numeric <injured; 1>
}
command <kill #@object#> {
msg <o.k. you kill yourself.|n|nyour dead.>
playerlose
}
command <feed banana to #@object#> if ( #object# = self ) then {
msg <You eat the banana.>
hide <banana>
}
define variable <injured>
type numeric
value <0>
display <injured: !>
end define
end define

define synonyms
eat banana; consume banana = use banana
end define

define room <inventory>

define object <self>
alt <me; myself>
look {
if ( %injured% = 0 ) then msg <You are in good shape.>
if ( %injured% = 1 ) then msg <You are in pretty bad shape, you need medical attention as soon as possible.>
}
speak <Do you talk to yourself a lot?>
invisible
drop nowhere <>
end define

end define

define room <startroom>
south {
msg <You step through the door and fall down a hole in the floor. Land hard in a pile of wood. You are seriously injured. You find yourself in a dark basement. The only thing you can see is a staircase leading up in the southeast corner.>
set numeric <injured; 1>
goto <basement>
}
end define

define room <basement>
prefix <the>
look <You are in a dark basement. Some light comes in through the hole above you that you just fell through. All you can make out is a staircase leading up.>
up {
msg <The staircase is very old and rickety but you decide to risk it. It shakes and seems very unsteady as you climb. It starts to collapse as you are about two thirds of the way up. You leap to the top and just make it as the stairs crumble beneath you.>
goto <kitchen>
}
end define

define room <kitchen>

define object <first aid kit>
look <A standard looking first aid kit.>
take
use {
if ( %injured% = 0 ) then msg <You have no use for the first aid kit right now.>
if ( %injured% = 1 ) then {
msg <You open up the kit and take care of your injuries. You feel much better.>
set numeric <injured; 0>
}
}
end define

define object <banana>
look <a big ripe yellow banana.>
take
use {
msg <You eat the banana.>
hide <banana>
}
use on <self> {
msg <You feed yourself the banana.>
hide <banana>
}
end define

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define



Obviously not a masterpiece but I think it covers everything you asked about. Inventory is constantly displayed in Quest so I can’t think of a reason to display it when you look at self, but you could do that to if you really wanted.

Anonymous
Thanks Mman.

That did pretty much everything I wanted.
Following your code I added:
command <examine #@object#> if ( #object# = self ) then exec <inventory>
else exec <examine #object#; normal>

The problem I have now is that "examine" and "x" are two different things. I'm sure I could just copy this code and substitute "x" for "examine", but my question is whether or not the code is behaving properly. I thought "x" and "examine" were always the same thing?

I just have two more questions:
In the variable declaration that Mman put for injured it has the phrase "display <Injured: !>". :
define variable <injured>
type numeric
value <0>
display <Injured: !>
end define
I understand what this does, but is there a way to change this to something less cryptic? I would like something like:
display{
if (injured = 0 ) then display <You are not injured.>
if (injured = 1) then display <You are injured.>
}

I tried this and it didn't seem to work. Which leads me to my final question:

In the definition of self Mman wrote:
look {
if ( %injured% = 0 ) then msg <You are in good shape.>
if ( %injured% = 1 ) then msg <You are in pretty bad shape, you need medical attention as soon as possible.>
}
This did not seem to work for me either. I cannot seem to make "look" work when there is a choice. It only seems to work with the more limited "look msg <You look fine.>" or something like that.

How do I get these choices to work? First in the "display" and second in the object definitions?

Thanks again.

surgeville
Hi, I'm the one that started and now has the most posts in this topic.

Since I'm a newbie I wanted to point out my own mistakes.
The "look" block worked fine when i tried it again. I must have done something wrong, but the other two problems remain. Let me try to make them easier to understand.

Here is my code for examine self:
command <examine #@object#; x #@object#> if ( #object# = self ) then exec <inventory>
else exec <examine #object#; normal>

I put 'x' and 'examine' together, but this definately limits the ability of 'x' and 'examine'. I don't know if this is a bug or what. I'm too new to tell, but let me state my problem with this.

I have a containable object sofa with cushions on it (or in it). Without this code for examine self, the "examine sofa" code tells me that the sofa contains cushions. With this code the sofa does not include this line.
Here is my code for the sofa and cushions:

define object <cushion1>
alias <slightly worn cushions>
alt <cushions; worn cushions>
look <They are slightly worn.>
take
speak <Have you made an appointment with the psychiatrist? You are

definitely due.>
examine <What do you want to know? They're blue cushions that go on a

couch! Not really that exciting now is it!>
prefix <three>
detail <slightly worn>
article <them>
type <TLTobject>
type <TLTcontainable>
properties <noWear=Oh it looks lovely on you!; size=4; weight=4; isIn=Sofa;

tooBig=The slightly worn cushion is too big to be put in there.; tooHeavy=The slightly worn cushion

is too heavy for that.>
end define

define object <Sofa>
alt <couch; resting place; chaise lounge; davenport>
look <It looks like a couch.>
speak <Amazingly the sofa answers...no wait, it can't. It's an inanimate object

and you are going quite mad.>
examine msg <This long piece of furniture is designed to seat three or more

adults. It is also suitable for one to lie on at full length. This particular davenport does not turn into

a bed so if one needs to lie down it must be accomplish while the chaise lounge is a chaise lounge

which is how it will be and how it will remain.|n|nIt's blue.>
prefix <the>
article <it>
type <TLTcontainer>
properties <not takeable; noTake=The sofa is far to heavy for you to move.;

noWear=Are you feeling okay? (That is a rhetorical question.); sizeLimit=50; weightLimit=50>
end define

I hope this explains it.
The other problem has not changed. If I put:
define variable <injured>
type numeric
value <0>
display {
if (%injured% = 0) then display <You are not injured.>
if (%injured% = 1) then display <You are injured.>
}

My output in the display box is either "0intproc2" or "1intproc2" depending on if %injured% = 0 or 1. How do I get the text that I want in that box.

Thanks again,
Surge

Alex
You can't use script in a "display" tag. But you can use a function:


define variable <injured>
type numeric
value <0>
display <$injured$>
end define

define function <injured>
if (%injured% = 0) then return <You are not injured.>
if (%injured% = 1) then return <You are injured.>
end define

surgeville
:D

Anonymous
I just have two brief comments. Fists about the display thing for injured. I absolutely agree that it is cryptic but this was just a quick example I whipped off in twenty minutes. If it were actual a game ready to be posted what I would do is remove the display part altogether. I find things like that useful when creating a game so that I know what is going on when I test it out, but it is not necessary. But if you want a display for this you could just start out with a string variable instead of a numeric on (I like numeric variables for some reason but that is my problem, not yours) or you could do as Alex suggests and use a function. I also thought that what every you ended up with might be a lot more involved than just injured or not injured, especially if you use some kind of combat system like Ste suggests. As I said this was just an example.

Secondly about the examine thing. Examine is a built in Quest function. You seem to be trying to override it. You can certainly do that but I don’t see why. You could just do something like:


examine {
if ( %injured% = 0 ) then msg <You are in good shape.>
if ( %injured% = 1 ) then msg <You are in pretty bad shape, you need medical attention as soon as possible.>
exec <inventory>
}


This would eliminate your “examine” or “x” problem. But if you still wanted to override the examine function you could just set up “x” as a synonym of “examine”

surgeville
I was actually able to do what I wanted with examine by putting it all in the define object <self> location.
I just wanted to show inventory when "examine self" was called. I was able to do this with adding "examine exec <inventory>".
Like I said, I'm new and am still working out this language.

Thanks for your help though. It really did help quite a bit.

Also, Alex, I put this in my program and the display box only shows "[Error]":
	define variable <injured>
type numeric
value <0>
display <$InjuredDisplay$>
end define

define function <InjuredDisplay>
if (%injured% = 0) then return <You are not injured.>
if (%injured% = 1) then return <You are injured.>
end define


Any hint as to what I did wrong. What step am I missing?

Thanks SO MUCH everyone. This seems like a great community!

Alex
That code works for me... You'll see [ERROR] displayed if the function doesn't exist. Full details will be in the ASL log file of precisely what function was missing, but presumably it's $InjuredDisplay$ - so check you haven't made any typing mistakes. If you're still have problems then please email me the ASL file.

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

Support

Forums