Giter Club home page Giter Club logo

Comments (8)

wysohn avatar wysohn commented on June 18, 2024 1

Great catch! I will take a look where the cause is

from triggerreactor.

wysohn avatar wysohn commented on June 18, 2024

eed96da

Now you can use both space and ',' for argument separator.

/trg run #WORLD:LEVERTOGGLE -14341, 82, -1716

will work.

(New refactored version is still under heavy testing. Expect some bugs!)

from triggerreactor.

soliddanii avatar soliddanii commented on June 18, 2024

Ok so i tested it and now i can use ',' and ', ' but not just a space. Is that right?

from triggerreactor.

wysohn avatar wysohn commented on June 18, 2024

No, you can still use spaces.

You can even add space and commas together.

I don't know if it's a good design, but I didn't want to break the functioning Triggers that uses spaces for separator

from triggerreactor.

soliddanii avatar soliddanii commented on June 18, 2024

I was asking because with the latest build (172) i still can't use just spaces. Commas and commas with spaces work fine, but spaces don't:

Command:

/trg run #WORLD:LEVEROFF -14341 82 -1716

Parameters the executor is getting:

Number of parameters: 2
Parameter 1: -14341
Parameter 2: -1634

Error:

at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:598)
at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.start(Interpreter.java:267)
at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.startWithContextAndInterrupter(Interpreter.java:141)
at io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager$Trigger.start(AbstractTriggerManager.java:217)
at io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager$Trigger$1.run(AbstractTriggerManager.java:202)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.Exception: #LEVEROFF encountered error.
at io.github.wysohn.triggerreactor.core.manager.AbstractExecutorManager$JSExecutor.execute(AbstractExecutorManager.java:266)
at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:327)
... 5 more
Caused by: java.util.concurrent.ExecutionException: javax.script.ScriptException: Error: Invalid parameters. Need [Location] in at line number 44 at column number 2
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftFuture.get(CraftFuture.java:74)
at io.github.wysohn.triggerreactor.core.manager.AbstractExecutorManager$JSExecutor.execute(AbstractExecutorManager.java:264)
... 6 more
Caused by: javax.script.ScriptException: Error: Invalid parameters. Need [Location] in at line number 44 at column number 2
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:392)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:190)
at io.github.wysohn.triggerreactor.core.manager.AbstractExecutorManager$JSExecutor$1.call(AbstractExecutorManager.java:245)
at io.github.wysohn.triggerreactor.core.manager.AbstractExecutorManager$JSExecutor$1.call(AbstractExecutorManager.java:232)
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftFuture.run(CraftFuture.java:89)
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:356)
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:832)
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423)
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:766)
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:664)
... 1 more
Caused by: :44:2 Error: Invalid parameters. Need [Location]
at jdk.nashorn.internal.objects.NativeError.initException(NativeError.java:137)
at jdk.nashorn.internal.objects.NativeError.(NativeError.java:102)
at jdk.nashorn.internal.objects.NativeError.(NativeError.java:106)
at jdk.nashorn.internal.objects.NativeError.(NativeError.java:110)
at jdk.nashorn.internal.objects.NativeError.constructor(NativeError.java:129)
at jdk.nashorn.internal.scripts.Script$Recompilation$32$914A$\^eval\_.LEVEROFF(:44)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:386)
... 10 more

from triggerreactor.

wysohn avatar wysohn commented on June 18, 2024

Sorry, for that case, you have no choice but using comma to separate them.

It's because TriggerReactor first tokenize the source code and then parse it one by one.

For example, even if you wrote -14341 82 -1716, after the lexical analysis, it becomes -, 14341, 82, -, 1716 total of five tokens.

Therefore, parser really has no ability to distinguish between 82 - 1716 or 82 and -1716 as they are the same for the parser.

Or, you can first save negative value in the variable and use it for the Executor

x=-14341;y=82;z=-1716;#WORLD:LEVEROFF x y z

from triggerreactor.

soliddanii avatar soliddanii commented on June 18, 2024

Negative numbers are proving to be a real problem. Now #LEVEROFF works if I use commas to separate the numbers, or if I first set the value in the variable as you say, but for example #ITEMFRAMEROTATE, that has a string argument before the numbers only works setting the variables beforehand. Simply separating the numbers with commas produces an error.

Command that works:

/trg run x=-14343;y=82;z=-1716;#WORLD:ITEMFRAMEROTATE "FLIPPED" x y z

Command that doesn't work:

/trg run #WORLD:ITEMFRAMEROTATE "FLIPPED" -14343,82,-1716

Error:

io.github.wysohn.triggerreactor.core.script.interpreter.InterpreterException: Error occured while processing Node [type: OPERATOR_A, value: '-'] {([type: STRING, value: 'FLIPPED']) ([type: INTEGER, value: '14343']) }
at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:598)
at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.start(Interpreter.java:267)
at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.start(Interpreter.java:263)
at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.startWithContextAndInterrupter(Interpreter.java:141)
at io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager$Trigger.start(AbstractTriggerManager.java:217)
at io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager$Trigger$1.run(AbstractTriggerManager.java:202)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at io.github.wysohn.triggerreactor.core.script.Token.toDouble(Token.java:69)
at io.github.wysohn.triggerreactor.core.script.interpreter.Interpreter.interpret(Interpreter.java:361)
... 6 more

The executor doesn't even start, doesn't even process the first sentence.
Not beeing able to use negative numbers seamlessly like positive ones is not very user friendly. Can something be done in the parser for it to recognize unary minus?
Thank you.

from triggerreactor.

wysohn avatar wysohn commented on June 18, 2024

But it's definitely not a good practice to combine both space and comma as it just looks confusing.

I would suggest you to go like this:

/trg run #WORLD:ITEMFRAMEROTATE "FLIPPED", -14343, 82, -1716

The error is basically complaining that it is trying to convert "FLIPPED" into number in order to work on the subtraction, but it couldn't as "FLIPPED" is not number at all.

Obviously, you can assume that it thinks it has to subtract 14343 from "FLIPPED" not thinking it as parameter.

Minus is trouble maker for sure, but there is no better way to distinguish between subtraction and unary minus for those cases.

from triggerreactor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.