how do i code unconsciousness using a function
TiberianEuanOfficial
26 Apr 2022, 00:12i want to make the player able to be knocked out and be unable to use any verb other than wait
>sleep
You close your eyes to rest.
>take object
You are unconscious!
mrangel
26 Apr 2022, 11:55I would suggest creating a command called "unconscious", which has the regular expression pattern ^(?!wait\b)
and displays a message saying something like "you can't do that".
When the player is unconscious, there are two options:
-
Enable the "unconscious" command (which runs for any command other than "wait") by moving it into the player's room. (
MoveObjectHere (unconscious)
)- When they wake up, use
AddToInventory (unconscious)
to disable that command again (adding a command to the inventory is the simplest way to remove it; usingRemoveObject
would make it work everywhere)
- When they wake up, use
-
Have a room whose description is something appropriate, and move the player there when they are unconscious.
- You might need to set an attribute to their previous location, so you can move them back when they wake up.
- In this case, you would want the unconscious command to always be in that room
Nemec
29 Apr 2022, 11:50Building off the idea of moving the player:
You could create a character with preset attributes that mimic unconsciousness, name it unconscious_player or something, put it in a room that describes being unconscious, and have a built-in timerscript/turnscript for that room that calls some function maybe named playerWakeUp() function after some time.
When the player goes unconscious, have some function maybe named PlayerGoUnconscious() change the game.pov = unconscious_player and then display the room's description (maybe use OnEnterRoom() ). When the turnscript finishes have it change game.pov = player and describe the player waking up.