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

blade8895

Members
  • Content Count

    1
  • Joined

  • Last visited

Posts posted by blade8895

  1. Hi,

    i tried to program a simply UI Design with Heat informations of a Fluid Reactor and a simple Toggle on/off function.
    but i had some problems with the refresh of the Heat display when i want the userinput. I Tried already with a thread and a new function the get the heat. but the mainprogram will still hold while it awaits the input.

    and when it will easier to program i normally dont want an "Input" field normaly i dont want to display the userinput and simply toggle a redstone state from 15 to 0 and backwards by simply pressing the button (number on keyboard) but i dont know to do that :D

    if anyone of you had an idea to fix that or improve that i am glad to hear from it!

    my code i wrote on my own attempt.. connections to the Reactor made via an Adapter and a Redstone Port

    -- Include
    
    local term = require("term")
    local component = require("component")
    local sides = require("sides")
    local event = require("event")
    local thread = require("thread")
    
    -- Variable
    local r1 = 0
    local build = "0910190124"
    local vers = "0.0.2"
    local rsget = component.redstone.getOutput(sides.west)
    
    -- Boot-UP
    term.clear()
    print("Reactor Control")
    print("Build: "..build.." Version:"..vers)
    print("made by Blade")
    
    -- function Reactor status
    local function status1()
     if rsget == 15 then
      local r1 = 1
      return "Online!"
     else
      local r1 = 0
      return "Offline!"
     end
    end
    
    -- Script
    print("Reaktor Status beim boot:")
    term.setCursor(27,4)
    print(status1())
    os.sleep(5)
    
    -- UI Design
    term.setCursor(1,1)
    term.clear()
    print("|================================================|")
    print("|                                                |")
    print("| Status der Reaktoren:                          |")
    print("| Reactor-1:                                     |")
    print("| Reactor-2:                                     |")
    print("| Reactor-3:                                     |")
    print("| Reactor-4:                                     |")
    print("| Reactor-5:                                     |")
    print("| Reactor-6:                                     |")
    print("|                                                |")
    print("|------------------------------------------------|")
    print("| [1-6] Toggle Reactor  |  [9] Exit Program      |")
    print("|------------------------------------------------|")
    print("| Input:                                         |")
    print("|================================================|")
    
    term.setCursor(14,4)
    print(status1())
    os.sleep(5)
    
    local function heatget()
     while true do
      heat = component.reactor_redstone_port.getHeat()
      maxheat = component.reactor_redstone_port.getMaxHeat()
      term.setCursor(25,4)
      print("Heat: "..heat.." / "..maxheat)
     end
    end
    
    -- user input inclusive heat refresh
     thread.create(heatget())
      while true do
       event.pull()
       local userInput = io.read()
      end

     

    thanks for the pataince and help :D

    ~ Blade8895

    ps. i know my english is garbage but i try my best ;P

×
×
  • Create New...

Important Information

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