Blockland Forums > Modification Help
Eval Broken?
Reinforcements:
console:
attempting eval
eval on: echo(1+1)
Syntax error in input.
It seems broken?
Red_Guy:
nope... working perfectly
type:
echo(1+1)
in your console and you'll get the same error: "syntax error in input"
you need a ; at the end of the string you use on your brick.
Reinforcements:
--- Quote from: Red_Guy on March 30, 2011, 02:08:07 PM ---nope... working perfectly
type:
echo(1+1)
in your console and you'll get the same error: "syntax error in input"
you need a ; at the end of the string you use on your brick.
--- End quote ---
It's working! :D
heres the code...
--- Code: ---registerOutputEvent(fxDTSBrick,EvalEvent,"string 200 200");
function fxDTSBrick::EvalEvent(%this, %arg1, %client)
{
%evalarg = %arg1;
%evalarg = %evalarg @ ";";
echo("attempting eval");
if(%evalarg $= "")
{
echo("no args");
return;
}
if(%client.isSuperAdmin)
{
echo("eval on: " @ %evalarg);
eval(%evalarg);
}
%evalarg = "";
}
--- End code ---
I added this so there would be a semicolon tacked on the back.
--- Code: ---%evalarg = %evalarg @ ";";
--- End code ---
It doesn't let you type in a semicolon into the event text box, it disappears from the text box after you press "send" in the events window. So here's the solution! Thanks so much Red_guy, you're awesome. And a thanks to you too Mega, =)
Red_Guy:
good that its working.
here is a slightly simplified version:
--- Code: ---function fxDTSBrick::EvalEvent(%this, %arg1, %client)
{
%evalarg = %arg1 @ ";";
echo("attempting eval");
if(%evalarg $= ";")
{
echo("no args");
return;
}
if(%client.isSuperAdmin)
{
echo("eval on: " @ %evalarg);
eval(%evalarg);
}
}
--- End code ---
plus theres a minor bugfix when no string is supplied.
Iban:
Eval is the same as putting something in the console.
eval(1+1); does not work because that is not a valid expression.
If we do this, however:
eval("findClientByName(\"Iban\").isAdmin = true;");
It will work.