Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
howardivanbaltazar

"Parallelized" if statements

Recommended Posts

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.