{"events":[],"handlers":[{"code":"Script.system:update()","filter":{"args":[],"signature":"onUpdate()","slotKey":"-4"},"key":"10"},{"code":"Script.system:inputText(text)","filter":{"args":[{"variable":"*"}],"signature":"onInputText(text)","slotKey":"-4"},"key":"11"},{"code":"Script.system:flush()","filter":{"args":[],"signature":"onFlush()","slotKey":"-4"},"key":"12"},{"code":"Script.system:actionStop(action)","filter":{"args":[{"variable":"*"}],"signature":"onActionStop(action)","slotKey":"-4"},"key":"13"},{"code":"Script.system:actionStart(action)","filter":{"args":[{"variable":"*"}],"signature":"onActionStart(action)","slotKey":"-4"},"key":"14"},{"code":"Script.system:actionLoop(action)","filter":{"args":[{"variable":"*"}],"signature":"onActionLoop(action)","slotKey":"-4"},"key":"15"},{"code":"Script.player:parentChanged(oldId, newId)","filter":{"args":[{"variable":"*"},{"variable":"*"}],"signature":"onParentChanged(oldId,newId)","slotKey":"-3"},"key":"3"},{"code":"Script.construct:VRStationEntered(id)","filter":{"args":[{"variable":"*"}],"signature":"onVRStationEntered(id)","slotKey":"-2"},"key":"6"},{"code":"Script.construct:undocked(id)","filter":{"args":[{"variable":"*"}],"signature":"onUndocked(id)","slotKey":"-2"},"key":"8"},{"code":"Script.construct:PvPTimer(active)","filter":{"args":[{"variable":"*"}],"signature":"onPvPTimer(active)","slotKey":"-2"},"key":"4"},{"code":"Script.construct:playerBoarded(id)","filter":{"args":[{"variable":"*"}],"signature":"onPlayerBoarded(id)","slotKey":"-2"},"key":"7"},{"code":"Script.construct:constructDocked(id)","filter":{"args":[{"variable":"*"}],"signature":"onConstructDocked(id)","slotKey":"-2"},"key":"5"},{"code":"Script.unit:timer(tag)","filter":{"args":[{"variable":"*"}],"signature":"onTimer(tag)","slotKey":"-1"},"key":"1"},{"code":"Script.unit:stop()","filter":{"args":[],"signature":"onStop()","slotKey":"-1"},"key":"2"},{"code":"--[[\r\n DU-LUA-Framework by Jericho\r\n Permit to code easier by grouping most of the code in a single event Unit > Start\r\n Unminified Source available here: https://github.com/Jericho1060/du-lua-framework\r\n]]--\r\nlocal a=system.print;local b=error;local c=pcall;local d=assert;local e=coroutine;local f=e.create;local g=e.status;local h=e.resume;local i=\"dead\"local j=\"suspended\"function runFunction(k,l,...)local m,n=c(k,...)if not m then b(l..n)end end;local o={__index={cos={update={},flush={}},fns={update={},flush={},action={start={},stop={},loop={}},inputText=nil,start=nil,stop=nil},ACTIONS={FORWARD=\"forward\",BACKWARD=\"backward\",YAW_LEFT=\"yawleft\",YAW_RIGHT=\"yawright\",STRAFE_LEFT=\"strafeleft\",STRAFE_RIGHT=\"straferight\",LEFT=\"left\",RIGHT=\"right\",UP=\"up\",DOWN=\"down\",GROUND_ALTITUDE_UP=\"groundaltitudeup\",GROUND_ALTITUDE_DOWN=\"groundaltitudedown\",LEFT_ALT=\"lalt\",LEFT_SHIFT=\"lshift\",GEAR=\"gear\",LIGHT=\"light\",BRAKE=\"brake\",OPTION_1=\"option1\",OPTION_2=\"option2\",OPTION_3=\"option3\",OPTION_4=\"option4\",OPTION_5=\"option5\",OPTION_6=\"option6\",OPTION_7=\"option7\",OPTION_8=\"option8\",OPTION_9=\"option9\",OPTION_10=\"option10\",OPTION_11=\"option11\",OPTION_12=\"option12\",OPTION_13=\"option13\",OPTION_14=\"option14\",OPTION_15=\"option15\",OPTION_16=\"option16\",OPTION_17=\"option17\",OPTION_18=\"option18\",OPTION_19=\"option19\",OPTION_20=\"option20\",OPTION_21=\"option21\",OPTION_22=\"option22\",OPTION_23=\"option23\",OPTION_24=\"option24\",OPTION_25=\"option25\",OPTION_26=\"option26\",OPTION_27=\"option27\",OPTION_28=\"option28\",OPTION_29=\"option29\",LEFT_MOUSE=\"leftmouse\",STOP_ENGINES=\"stopengines\",SPEED_UP=\"speedup\",SPEED_DOWN=\"speeddown\",ANTIGRAVITY=\"antigravity\",BOOSTER=\"booster\"},main={update=f(function()end),flush=f(function()end)},update=function(self)local p=g(self.main.update)if p==i then self.main.update=f(function()self:runUpdate()end)elseif p==j then d(h(self.main.update))end end,flush=function(self)local p=g(self.main.flush)if p==i then self.main.flush=f(function()self:runFlush()end)elseif p==j then d(h(self.main.flush))end end,action=function(self,q,r)if self.fns.action[q][r]then runFunction(self.fns.action[q][r],\"System Action \"..q..\" Error: \")end end,actionStart=function(self,r)self:action('start',r)end,actionStop=function(self,r)self:action('stop',r)end,actionLoop=function(self,r)self:action('loop',r)end,inputText=function(self,s)if self.fns.inputText then runFunction(self.fns.inputText,\"System Input Text Error: \",s)end end,runUpdate=function(self)for t,u in pairs(self.cos.update)do local m=g(u)if m==i then self.cos.update[t]=f(self.fns.update[t])elseif m==j then d(h(u))end end end,runFlush=function(self)for t,u in pairs(self.cos.flush)do local m=g(u)if m==i then self.cos.flush[t]=f(self.fns.flush[t])elseif m==j then d(h(u))end end end,onUpdate=function(self,v)for t,w in pairs(v)do self.fns.update[t]=w;self.cos.update[t]=f(w)end end,onFlush=function(self,v)for t,w in pairs(v)do self.fns.flush[t]=w;self.cos.flush[t]=f(w)end end,onAction=function(self,q,v)for t,w in pairs(v)do self.fns.action[q][t]=w end end,onActionStart=function(self,v)self:onAction(\"start\",v)end,onActionStop=function(self,v)self:onAction(\"stop\",v)end,onActionLoop=function(self,v)self:onAction(\"loop\",v)end,onInputText=function(self,k)self.fns.inputText=k end}}local x={__index={timers={},stopFn=function()end,timer=function(self,y)if self.timers[y]then runFunction(self.timers[y],\"Unit Timer \"..y..\" Error: \")end end,setTimer=function(self,y,z,k)self.timers[y]=k;unit.setTimer(y,z)end,stopTimer=function(self,y)unit.stopTimer(y)self.timers[y]=nil end,onStop=function(self,k)self.stopFn=k end,stop=function(self)if self.stopFn then runFunction(self.stopFn,\"Unit Stop Error: \")end end}}local A={__index={parentChangedFn=function(B,C)end,onParentChange=function(self,k)self.parentChangedFn=k end,parentChanged=function(self,B,C)if self.parentChangedFn then runFunction(self.parentChangedFn,\"Player Parent Changed Error: \",B,C)end end}}local D={__index={dockedFn=function(E)end,onDocked=function(self,k)self.dockedFn=k end,docked=function(self,E)if self.dockedFn then runFunction(self.dockedFn,\"Construct Docked Error: \",E)end end,undockedFn=function(E)end,onUndocked=function(self,k)self.undockedFn=k end,undocked=function(self,E)if self.undockedFn then runFunction(self.undockedFn,\"Construct Undocked Error: \",E)end end,playerBoardedFn=function(E)end,onPlayerBoarded=function(self,k)self.playerBoardedFn=k end,playerBoarded=function(self,E)if self.playerBoardedFn then runFunction(self.playerBoardedFn,\"Construct Player Boarded Error: \",E)end end,VRStationEnteredFn=function(E)end,onVRStationEntered=function(self,k)self.VRStationEnteredFn=k end,VRStationEntered=function(self,E)if self.VRStationEnteredFn then runFunction(self.VRStationEnteredFn,\"Construct VR Station Entered Error: \",E)end end,constructDockedFn=function(E)end,onConstructDocked=function(self,k)self.constructDockedFn=k end,constructDocked=function(self,E)if self.constructDockedFn then runFunction(self.constructDockedFn,\"Construct Construct Docked Error: \",E)end end,PvPTimerFn=function(F)end,onPvPTimer=function(self,k)self.PvPTimerFn=k end,PvPTimer=function(self,F)if self.PvPTimerFn then runFunction(self.PvPTimerFn,\"Construct PvP Timer Error: \",F)end end}}DU_Framework={__index={system=setmetatable({},o),unit=setmetatable({},x),player=setmetatable({},A),construct=setmetatable({},D)}}\r\n\r\nScript = {}\r\nsetmetatable(Script, DU_Framework)\r\n\r\n\r\n--[[\r\n You can declare here all the functions you want to call in the diffent events from system, unit, player and construct.\r\n Major changes compared to the base game concept:\r\n - System onUpdate and onFlush events are now built with coroutines, in the framework, onUpdate and onFlush are loading a table of functions that will be runned as coroutines. This way you can have multiple functions running at the same time, and you use the yield function to pause the coroutine and let the other coroutines run. Each coroutine will be resume or restarted if dead each time the system onUpdate or onFlush event is called.\r\n\r\n]]\r\n\r\n-- System > onUpdate and onFlush\r\n\r\n--Functions to load as coroutines that will be runned in system > onUpdate (based on FPS)\r\nlocal system_update = {}\r\nsystem_update.co1 = function ()\r\n for i=0, 10 do\r\n system.print(\"coroutine 1 --- update --- \"..i)\r\n coroutine.yield() -- pause the coroutine 1, it will wait till the next onUpdate event to be resumed\r\n end\r\nend\r\nsystem_update.co2 = function ()\r\n for i=0, 10 do\r\n system.print(\"coroutine 2 --- update --- \"..i)\r\n coroutine.yield() -- pause the coroutine 2, it will wait till the next onUpdate event to be resumed\r\n end\r\nend\r\n\r\nScript.system:onUpdate(system_update) --loading coroutines for system > onUpdate\r\n\r\n--Functions to load as coroutines that will be runned in system > onFlush (60 times / s)\r\nlocal system_flush = {}\r\nsystem_flush.co1 = function ()\r\n for i=0, 10 do\r\n system.print(\"coroutine 1 --- flush --- \"..i)\r\n coroutine.yield() -- pause the coroutine 1, it will wait till the next onFlush event to be resumed\r\n end\r\nend\r\nsystem_flush.co2 = function ()\r\n for i=0, 10 do\r\n system.print(\"coroutine 2 --- flush --- \"..i)\r\n coroutine.yield() -- pause the coroutine 2, it will wait till the next onFlush event to be resumed\r\n end\r\nend\r\n\r\nScript.system:onFlush(system_flush) --loading coroutines for system > onFlush\r\n\r\n\r\n\r\n-- System > onActionStart, onActionStop and onActionLoop\r\n\r\n--Function to run on actions\r\nlocal system_action_start = {}\r\nsystem_action_start[Script.system.ACTIONS.BRAKE] = function()\r\n system.print(\"I'm braking\");\r\nend\r\nScript.system:onActionStart(system_action_start) --loading all \"actionStart\" functions\r\n\r\nlocal system_action_stop = {}\r\nsystem_action_stop[Script.system.ACTIONS.BRAKE] = function()\r\n system.print(\"I stopped braking\");\r\nend\r\nScript.system:onActionStop(system_action_stop) --loading all \"actionStop\" functions\r\n\r\nlocal system_action_loop = {}\r\nsystem_action_loop[Script.system.ACTIONS.BRAKE] = function()\r\n system.print(\"I'm still braking\");\r\nend\r\nScript.system:onActionLoop(system_action_loop) --loading all \"actionLoop\" functions\r\n\r\n\r\n-- System > onInputText\r\n\r\n--Function to run when input text to the lua chat\r\nScript.system:onInputText(function (text)\r\n system.print(\"Input: \" .. text)\r\nend)\r\n\r\n\r\n-- unit > onStop\r\n\r\n--Function to run when the program is stopping\r\nScript.unit:onStop(function()\r\n system.print(\"Program is stopping\")\r\nend)\r\n\r\n\r\n\r\n-- unit > Timers\r\n\r\n--[[\r\n Here how to add a timer\r\n @param name: the name of the timer, used to remove it with Script.unit:stopTimer(name)\r\n @param delay: the delay between each call of the function in seconds\r\n @param func: the function to call\r\n]]\r\nScript.unit:setTimer(\"hello\", 1, function()system.print(\"hello\")end) --add a timer displaying \"hello\" every seconds\r\nScript.unit:setTimer(\"hello5\", 5, function()system.print(\"hello 5\")end) --add a timer displaying \"hello 5\" every 5 seconds\r\n\r\nScript.unit:stopTimer(\"hello\") --stop the timer \"hello\"\r\n\r\n\r\n\r\n-- player > onParentChanged\r\n\r\n--Function to run when the player change parent\r\nScript.player:onParentChanged(function (oldParent, newParent)\r\n system.print(\"Player changed parent from ID \"..oldParent..\" to ID \"..newParent)\r\nend)\r\n\r\n\r\n\r\n-- construct events\r\n\r\n--Function to run when the construct is docked or undocked\r\nScript.construct:onDocked(function(id)\r\n system.print(\"Construct docked on ID \"..id)\r\nend)\r\nScript.construct:onUndocked(function(id)\r\n system.print(\"Construct undocked from ID \"..id)\r\nend)\r\n\r\n--Function to run when a player board the construct\r\nScript.construct:onPlayerBoarded(function(id)\r\n system.print(\"Player with ID \" .. id .. \" boarded construct\")\r\nend)\r\n\r\n--Function to run when a player enter the VR Station\r\nScript.construct:onVRStationEntered(function(id)\r\n system.print(\"Player with ID \" .. id .. \" entered VR Station\")\r\nend)\r\n\r\n--Function to run when another construct is docked on this construct\r\nScript.construct:onConstructDocked(function(id)\r\n system.print(\"Construct with ID \" .. id .. \" docked on this construct\")\r\nend)\r\n\r\n--Function to run when pvp timer is changing state\r\nScript.construct:onPvPTimer(function(active)\r\n if active then\r\n system.print(\"PVP is now active\")\r\n else\r\n system.print(\"PVP is now inactive\")\r\n end\r\nend)","filter":{"args":[],"signature":"onStart()","slotKey":"-1"},"key":"0"}],"methods":[],"slots":{"0":{"name":"slot1","type":{"events":[],"methods":[]}},"1":{"name":"slot2","type":{"events":[],"methods":[]}},"2":{"name":"slot3","type":{"events":[],"methods":[]}},"3":{"name":"slot4","type":{"events":[],"methods":[]}},"4":{"name":"slot5","type":{"events":[],"methods":[]}},"5":{"name":"slot6","type":{"events":[],"methods":[]}},"6":{"name":"slot7","type":{"events":[],"methods":[]}},"7":{"name":"slot8","type":{"events":[],"methods":[]}},"8":{"name":"slot9","type":{"events":[],"methods":[]}},"9":{"name":"slot10","type":{"events":[],"methods":[]}},"-5":{"name":"library","type":{"events":[],"methods":[]}},"-4":{"name":"system","type":{"events":[],"methods":[]}},"-3":{"name":"player","type":{"events":[],"methods":[]}},"-2":{"name":"construct","type":{"events":[],"methods":[]}},"-1":{"name":"unit","type":{"events":[],"methods":[]}}}}