howardivanbaltazar 2 Posted June 15, 2019 Share Posted June 15, 2019 if x<5 then x = x+1 else x = 0 end if y<5 then y = y+1 else y = 0 end in this commands how can i make them work in parallel or in the same time? Quote Link to post Share on other sites
Molinko 43 Posted June 15, 2019 Share Posted June 15, 2019 If you could post all the code or explain what you're trying to do a bit more that would help me help you. Lua is single threaded so there isn't any real parallelization, so I'm having a hard time understanding what you need. Quote Link to post Share on other sites
payonel 21 Posted June 15, 2019 Share Posted June 15, 2019 like molinko said, we dont have parallel execution, but we do have concurrency. https://ocdoc.cil.li/api:thread Quote Link to post Share on other sites
howardivanbaltazar 2 Posted June 16, 2019 Author Share Posted June 16, 2019 I would like to execute both if statements in the same time so that it can light up both redstone lamp at the same time I would like to execute both if statements in the same time so that it can light up both redstone lamp at the same time Quote Link to post Share on other sites
Molinko 43 Posted June 16, 2019 Share Posted June 16, 2019 It's not possible. You can set them one after the other, sequentially, fast enough that you won't notice. Effectively at the same time.. but parallelization is not possible Quote Link to post Share on other sites
tromp_ 0 Posted May 22, 2022 Share Posted May 22, 2022 On 6/16/2019 at 5:03 PM, howardivanbaltazar said: I would like to execute both if statements in the same time so that it can light up both redstone lamp at the same time I would like to execute both if statements in the same time so that it can light up both redstone lamp at the same time What you can do is perform all the calculations and then after computing the desired redstone states, you can then update all the states local states = {} -- Compute all your conditions and store the resulting state for future use if states.x < 5 then states.x = states.x + 1 else states.x = 0 end if states.y < 5 then states.y = states.y + 1 else states.y = 0 end Then you would just use something like component.redstone.setOutput(states) and this would then push your state to a redstone card. Please note that the above code will not work as setOutput expects a numerical index rather than "x" or "y". If your using bundled you would need to adjust it as required. Though I dont understand how this is an issue for you as you can call 20 component functions per game tick (or so i think, based of an answer I recieved when asking if you could use multiple GPUs to speed up rendering to a single screen) Edit 1: Fixed Typo Quote Link to post Share on other sites