msg ("You are in a kitchen. There is a table here, on top of which sits a fresh sandwich.")
if (not ListContains(ScopeVisible(), sandwich)) {
msg ("You are in a kitchen. There is a table here.")
}You are in a kitchen. There is a table here, on top of which sits a fresh sandwich.
> eat sandwich
Yum yum!
> l
You are in a kitchen. There is a table here, on top of which sits a fresh sandwich.
Error running script: Unknown object or variable 'sandwich'
if (ListContains (GetAllChildObjects(), "sandwich") {
if (not ListContains (ScopeVisible(), "sandwich") {
msg ("You don't immediately see, out in the open, any sandwich in the kitchen... but maybe there's a sandwich in the refridgerator...")
} else {
// your eating sandwich scripts
}
} else {
msg ("There is no sandwich... (maybe you already ate it...)")
}HegemonKhan wrote:
personally, I'd just create your own 'whatever eat' Verb, and not use the 'edible' and 'eat' Verb default built-in coding... but that's just me as I still have trouble with understanding the 'health' and 'edible' default built-in stuff, lol.
if (not ListContains (ScopeVisible(), "sandwich") {
msg ("You don't immediately see, out in the open, any sandwich in the kitchen... but maybe there's a sandwich in the refridgerator...")
} else {
msg ("Yum yum")
// make sandwich invisible script(s)
}HegemonKhan wrote:You already know what a nightmare it is to try to program~account for every possible situation in your own game making, well now expand that to creating a game engine... for people to use. If you think it's hard or taxing to have your game handle every action~command~etc a person~user may try, imagine trying to create a game engine, or a programming language itself...
if (ListContains(ScopeVisible(), sandwich)) {
msg ("You are in a kitchen. There is a table here, on top of which sits a fresh sandwich.")
}
if (not ListContains(ScopeVisible(), sandwich)) {
msg ("You are in a kitchen. There is a table here.")
}firsttime {
msg ("Yum yum!")
SetObjectFlagOn (player, "eaten")
MakeObjectInvisible (sandwich)
}
otherwise {
if (GetBoolean(player, "eaten")) {
msg ("You already ate it.")
}
}
OurJud wrote:I got there! You're right HK, it usually is something very stupid and simple, namely me.
Xan, I thought about flags and was busy doing it when you made your post.
Anyway, for those interested, here's the solution:
Room script:if (ListContains(ScopeVisible(), sandwich)) {
msg ("You are in a kitchen. There is a table here, on top of which sits a fresh sandwich.")
}
if (not ListContains(ScopeVisible(), sandwich)) {
msg ("You are in a kitchen. There is a table here.")
}
And the 'eat sandwich' command script:firsttime {
msg ("Yum yum!")
SetObjectFlagOn (player, "eaten")
MakeObjectInvisible (sandwich)
}
otherwise {
if (GetBoolean(player, "eaten")) {
msg ("You already ate it.")
}
}
if (ListContains(ScopeVisible(), sandwich)) {
msg ("You are in a kitchen. There is a table here, on top of which sits a fresh sandwich.")
}
else {
msg ("You are in a kitchen. There is a table here.")
}firsttime {
msg ("Yum yum!")
MakeObjectInvisible (sandwich)
}
otherwise {
if (not GetBoolean(sandwich, "visible")) {
msg ("You already ate it.")
}
}The Pixie wrote:
I would set up a room for things that are not currently in the game. I call in "nowhere" in my games, other people have other names like "offstage". Move the sandwich there when it is eaten.
<object name="edible flag room">
<inherit name="editor_room" />
<alias>edible triggering an event room</alias>
<description type="script"><![CDATA[
if (GetBoolean(cantaloupe, "eaten")) {
msg ("<br/>In this room, you will see how to eat something which causes an event to occur. Do these steps to see it in action:<br/>1. go to sleep<br/>2. eat the muffin<br/>3. go to sleep<br/>4. wake up<br/><br/>See! The cantaloupe does not have a description here. Once you type 'eat cantaloupe' you can put up a flag. I named mine 'eaten'. Then, I put an if script in this room's description that did not include information about the cantaloupe.")
}
else {
msg ("<br/>In this room, you will see how to eat something which causes an event to occur. Do these steps to see it in action:<br/>1. go to sleep<br/>2. eat the muffin<br/>3. go to sleep<br/>4. wake up<br/><br/>There is a fresh cantaloupe here as well.<br/><br/>Also, to alter room description after eating ssomething, eat the cantaloupe and have a look around.")
}
]]></description>
<object name="bed">
<inherit name="editor_object" />
<look>It's a bed.</look>
<lie type="script">
if (GetBoolean(muffin, "eaten")) {
msg ("That muffin really did you in! You lie down in bed and quickly fall asleep. (type 'wake up' to wake back up).")
}
else {
msg ("You lie down in bed and toss and turn. You just aren't tired enough to fall asleep.")
}
</lie>
</object>
<object name="muffin">
<inherit name="editor_object" />
<look>It's a muffin made of flour, sugar, eggs, milk, valium, and vanilla.</look>
<eat type="script">
msg ("You scarf down the valium laced muffin. Tasty.")
RemoveObject (muffin)
SetObjectFlagOn (muffin, "eaten")
</eat>
</object>
<command name="wake up cmd">
<pattern>wake up</pattern>
<script>
msg ("You wake from sleep after a long nap feeling refreshed. You get out of bed.")
MoveObjectHere (muffin)
</script>
</command>
<command name="go to sleep cmd">
<pattern>go to sleep</pattern>
<script>
if (GetBoolean(muffin, "eaten")) {
msg ("That muffin really did you in! You lie down in bed and quickly fall asleep.")
}
else {
msg ("You lie down in bed and toss and turn. You just aren't tired enough to fall asleep.")
}
</script>
</command>
<exit alias="south" to="different kind of objects room">
<inherit name="southdirection" />
</exit>
<object name="cantaloupe">
<inherit name="editor_object" />
<look>It is a cantaloupe shaped like your head. Eat it.</look>
<eat type="script">
msg ("You devour the head-shaped cantaloupe.")
SetObjectFlagOn (cantaloupe, "eaten")
RemoveObject (cantaloupe)
</eat>
</object>
<object name="Magoo">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="namedmale" />
<attr name="pov_look">You're Magoo. A simple being trapped in a test game.</attr>
<look type="script">
if (game.pov = Xanadu) {
msg ("Holy moly! That looks exactly like you! To take control of Magoo, just type 'switch to Magoo'.")
}
else {
msg ("You are a simple being trapped in a test game.")
}
</look>
</object>
</object>The Pixie wrote:If you use the built in "edible" type, that does a destroy, which would cause your error.
XanMag wrote:
1. Add object.
2. Add verb eat.
3. In that 'eat script' add flag 'eaten' to cantaloupe. Can be found under Variables.
4. Add 'Remove object cantaloupe' script to your eat verb.
5. In room description, 'Run Script', 'If', 'if object cantaloupe has flag eaten' then 'print message' without cantaloupe in the description, 'Else' 'print message' with cantaloupe in room description.
Marzipan wrote:
I hope you realize of course that no seasoned adventurer will ever eat your sandwich. They'll just carry it around in their inventory for the entire game in case it's needed to solve a puzzle.