Modify

Ticket #187 (closed bug: fixed)

Opened 9 years ago

Last modified 9 years ago

console suggestions

Reported by: zenbitz Owned by: parpg
Priority: major Milestone: Techdemo 1
Component: gui Version: trunk
Keywords: Cc:
Blocked By: Blocking:
Department:

Description (last modified by barra_parpg) (diff)

For testing dialogue/quest files I need the python console to be able to access (get/set) the game_state.

For example:

self.data.game_state.quest_engine.addQuest('quests/fedex.yaml')

or

self.data.game_state.quest_engine['fedex'].setValue('found_pekko', 1)

The first currently returns "console instance has no attribute data"... which is quite logical, but not helpful We need API access to QuestEngine?, PC, NPC, Inventory, other objects - at least for testing purposes.

Two other minor points:

python import foo

doesn't work at all (for any foo that I try), throwing syntax error.

I had set the console command to F2 instead of F10 because my mac powerbook doesn't like F10. This is not a huge deal, but right now I have a hacked version of keyPressed in world.py so that I can use the console!

Attachments

Change History

comment:1 Changed 9 years ago by zenbitz

sorry about the formatting... it should be clear.

comment:2 Changed 9 years ago by eliedebrauwer

  • Description modified (diff)

you didn't try hard enough ;)

for now the python code you execute is eval()'ed, but it run from the console.py context so you need to travel your way up.

To get your example functional you should type

python self.app_listener.wold.data.game_state.quest_engine.addQuest('quests/beer.yaml')

I do agree that in the long run we might want to have a more flexible scripting interface, so we can connect to it remotely, launch scripts (which would be sweet for unittesting and regression testing).

comment:3 Changed 9 years ago by eliedebrauwer

(In [389]) Ticket #187. Patch by eliedebrauwer: Improved python code parsing from the console. refs #187

comment:4 Changed 9 years ago by barra_parpg

  • Description modified (diff)

comment:5 Changed 9 years ago by eliedebrauwer

Zenbitz, could you update the ticket with what you still think is lacking ? Or close the ticket if you're completely pleased by the current functioning ? ;)

comment:6 Changed 9 years ago by zenbitz

OK, it does seem to be possible to set game_state (quest_engine) values, but the console always returns "None" (when it doesn't throw an exception) so you cannot actually GET any values.

It would also be nice to be able to cut-and-paste commands into the console, and to "save state" (so that you could store {{ qe = self.app_listener.wold.data.game_state.quest_engine}} and not have to retype it (this isn't so bad becuae you can up-arrow to get last command)

comment:7 Changed 9 years ago by zenbitz

w.r.t the "return None"... this also causes the unittest to fail. If you replace the result = str(eval(compile(end_python,'<string>','single'))) with result = str(eval(compile(end_python,'<string>','eval')))

The values (at least for 2*2) return

comment:8 Changed 9 years ago by zenbitz

I have patched the change of single -> eval in release 396, it seems to do what we need for now.

comment:9 Changed 9 years ago by eliedebrauwer

Okay, regarding your previous comments, well it did what you asked ;) in order to get output the workaround was to prefix it with a print and you would see what you asked on standard output (which wasn't that convenient after all).

comment:10 Changed 9 years ago by eliedebrauwer

  • Status changed from new to closed
  • Resolution set to fixed

(In [416]) Ticket #187: Patch by eliedebrauwer. Added shortcuts so from the console self.world, self.engine and self.game_state point to, well world, engine and game_state. closes #187

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.