![]() |
function: eval
32 Attachment(s)
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:
To be added:
To be limited in final release:
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:
|
That's truly amazing, far beyond what I could do.
|
You know once you declare a variable as temp you don't need the temp. for the rest of that function right?
All the temp. is melting my eyes :( But damn fine job on that eval(). |
Quote:
|
Quote:
|
Nice :)
|
Question: should eval be able to access temp. variables declared within the scope that eval is called? e.g.,
PHP Code:
PHP Code:
e2: in and ',' operators are conflicting by precedence (',' < in). Inspire me to solve the problem that is 'in |a,b|'! It's tough to say that ',' could have enough foresight to see it's part of in. |
Read line 242.
|
Quote:
|
Quote:
Nice job pfa. :) |
Looks good PFA. I'm still going to post mine though when I'm not so busy ^^.
|
Quote:
|
Quote:
|
I have updated the script, it now supports strings. Next I hope to tackle arrays, then variables should follow, should be quite the challenge. :)
@Zero: Stop being lazy. :p |
Really nice work.
|
|
Quote:
|
Quote:
|
Quote:
|
Just released a new version, one is for debug ("unstable"), and the other just has the functions to do the work. This release can catch all variables prefixes excluding temp.-. I fixed some problems (multidimensional arrays, 'error code 2' caused an infinite loop), and errors now tell you exactly what the problem is (and what line, but since only one line is supported so far, it says line 1, hurr). You should be able to do multiple operations, separating them with ;.
If you want to mess with the debug version, just change __debug__ (this is the mode) to somewhere between 0 (none) and 15 (all) and __debug_string__ to whatever you want to evaluate. The debug method does not make a call to eval(). |
Hate to double post, but for the sake of the bump...
I've been slowly making progress with this script. Over the past few days, the to-do list has been slowly shrinking. The current version finally recognizes functions (it will say that the function does not exist, but the point is that it finds them correctly). I will release a supplementary script for the functions once I figure out a good way to handle them (must be secure, hoping to minimize the use of function f(p1,p2,...,pN), &c.). |
Quote:
Way to show Zero who's boss! ^^ |
Quote:
Neither of ours is better per say as we are doing them entirely different ways. Anyways, good job PFA :). |
Quote:
Yours is awesome as well. Didn't mean to hurt your ego, 'o great one. |
Quote:
|
| All times are GMT +2. The time now is 05:43 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.