Hi all! I'm new to this amazing simulator and i have a pretty newbie question to ask:
how can i define (then call) my own Lua functions in a child script?
"-- DO NOT WRITE CODE OUTSIDE OF THE if-then-end SECTIONS BELOW!!" blocked me :(
TIA,
Nicola.
Function definition in child script
Re: Function definition in child script
Hello Nicola,
actually you can write code outside of the mentioned section, as long as the code represents a function.
So following is a valid child script:
Cheers
actually you can write code outside of the mentioned section, as long as the code represents a function.
So following is a valid child script:
Code: Select all
myFunction=function(a,b)
return a+b
end
if (sim_call_type==sim_childscriptcall_initialization) then
end
if (sim_call_type==sim_childscriptcall_actuation) then
print(myFunction(1,2))
end
if (sim_call_type==sim_childscriptcall_sensing) then
end
if (sim_call_type==sim_childscriptcall_cleanup) then
end
-
- Posts: 3
- Joined: 13 Jan 2015, 11:10
Re: Function definition in child script
Thanks! ;)