[READ-ONLY] Mirror of https://github.com/thoda-dev/du-nested-coroutines. A small script for DU to avoid any CPU load error
0

Configure Feed

Select the types of activity you want to include in your feed.

new lua events

Thomas (Jul 25, 2022, 4:46 PM +0200) b0df2645 470e7de0

+1 -117
Source/system/update.lua Source/system/onUpdate.lua
Source/unit/start.lua Source/unit/onStart.lua
+1 -117
config.json
··· 1 - { 2 - "slots": { 3 - "0": { 4 - "name": "slot1", 5 - "type": { 6 - "events": [], 7 - "methods": [] 8 - } 9 - }, 10 - "1": { 11 - "name": "slot2", 12 - "type": { 13 - "events": [], 14 - "methods": [] 15 - } 16 - }, 17 - "2": { 18 - "name": "slot3", 19 - "type": { 20 - "events": [], 21 - "methods": [] 22 - } 23 - }, 24 - "3": { 25 - "name": "slot4", 26 - "type": { 27 - "events": [], 28 - "methods": [] 29 - } 30 - }, 31 - "4": { 32 - "name": "slot5", 33 - "type": { 34 - "events": [], 35 - "methods": [] 36 - } 37 - }, 38 - "5": { 39 - "name": "slot6", 40 - "type": { 41 - "events": [], 42 - "methods": [] 43 - } 44 - }, 45 - "6": { 46 - "name": "slot7", 47 - "type": { 48 - "events": [], 49 - "methods": [] 50 - } 51 - }, 52 - "7": { 53 - "name": "slot8", 54 - "type": { 55 - "events": [], 56 - "methods": [] 57 - } 58 - }, 59 - "8": { 60 - "name": "slot9", 61 - "type": { 62 - "events": [], 63 - "methods": [] 64 - } 65 - }, 66 - "9": { 67 - "name": "slot10", 68 - "type": { 69 - "events": [], 70 - "methods": [] 71 - } 72 - }, 73 - "-1": { 74 - "name": "unit", 75 - "type": { 76 - "events": [], 77 - "methods": [] 78 - } 79 - }, 80 - "-2": { 81 - "name": "system", 82 - "type": { 83 - "events": [], 84 - "methods": [] 85 - } 86 - }, 87 - "-3": { 88 - "name": "library", 89 - "type": { 90 - "events": [], 91 - "methods": [] 92 - } 93 - } 94 - }, 95 - "handlers": [ 96 - { 97 - "code": "--[[\n DU-Nested-Coroutines by Jericho\n Permit to easier avoid CPU Load Errors\n Source available here: https://github.com/Jericho1060/du-nested-coroutines\n]]--\n\ncoroutinesTable = {}\n--all functions here will become a coroutine\nMyCoroutines = {\n function()\n for i=0, 10 do\n system.print(\"function 1 --- \"..i)\n coroutine.yield(coroutinesTable[1])--start with index 1 and so on\n end\n end,\n function()\n for i=0, 10 do\n system.print(\"function 2 --- \"..i)\n coroutine.yield(coroutinesTable[2])--the second fonction yiel is with index 2\n end\n end\n}\n\nfunction initCoroutines()\n for _,f in pairs(MyCoroutines) do\n local co = coroutine.create(f)\n table.insert(coroutinesTable, co)\n end\nend\n\ninitCoroutines()\n\nrunCoroutines = function()\n for i,co in ipairs(coroutinesTable) do\n if coroutine.status(co) == \"dead\" then\n coroutinesTable[i] = coroutine.create(MyCoroutines[i])\n end\n if coroutine.status(co) == \"suspended\" then\n assert(coroutine.resume(co))\n end\n end\nend\n\nMainCoroutine = coroutine.create(runCoroutines)", 98 - "filter": { 99 - "args": [], 100 - "signature": "start()", 101 - "slotKey": "-1" 102 - }, 103 - "key": "0" 104 - }, 105 - { 106 - "code": "--[[\n DU-Nested-Coroutines by Jericho\n Permit to easier avoid CPU Load Errors\n Source available here: https://github.com/Jericho1060/du-nested-coroutines\n]]--\n\nif coroutine.status(MainCoroutine) == \"dead\" then\n MainCoroutine = coroutine.create(runCoroutines)\nend\nif coroutine.status(MainCoroutine) == \"suspended\" then\n assert(coroutine.resume(MainCoroutine))\nend", 107 - "filter": { 108 - "args": [], 109 - "signature": "update()", 110 - "slotKey": "-2" 111 - }, 112 - "key": "1" 113 - } 114 - ], 115 - "methods": [], 116 - "events": [] 117 - } 1 + {"events":[],"handlers":[{"code":"--[[\n DU-Nested-Coroutines by Jericho\n Permit to easier avoid CPU Load Errors\n Source available here: https://github.com/Jericho1060/du-nested-coroutines\n]]--\n\nif coroutine.status(MainCoroutine) == \"dead\" then\n MainCoroutine = coroutine.create(runCoroutines)\nend\nif coroutine.status(MainCoroutine) == \"suspended\" then\n assert(coroutine.resume(MainCoroutine))\nend","filter":{"args":[],"signature":"onUpdate()","slotKey":"-4"},"key":"1"},{"code":"--[[\n DU-Nested-Coroutines by Jericho\n Permit to easier avoid CPU Load Errors\n Source available here: https://github.com/Jericho1060/du-nested-coroutines\n]]--\n\ncoroutinesTable = {}\n--all functions here will become a coroutine\nMyCoroutines = {\n function()\n for i=0, 10 do\n system.print(\"function 1 --- \"..i)\n coroutine.yield(coroutinesTable[1])--start with index 1 and so on\n end\n end,\n function()\n for i=0, 10 do\n system.print(\"function 2 --- \"..i)\n coroutine.yield(coroutinesTable[2])--the second fonction yiel is with index 2\n end\n end\n}\n\nfunction initCoroutines()\n for _,f in pairs(MyCoroutines) do\n local co = coroutine.create(f)\n table.insert(coroutinesTable, co)\n end\nend\n\ninitCoroutines()\n\nrunCoroutines = function()\n for i,co in ipairs(coroutinesTable) do\n if coroutine.status(co) == \"dead\" then\n coroutinesTable[i] = coroutine.create(MyCoroutines[i])\n end\n if coroutine.status(co) == \"suspended\" then\n assert(coroutine.resume(co))\n end\n end\nend\n\nMainCoroutine = coroutine.create(runCoroutines)","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":[]}}}}