# HG changeset patch # User Beliar # Date 1332579586 -3600 # Node ID ab6a0fd1668aa7a294682ed31d083682efeb626d # Parent c41299c7e833ce07efd81e42779758b8fcd6ea08 Added help, moveObject, deleteObject, putItemIntoContainer, equipItem, createItemByID and createItemByType functions to the GameEnvironment. diff -r c41299c7e833 -r ab6a0fd1668a gamemodel.py --- a/gamemodel.py Tue Mar 20 14:31:02 2012 +0100 +++ b/gamemodel.py Sat Mar 24 09:59:46 2012 +0100 @@ -60,7 +60,7 @@ """Initialize the instance. @param engine: A fife.Engine object @type emgome: fife.Engine - @param setting: The applications settigns + @param setting: The applications settings @type setting: parpg.settings.Settings object @return: None""" self.settings = settings @@ -69,9 +69,15 @@ self.load_saver = False self.savegame = None quests_directory = settings.get("parpg", "QuestsPath") + #setup functions for the GameEnvironment self.game_state = GameState(quests_dir=quests_directory) - #self.game_state.quest_engine = - #self.game_state.quest_engine.readQuests() + funcs = { + "moveObject":self.moveObject, + "deleteObject":self.deleteObject, + "putItemIntoContainer":container.put_item, + "equipItem":equip.equip, + } + self.game_state.funcs.update(funcs) self.pc_run = 1 self.target_position = None self.target_map_name = None diff -r c41299c7e833 -r ab6a0fd1668a gamescenecontroller.py --- a/gamescenecontroller.py Tue Mar 20 14:31:02 2012 +0100 +++ b/gamescenecontroller.py Sat Mar 24 09:59:46 2012 +0100 @@ -74,6 +74,24 @@ model, application) World.__init__(self) + + #setup functions for the GameEnvironment + createItemByID = lambda identifier : ( + self.model.createItemByID( + identifier=identifier, + world=self) + ) + createItemByType = lambda item_type, identifier: ( + self.model.createItemByType( + item_type=item_type, + identifier=identifier, + world=self) + ) + funcs = { + "createItemByID": createItemByID, + "createItemByType": createItemByType, + } + self.model.game_state.funcs.update(funcs) self.systems.scripting.game_state = self.model.game_state #this can be helpful for IDEs code analysis diff -r c41299c7e833 -r ab6a0fd1668a gamestate.py --- a/gamestate.py Tue Mar 20 14:31:02 2012 +0100 +++ b/gamestate.py Sat Mar 24 09:59:46 2012 +0100 @@ -12,11 +12,14 @@ # You should have received a copy of the GNU General Public License # along with PARPG. If not, see . - import math from parpg.quest_engine import QuestEngine +def script_help(object): + """Python's help() function with the no-parameters path disabled""" + help(object) + class GameState(object): """This class holds the current state of the game.""" def __init__(self, quests_dir = None): @@ -29,13 +32,14 @@ self.maps = {} self.npcs_met = set() self.funcs = { - "__builtins__":None, - "meet":self.meet, - "met":self.met, - "sqrt":math.sqrt, - "log":math.log, - "str":str, - } + "__builtins__":None, + "help":script_help, + "sqrt":math.sqrt, + "log":math.log, + "str":str, + "meet":self.meet, + "met":self.met, + } self.locals = {}