Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-24-2008, 05:33 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
function: eval

eval()

eval(str) - evaluates/executes a string of GScript.

You asked for it and you got it. eval is a function available in other scripting languages. Its only parameter is a string of code to be executed. This is not so much to show off the script, but rather I hope I can get some input into what this function should do. Useful? Sure. You could save expressions such as "player.hp += this.hpgain;" in mudlib files, or similar. The possibilities are probably endless, but I'm just the guy doing the coding.

Currently supports:
  • strings, arrays, variables, functions, comments, operators
  • error catching, garbage collection
  • variable assignment toggling, protection

To be added:
  • flow structures
  • temp.- variables of calling function accessible

To be limited in final release:
  • for, while, do-while loops
  • 'new' operator
  • script complexity


If there's something you want to fix/write, go ahead and post your update in this thread. Questions, comments, critique, and requests are welcomed. Please try it and report issues!

I have included an "unstable" version of the parser. It may have some debug messages, etc. This file will be updated more regularly.

Updates:
  • April 16
    • fixed small bug with constructs like a(2) [the 2 turned into 0].
    • added support for dynamic variable names this.(@blah).
    • added support for the [] operator.
  • April 19
    • added support for special concatenation operators (SPC, TAB, NL), oops!
    • tested @ array; it works
  • April 26
    • fixed a bug with inserting operators with constructs like h = f(g(x)).
    • the script is accurately finding functions (there may be some issues). It is not yet calling the functions, though.
  • April 28, 29, 30
    • Made the dot operator a LOT faster, yay!
    • added support for functions, woo!
    • added comma operator (that should be all of them!)
Attached Files
File Type: txt math.parser.unstable.txt (17.9 KB, 360 views)
File Type: txt math.parser.txt (15.5 KB, 425 views)
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/

Last edited by Tolnaftate2004; 05-02-2008 at 12:58 AM..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.