And why not also support other types? There is nothing lost in conversion int -> long -> double.
Dne úterý, 22. dubna 2014 22:16:28 UTC+2 Jason Bertsche napsal(a): > NetLogo numbers must always be doubles, because much of the NetLogo > > internals assumes as much. If that assumption isn't met, bad things > > will happen. Fortunately, it's pretty easy to always just give NetLogo > > doubles. > > > > On 4/22/2014 3:12 PM, [email protected] wrote: > > > Hi, I' trying to pass number (int or long) from java etension as an > > argument to task but have some issues with it. I tried both int and long > > and got two different errors. When I cast the int/long into double then it > > works. > > > > > > long: > > > ```java > > > class Callbacks$Actuators{ > > > public void attack(long id) { > > > attack.perform(ctx, new Object[] {id}); > > > } > > > } > > > ``` > > > ``` > > > let tattack task [ > > > let cislo int ?1 > > > ] > > > ``` > > > ``` > > > INT expected input to be a number but got the number <Long> instead. > > > error while zombie 85 running INT > > > called by (command task from: procedure SETUP) > > > called by procedure STEP > > > called by Button 'Step' > > > ``` > > > > > > int: > > > ```java > > > class Callbacks$Actuators{ > > > public void attack(int id) { > > > attack.perform(ctx, new Object[] {id}); > > > } > > > } > > > ``` > > > ``` > > > to step > > > gbui:tick > > > ask humans [ gbui:ai-perform ] > > > ask zombies [ gbui:ai-perform ] > > > decay > > > reap > > > tick > > > end > > > ``` > > > ``` > > > error (RuntimeException) > > > while observer running ASK > > > called by procedure STEP > > > called by Button 'Step' > > > > > > NetLogo is unable to supply you with more details about this error. Please > > report the problem > > > at https://github.com/NetLogo/NetLogo/issues, or to > > [email protected], and paste the > > > contents of this window into your report. > > > > > > java.lang.RuntimeException: java.lang.Integer: 7 > > > at scala.sys.package$.error(package.scala:27) > > > at org.nlogo.api.Dump$.logoObject(Dump.scala:43) > > > at org.nlogo.api.Dump.logoObject(Dump.scala) > > > at > > org.nlogo.nvm.ArgumentTypeException.getMessage(ArgumentTypeException.java:47) > > > at > > org.nlogo.nvm.StackTraceBuilder$$anonfun$1.apply(StackTraceBuilder.scala:35) > > > at > > org.nlogo.nvm.StackTraceBuilder$$anonfun$1.apply(StackTraceBuilder.scala:33) > > > at scala.Option.map(Option.scala:133) > > > at org.nlogo.nvm.StackTraceBuilder$.build(StackTraceBuilder.scala:33) > > > at org.nlogo.nvm.StackTraceBuilder.build(StackTraceBuilder.scala) > > > at org.nlogo.nvm.Context.buildRuntimeErrorMessage(Context.java:349) > > > at org.nlogo.nvm.EngineException.fillInStackTrace(EngineException.java:83) > > > at org.nlogo.nvm.CommandTask.perform(Task.scala:87) > > > at org.nlogo.nvm.CommandTask.perform(Task.scala:69) > > > at eu.janinko.etsza.ai.Callbacks$Actuators.attack(Callbacks.java:114) > > > at eu.janinko.etsza.ai.agents.Zombie.act(Zombie.java:65) > > > at eu.janinko.etsza.ai.agents.Zombie.perform(Zombie.java:46) > > > at eu.janinko.etsza.primitives.AIPerform.perform(AIPerform.java:35) > > > at org.nlogo.prim._extern.perform(_extern.java:54) > > > at org.nlogo.nvm.Context.runExclusive(Context.java:119) > > > at org.nlogo.nvm.ExclusiveJob.run(ExclusiveJob.java:57) > > > at org.nlogo.nvm.Context.runExclusiveJob(Context.java:162) > > > at org.nlogo.prim._asm_procedurestep_ask_2.perform(:1) > > > at org.nlogo.nvm.Context.stepConcurrent(Context.java:91) > > > at org.nlogo.nvm.ConcurrentJob.step(ConcurrentJob.java:82) > > > at > > org.nlogo.job.JobThread.org$nlogo$job$JobThread$$runPrimaryJobs(JobThread.scala:143) > > > at org.nlogo.job.JobThread$$anonfun$run$1.apply$mcV$sp(JobThread.scala:78) > > > at org.nlogo.job.JobThread$$anonfun$run$1.apply(JobThread.scala:76) > > > at org.nlogo.job.JobThread$$anonfun$run$1.apply(JobThread.scala:76) > > > at scala.util.control.Exception$Catch.apply(Exception.scala:88) > > > at org.nlogo.util.Exceptions$.handling(Exceptions.scala:41) > > > at org.nlogo.job.JobThread.run(JobThread.scala:75) > > > ``` > > > -- You received this message because you are subscribed to the Google Groups "netlogo-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
