davedotluebke / old-skool-text-game

Coding project used to learn Python
5 stars 4 forks source link

Easier in-game code execution #191

Open davedotluebke opened 2 years ago

davedotluebke commented 2 years ago

Idea: add "invoke" command which takes an object in the game and a string, and attempts to call the string as a method of the object.

Currently, if there is (say) an orc in the room and you want to call a function (like die()) on the orc, you have to do some crazy thing like execute "self.cons.write(self.location.contents)" and get the ID of the orc and then call execute "Thing.ID_dict['<orc_id>'].die()"

It would be much nicer to just type invoke orc die() or invoke orc.die(), and have the Parser figure out the orc object and call the appropriate function.