Page 1 of 1

(renamed) Scripting Engines

Posted: Sun Apr 13, 2014 2:56 am
by Zach
Hi,

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>
And let's say I can write a parser to hash all that out and spit out the proper code that would be needed to build such a procedure, calculating stuff based on those variables / data (if possible). Which it could do at program startup or whatever (no impact on performance later)

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 ??)

Re: Is it possible to define and use an unknown Proc at runt

Posted: Sun Apr 13, 2014 3:44 am
by Demivec
Use eScript by srod.

Re: Is it possible to define and use an unknown Proc at runt

Posted: Sun Apr 13, 2014 4:28 am
by Zach
Yes, I remember eScript. I never had time to really look at it and play with it.

I suppose its time to take a look again..

Has anyone used eScript in a large project, aside from srod?

Re: Is it possible to define and use an unknown Proc at runt

Posted: Sun Apr 13, 2014 5:17 am
by Danilo
There's also PBScript by CSHW89 (PBScript.zip)

Re: Is it possible to define and use an unknown Proc at runt

Posted: Sun Apr 20, 2014 10:49 pm
by Zach
Just wondering, is there an updated AutoIt wrapper for PB? Or perhaps a near complete one for an older version I could still acquire?

I am somewhat familiar with AutoIT, as I use it to script game actions sometimes, and I know my way around it already, so I was hoping there was a useful wrapper available.. I know at one point someone posted a wrapper but that was along time ago wasn't it?

If anyone knows of a good, working wrapper it might also be a good alternative for me to look into

Re: (renamed) Scripting Engines

Posted: Mon Apr 21, 2014 1:45 am
by IdeasVacuum
Correct me if I'm wrong but I think a lot of games use Lua.
http://www.lua.org/

Re: (renamed) Scripting Engines

Posted: Mon Apr 21, 2014 2:41 am
by Zach
A lot do, and I've considered using it for A.I mainly. But I prefer other options. The syntax just gives me a headache to look at
I know someone did make a LUA wrapper for PB, but I'm not sure how out of date it is either.

Re: (renamed) Scripting Engines

Posted: Tue Apr 22, 2014 11:37 am
by Crusiatus Black
Zach wrote:A lot do, and I've considered using it for A.I mainly. But I prefer other options. The syntax just gives me a headache to look at
I know someone did make a LUA wrapper for PB, but I'm not sure how out of date it is either.
You can also simply use Lua 5.1 or Lua 5.2 as static library / dynamically linked library in your PB project, a PureBasic wrapper isn't required, just an include for PB importing all library functions and defining some constants and macro's.

Lua might be hard to get your head around (especially when used to strict / static languages), but it's extremely flexible and fast.