(renamed) Scripting Engines

Just starting out? Need help? Post your questions and find answers here.
Zach
Addict
Addict
Posts: 1676
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

(renamed) Scripting Engines

Post 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 ??)
Last edited by Zach on Sun Apr 20, 2014 10:49 pm, edited 1 time in total.
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

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

Post by Demivec »

Use eScript by srod.
Zach
Addict
Addict
Posts: 1676
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

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

Post 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?
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

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

Post by Danilo »

There's also PBScript by CSHW89 (PBScript.zip)
Zach
Addict
Addict
Posts: 1676
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

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

Post 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
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: (renamed) Scripting Engines

Post by IdeasVacuum »

Correct me if I'm wrong but I think a lot of games use Lua.
http://www.lua.org/
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Zach
Addict
Addict
Posts: 1676
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: (renamed) Scripting Engines

Post 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.
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

Re: (renamed) Scripting Engines

Post 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.
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
Post Reply