DracScript 1.06 Released! LGPL Scripting Language

Developed or developing a new product in PureBasic? Tell the world about it.
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

DracScript 1.06 Released! LGPL Scripting Language

Post by dracflamloc »

** If the LGPL license prevents you from using DracScript in your game or application please contact me so we can work something out. **

If someone would like to volunteer to be the official pb4 converter thats fine. Its not like its very hard ;)

[Note]
Just a quick note:

For those unfamiliar witht he LGPL. If you use this code in any way you must release the modifications to JUST THIS CODE AND ITS INCLUDES (but not the other way around) and within your programs documentation or credits must make available a way for the source code to be obtained at no cost. Thats it in a nutshell but the full text can be found on www.gnu.org

Enjoy!
[/Note]

Hey folks I'm proud to present the release of DracScript. It has a Pb-like syntax and is written in PB. Thanks to Trond, Srod, and Xombie for the mathematical expression evaluators, optimizations and hard work!

You can download the source and sample scripts from here:
http://www.dracsoft.com/zips/dracscript.zip

You will always be able to find the latest official version here. If you have changes you've made with optimizations, etc, post them and I will include them into the official version here!

To use, just include the file DracScript.pb, and set #DS_TEST_BUILD to 0
Register your functions and register then default functions using DS_RegisterDefault()

Strings in the script are denoted by single quotes like so: 'Hi!'
Mathematical expressions must be done in the form: "var1=var2+var3-(8+9.9)", etc. At the moment there is no pb-like shortcut like "var1 + 1". You can do just about any kind of mathematical expression in the While conditions or in the variable assignment. DracScript is sort of like a small subset of PB for scripting.

To do a For-Next loop, just use While/Wend and increment the variable yourself. I left out For-Next purposefully to make the code simpler and increase the speed a bit.

Its possible to strip out the default functions if you dont need or want them by setting #DS_INCLUDE_DEFAULT to 0

Enjoy and be sure to let me know what you use it for!

[Update]
1.0 Beta is released. Now you can load multiple scripts. A few changes to procedures can be seen in the Readme.txt.

[Update]
1.01 Beta is up. Xombies IsNumeric() rewrite is used for speed.

[Update]
1.02 is up. Seems stable enough. Fixed the bug where commands wouldnt be executed in conditionals.

[Update]
1.03 is up. Small bugfix in Constant processing.

[Update]
1.04 is up. Major bugfix. In fixing the constant processing, I discovered that DS_FreeScript did not work correctly and wasn't resetting certain things. This affects when you try loading a script over another script and can cause very strange behavior and even infinite loops when using if/else/while/wend.

[Update]
1.05 is up. Significant bugfix that caused no script to work correctly after an error occurred in a 'scripting command'. This version is still 3.94 compatible.

[Update]
1.06. Another big bugfix that caused a script to crash the engine if it tried to concatenate a string with a '+' sign in them. Also, a constant has been added so its possible to change the character that is used to mark strings. By default this is now the double-quote or char(34)
Last edited by dracflamloc on Sun Jun 24, 2007 4:47 pm, edited 12 times in total.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

If this is good, then i'm going to use it for a RPG.
But I must finish the damn chess game first :lol:

Thank you for this, going to test it later sometime!
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

Really amazing work! It's a bit annoying with the mathmatical expressions however. Have you considered using an end of line symbol instead?

var1 = var2 + var3;

For example.
~I see one problem with your reasoning: the fact is thats not a chicken~
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

What do you mean by annoying?

If you are referring to the Eval() command? Thats only needed when you want to mathematically evaluate a part of a string concatenation. Otherwise its fine to use normal math expressions just like in pb

Eval() is sort of like Str() in pb. Actually maybe I should rename it to that...
Brice Manuel

Post by Brice Manuel »

I really like this. Good work!!
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Thanks. Enjoy! And feel free to optimize it a bit and post back here =)
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

1.0 Beta is released. Now you can load multiple scripts. A few changes to procedures can be seen in the Readme.txt.
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Very good work!
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

ARgh!

T3h Warg 3 will use DracScript, and graphics made in Paint.Drac and POV-Drac...

The audio track will be made using Fruity-Drac....

Also comming soon:

DracOS 1.0 ! Image :shock:



Eheheh

Now on the serious side, nice work!
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Hey... DracOS... not a bad idea!
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

I gotta admit it Sounds cool !
theNerd
Enthusiast
Enthusiast
Posts: 131
Joined: Sun Mar 20, 2005 11:43 pm

Post by theNerd »

Great work! Thanks!
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Howdy, dracflamloc. I finally downloaded your code to look through. Figure I could see what I could spiff up for you. I immediately noticed your IsNumber function and thought I'd humbly offer my own code as a replacements.

I ran this block of code as a speed test...

Code: Select all

Delay(500)
;
a.l = GetTickCount_()
   ;
   For b.l = 1 To 100000
      ;
      IsNumber("323", 46, 0, 0)
      IsNumber("-323", 46, 0, 0)
      IsNumber("3-23", 46, 0, 0)
      IsNumber("32.1323", 46, 0, 0)
      IsNumber("3232.231.321", 46, 0, 0)
      IsNumber("-4113.7892", 46, 0, 0)
      ;
   Next b
   ;
z.l = GetTickCount_()
;
MessageRequester("", Str(z-a))
Mine: 172ms
Yours: 1171ms

On my PC at least. Also, yours will incorrectly identify string as numbers. In those tests above, it only thinks "3-23" is not a number. It does not catch "3232.231.321", for example. I didn't test more extensively.

One thing to note for my code that's different than yours - you can change the character used for a decimal or thousands separator (or use '0' for either to disable their usage in a pure integer numeric). Also, it will return 0 for a non-numeric. It's other return values are 1, -1, 2, -2. That's positive numeric, negative numeric, positive decimal and negative decimal. You can leave it as is and just always test for a non-zero to show that it's a number or you could change the behavior to always return 1 for a postive/negative numeric/decimal. Up to you :) It also has a function to return a 'cleaned' value that basically removes spaces and any thousands separator.

Anyway, I'll dig through some more later and see if I spot any other cheap speed increases for you.

http://www.seijin.net/Storage/Code/IsNumber.pb
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Hey dracflamloc, I found a nice program you could use to make dracscript better. I found this when I was trying to find out more about interpreters.
I hope it helps. Here it's the link:
http://www.planet-source-code.com/vb/sc ... 1&lngWId=1
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Looks interesting.

@Xombie: Thanks! Its in dracscript now. You can check it out. I changed a few things since I believe the IsNumeric should be a simple one-parameter function. I just made the decimal character a constant mainly.
Post Reply