From 4ab02c7bd50310851dc215ae666fc51c24f2b629 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Sat, 17 May 2025 11:51:56 -0700 Subject: [PATCH] Move read command to character Fixed a puppet pose of the reset. Updated the introduction. --- commands/default_cmdsets.py | 3 +- commands/everyone.py | 30 ++++++ typeclasses/characters.py | 2 - typeclasses/drinkables.py | 1 + typeclasses/puppets.py | 7 ++ typeclasses/readables.py | 28 +----- web/static/website/intro.html | 178 +++++++++++++++++++++++----------- world/version2.ev | 30 ++---- 8 files changed, 178 insertions(+), 101 deletions(-) diff --git a/commands/default_cmdsets.py b/commands/default_cmdsets.py index 975d5a3..2e95bf1 100644 --- a/commands/default_cmdsets.py +++ b/commands/default_cmdsets.py @@ -20,7 +20,7 @@ from evennia.contrib.game_systems.gendersub import SetGender from evennia.contrib.rpg.rpsystem import RPSystemCmdSet from evennia.contrib.rpg.character_creator.character_creator import ContribChargenCmdSet from commands.sittables import CmdNoSitStand -from commands.everyone import CmdTake, CmdThink, CmdSay, CmdWhisper +from commands.everyone import CmdTake, CmdThink, CmdSay, CmdWhisper, CmdRead from commands.wizards import CmdGM, CmdSpell, CmdGMTrigger, CmdMakeCocktail class CharacterCmdSet(default_cmds.CharacterCmdSet): @@ -45,6 +45,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet): self.add(extended_room.ExtendedRoomCmdSet) self.add(CmdSay) self.add(CmdWhisper) + self.add(CmdRead) self.add(CmdGM) self.add(CmdSpell) self.add(CmdGMTrigger) diff --git a/commands/everyone.py b/commands/everyone.py index 4ed0ca9..be9f320 100755 --- a/commands/everyone.py +++ b/commands/everyone.py @@ -240,6 +240,36 @@ class CmdThink(Command): self.caller.execute_cmd(f"pub :{msg}") +class CmdRead(Command): + """ + Return the inside contents of a book or other readable object. + + Usage: + + read + + To add something to read on target, use the @set command: + + @set /inside = 'This is the text to read.' + """ + key = "read" + + def func(self): + """Return the 'inside' attribute.""" + + target_str = self.args.strip() + if target_str == "": + self.caller.msg("Usage: |gread |n") + return + + target = self.caller.search(target_str) + if target: + if target.db.inside: + self.caller.msg(target.db.inside) + else: + self.caller.msg(f"Nothing to read on {target.get_display_name(self.caller)}") + + class CmdTake(Command, NumberedTargetCommand): """ Take an object from another character or NPC. diff --git a/typeclasses/characters.py b/typeclasses/characters.py index 05e35b6..c7c83df 100644 --- a/typeclasses/characters.py +++ b/typeclasses/characters.py @@ -83,8 +83,6 @@ class Character(Object, GenderCharacter, ContribRPCharacter): """ Make sure we aren't left sitting down when logging out. """ - self.execute_cmd("pose reset") - if self.db.is_sitting: chair = self.db.is_sitting chair.db.sitter = None diff --git a/typeclasses/drinkables.py b/typeclasses/drinkables.py index ed88950..e602438 100755 --- a/typeclasses/drinkables.py +++ b/typeclasses/drinkables.py @@ -292,6 +292,7 @@ class Cocktail(Object): else: drinker.msg(choices(EMPTY_COCKTAIL_MSGS, cocktail_type)) self.key = "cocktail glass" + self.aliases = ['glass'] self.db.desc = "An empty cocktail glass" self.db.amount = self.db.amount - self.sip_amount diff --git a/typeclasses/puppets.py b/typeclasses/puppets.py index 3436227..07d9c02 100755 --- a/typeclasses/puppets.py +++ b/typeclasses/puppets.py @@ -28,6 +28,13 @@ class Puppet(Character): self.msg("\nYou are puppeting |c{name}|n.".format(name=self.key)) self.msg((self.at_look(self.location), {"type": "look"}), options=None) + def at_pre_unpuppet(self, **kwargs): + """ + Reset our pose. + """ + super().at_pre_unpuppet() + self.execute_cmd("pose reset") + def at_post_unpuppet(self, account=None, session=None, **kwargs): """ Make the character object remain in the room. diff --git a/typeclasses/readables.py b/typeclasses/readables.py index ce9bfdc..0046c46 100755 --- a/typeclasses/readables.py +++ b/typeclasses/readables.py @@ -1,15 +1,14 @@ #!/usr/bin/python +import random + from evennia import Command, CmdSet -from evennia.utils import logger from evennia.prototypes.spawner import spawn from typeclasses.objects import Object from typeclasses.rooms import DabblersRoom from utils.word_list import routput -import random - BOOK_EMOTIONS = [ "sad", "heartfelt", @@ -67,6 +66,7 @@ BOOKS = { "The Wyrm in the Willows": "small dragon from the countryside who learns to cook without burning the meal first", } + class CmdLookBook(Command): """ Respond with a new book to look at. @@ -91,15 +91,6 @@ class CmdTakeBook(Command): self.obj.do_take(self.caller) -class CmdReadBook(Command): - """ - Return the inside contents of the book. - """ - key = "read" - def func(self): - self.obj.do_read(self.caller) - - class CmdBurnBook(Command): """ Destroy the instance of the book @@ -123,12 +114,11 @@ class CmdDropBook(Command): class CmdSetRead(CmdSet): def at_cmdset_creation(self): - self.add(CmdReadBook) + pass # self.add(CmdReadBook) class CmdSetBook(CmdSet): def at_cmdset_creation(self): - self.add(CmdReadBook) self.add(CmdBurnBook) self.add(CmdDropBook) @@ -149,15 +139,7 @@ class Readable(Object): @desc sign = A tall wooden post. @set sign/inside = "What happens when you read it." """ - def at_object_creation(self): - """ - called at creation - """ - self.cmdset.add_default(CmdSetRead) - - def do_read(self, reader): - "called when 'read'." - reader.msg(self.db.inside) + pass class Letter(Readable): diff --git a/web/static/website/intro.html b/web/static/website/intro.html index ef3cba2..95d2f37 100644 --- a/web/static/website/intro.html +++ b/web/static/website/intro.html @@ -7,7 +7,7 @@ RPG for the Moss and Puddles Mud - -