I'm wondering if its possible to do this, and also perhaps variables as well.
Or perhaps a suitable alternative that is easy for me to use and understand (detailed comments on code examples if you please).
For example I would like to have a way to define game commands (and potentially all other sorts of data) without hard coding them. As one future goal of my TextRPG Engine is to have it be re-usable, or essentially "mod-friendly". Having a way to change or expand the way core systems work in the game would be great.
Adding new commands (I implement them with procedures currently), and everything that goes with it (defining arguements it will accept, etc)
Being able to modify existing, or add new combat mechanics (calculation formulas, stats, skills, damage types, etc).
The basic idea would be storing the definitions for such things in a database table, or XML file or something like that. I certainly don't know how to write my own scripting language, and wrappers for current languages, even older versions, are incomplete and leave a lot to be desired (and I've no real idea how to write one, much less pass data between PB and a scripting engine like that).
So if its at all possible to do this another way, its something I would be interested in trying..
Let's say I have a command I want to add stored in an XML file
(pseudo code ahead)
Code: Select all
<ParentNode>
<commands>
<newcommand>
<cmd_name>Steal</cmd_name>
<cmd_args>
<arg1 attribute="string">target</arg1>
</cmd_args>
<cmd_algorithm>(actor dex) + (SkillA / 1.5) + (SkillB * 0.15) vs (Target dex + SkillA Bonus) + (SkillB * 0.25)</cmd_algorithm>
</newcommand>
</commands>
</ParentNode>
So I can basically generate code that spits out a valid procedure that can now be accessed and used while the game is running, it will insert the command into the command dictionary, and when the player types "steal monsterA", the command parser (not the parser mentioned above) can find it in the dictionary, verify the grammar is correct and get a hit, etc and execute that procedure to see if something was stolen..
Would there be a way to do this?
TL;DR - Is there any way to externally define a procedure, and then build & use it while the program is already running.. (self- generating/modifying code ??)