The name must match a valid thing action function. If after the name
setting no ThingAction with name "wait" remains, call set_world_inactive().
"""
- if name == "wait" or name == "move" or name == "use" or name == "drop" \
- or name == "pickup":
+ from server.config.commands import commands_db
+ if name in commands_db and name.islower():
world_db["ThingActions"][command_taid.id]["TA_NAME"] = name
if 1 == world_db["WORLD_ACTIVE"]:
for id in world_db["ThingActions"]:
def play_wait():
"""Try "wait" as player's T_COMMAND."""
- set_command("wait")
+ if world_db["WORLD_ACTIVE"]:
+ set_command("wait")
def action_exists(action):
def play_pickup():
"""Try "pickup" as player's T_COMMAND"."""
- if action_exists("pickup"):
+ if action_exists("pickup") and world_db["WORLD_ACTIVE"]:
t = world_db["Things"][0]
ids = [tid for tid in world_db["Things"] if tid
if not world_db["Things"][tid]["carried"]
def play_drop(str_arg):
"""Try "drop" as player's T_COMMAND, int(str_arg) as T_ARGUMENT / slot."""
- if action_exists("drop"):
+ if action_exists("drop") and world_db["WORLD_ACTIVE"]:
t = world_db["Things"][0]
if 0 == len(t["T_CARRIES"]):
log("You have NOTHING to drop in your inventory.")
def play_use(str_arg):
"""Try "use" as player's T_COMMAND, int(str_arg) as T_ARGUMENT / slot."""
- if action_exists("use"):
+ if action_exists("use") and world_db["WORLD_ACTIVE"]:
t = world_db["Things"][0]
if 0 == len(t["T_CARRIES"]):
log("You have NOTHING to use in your inventory.")
def play_move(str_arg):
"""Try "move" as player's T_COMMAND, str_arg as T_ARGUMENT / direction."""
- if action_exists("move"):
+ if action_exists("move") and world_db["WORLD_ACTIVE"]:
from server.config.world_data import directions_db, symbols_passable
t = world_db["Things"][0]
if not str_arg in directions_db:
def command_ai():
"""Call ai() on player Thing, then turn_over()."""
from server.ai import ai
- ai(world_db["Things"][0])
- turn_over()
+ if world_db["WORLD_ACTIVE"]:
+ ai(world_db["Things"][0])
+ turn_over()