Merge pull request #3065 from Xinefus-Braska/patch-1
Update Beginner-Tutorial-Making-A-Sittable-Object.md
This commit is contained in:
commit
c1f32e31a0
1 changed files with 7 additions and 7 deletions
|
|
@ -11,7 +11,7 @@ the current chair in an attribute `is_sitting`. Other systems could check this t
|
||||||
- A character should be able to stand up and move away from the chair.
|
- A character should be able to stand up and move away from the chair.
|
||||||
- When you sit down you should not be able to walk to another room without first standing up.
|
- When you sit down you should not be able to walk to another room without first standing up.
|
||||||
|
|
||||||
## Make us not able to move while resting
|
## Make us not able to move while sitting
|
||||||
|
|
||||||
When you are sitting in a chair you can't just walk off without first standing up.
|
When you are sitting in a chair you can't just walk off without first standing up.
|
||||||
This requires a change to our Character typeclass. Open `mygame/typeclasses/characters.py`:
|
This requires a change to our Character typeclass. Open `mygame/typeclasses/characters.py`:
|
||||||
|
|
@ -24,12 +24,12 @@ This requires a change to our Character typeclass. Open `mygame/typeclasses/char
|
||||||
class Character(DefaultCharacter):
|
class Character(DefaultCharacter):
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
def at_pre_move(self, destination):
|
def at_pre_move(self, destination, **kwargs):
|
||||||
"""
|
"""
|
||||||
Called by self.move_to when trying to move somewhere. If this returns
|
Called by self.move_to when trying to move somewhere. If this returns
|
||||||
False, the move is immediately cancelled.
|
False, the move is immediately cancelled.
|
||||||
"""
|
"""
|
||||||
if self.db.is_resting:
|
if self.db.is_sitting:
|
||||||
self.msg("You need to stand up first.")
|
self.msg("You need to stand up first.")
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
@ -71,8 +71,8 @@ class Sittable(Object):
|
||||||
sitter.msg(f"You can't sit on {self.key} "
|
sitter.msg(f"You can't sit on {self.key} "
|
||||||
f"- {current.key} is already sitting there!")
|
f"- {current.key} is already sitting there!")
|
||||||
return
|
return
|
||||||
self.db.sitting = sitter
|
self.db.sitter = sitter
|
||||||
sitter.db.is_sitting = self
|
sitter.db.is_sitting = self.obj
|
||||||
sitter.msg(f"You sit on {self.key}")
|
sitter.msg(f"You sit on {self.key}")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ class Sittable(DefaultObject):
|
||||||
f"You can't sit {adjective} {self.key} "
|
f"You can't sit {adjective} {self.key} "
|
||||||
f"- {current.key} is already sitting there!")
|
f"- {current.key} is already sitting there!")
|
||||||
return
|
return
|
||||||
self.db.sitting = sitter
|
self.db.sitter = sitter
|
||||||
sitter.db.is_sitting = self
|
sitter.db.is_sitting = self
|
||||||
sitter.msg(f"You sit {adjective} {self.key}")
|
sitter.msg(f"You sit {adjective} {self.key}")
|
||||||
|
|
||||||
|
|
@ -313,7 +313,7 @@ class Sittable(DefaultObject):
|
||||||
(docstring)
|
(docstring)
|
||||||
"""
|
"""
|
||||||
def at_object_creation(self):
|
def at_object_creation(self):
|
||||||
self.cmdset.add_default(CmdSetSit)A
|
self.cmdset.add_default(CmdSetSit)
|
||||||
# ...
|
# ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue