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

sshika

Members
  • Content Count

    41
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by sshika

  1. this is the complet program :

    local term = require("term")
    local shell = require("shell") 
    local component = require("component")
    local computer = require("computer")
    local math = require("math")
    local event = require("event")
    local string = require("string")
    local unicode = require("unicode")
    local serialisation = require("serialization")
    local colors = require("colors")
    local sides = require("sides")
    local os = require("os") 
    --local rs = component.redstone
    local gpu = component.gpu
    component.gpu.setResolution(100,50)
    
    br = component.getPrimary("br_reactor")
    nbrrod = br.getNumberOfControlRods()
    local i = 1
    local rods = {}
    local boucle2 = true
    
    local function setColor(bg,fg)
      gpu.setBackground(bg)
      gpu.setForeground(fg)
    end
    
    local function loadbar(x,y,width,cur,text,bg)
      local raw = " " .. text ..string.rep(" ", width - unicode.len(text) - 2) .. " "
      local oldbg = gpu.setBackground(bg)
      local oldfg = gpu.setForeground(0xFFFFFF - bg)
      gpu.set(x,y,unicode.sub(raw,1,cur))
      gpu.setBackground(oldbg)
      gpu.setForeground(oldfg)
      gpu.set(x+cur,y,unicode.sub(raw,cur+1,width))
    end 
    
    local function loadbarv(x,y,cur,height,col,text)
      local top = i, y
      local left = height
      for i = left, 0, -1 do
        if i <= cur then
          color = col
        else
          color = 0x0
        end
    	j = -i + height + y
        gpu.setBackground(color)
        gpu.set(x,j,text)
        gpu.setBackground(0x0)
      end
    end
    
    local function hexa(dec)
    local B,K,OUT,I,D = 16,"0123456789ABCDEF","",0
      if dec <= 0 then
        OUT = "00"
      elseif dec > 0 and dec < 16 then
        D = dec + 1
        OUT = "0"..string.sub(K,D,D)
      elseif dec > 16 and dec < 256 then
        V1 = math.modf(dec/B)+1
        V2 = dec-V1*16
        OUT = string.sub(K,V1,V1)..string.sub(K,V2,V2)
      elseif dec >= 255 then
        OUT = "FF"
      end
      return OUT
    end
    
    local function round(num, dec)
      local mult = 10 ^ (dec or 0)
      return math.floor(num * mult + 0.5) / mult
    end
    
    local function rod(x,y,n)
      lvl = br.getControlRodLevel(n-1)
      rouge = math.floor((100-lvl)*255/50)
      vert = math.floor(lvl*255/50)
      color = hexa(rouge)..hexa(vert).."00"
      color2 = tonumber(string.format("%6s",color),16)
      setColor(color2,0x0000FF)
      gpu.set(x,y,"█"..string.format("%3s",lvl).."█")
      setColor(0x0, 0xFFFFFF)
    end
    
    local function aff7rod(x,y)
      c = 6.5*y-25
      rod(x,y,c)
      rod(x+6,y,c+1)
      rod(x+12,y,c+2)
      rod(x+18,y,c+3)
      rod(x+24,y,c+4)
      rod(x+30,y,c+5)
      rod(x+36,y,c+6)
    end
    
    local function aff6rod(x,y)
      c = 6.5*y-24.5
      rod(x,y,c)
      rod(x+6,y,c+1)
      rod(x+12,y,c+2)
      rod(x+18,y,c+3)
      rod(x+24,y,c+4)
      rod(x+30,y,c+5)
    end
    
    local function control()
    aff7rod(8,4)
    aff6rod(11,5)
    aff7rod(8,6)
    aff6rod(11,7)
    aff7rod(8,8)
    aff6rod(11,9)
    aff7rod(8,10)
    aff6rod(11,11)
    aff7rod(8,12)
    aff6rod(11,13)
    aff7rod(8,14)
    aff6rod(11,15)
    aff7rod(8,16)
    end
    
    local function manualrod(x,y)
      local rod
      local v1
      local v2
      if y == 4 or y == 6 or y == 8 or y == 10 or y == 12 or y == 14 or y == 16 then
        v1 = (x-4)/6
    	v2 = 6.5*y-25
      elseif y == 5 or y == 7 or y == 9 or y == 11 or y == 13 or y == 15 then
        v1 = (x-7)/6
    	v2 = 6.5*y-24.5
      end
      rod = round(v1,0)+v2-1
      local a = 81
      local b = 1
        gpu.set(a,b,"╦═════════════════╗")
      gpu.set(a,b+1,"║   Profondeur    ║")
      gpu.set(a,b+2,"╠═════════════════╣") 
      gpu.set(a,b+3,"║ Rod n°XX █100█  ║")
      gpu.set(a,b+4,"║                 ║")
      gpu.set(a,b+5,"║  █-10█   █+10█  ║")
      gpu.set(a,b+6,"║                 ║")
      gpu.set(a,b+7,"║  █-1 █   █+1 █  ║")
      gpu.set(a,b+8,"║                 ║")
      gpu.set(a,b+9,"║ ANNULER VALIDER ║")
     gpu.set(a,b+10,"╚═════════════════╣")
      lvl = br.getControlRodLevel(rod-1)
      gpu.set(a+12,b+3,string.format("%3s",lvl))
      gpu.set(a+8,b+3,string.format("%2s",rod))
      print("1")
      local test =0
      while boucle2 == true do
        test = test + 1
        event.listen("touch",onTouch2)
    	gpu.set(a,b+11,string.format("%3s",test))
    
      end
      event.ignore("touch",onTouch2)
      print("a")
      boucle2 = true
      
        gpu.set(a,b,"══════════════════╗")
      gpu.set(a,b+1,"                  ║")
      gpu.set(a,b+2,"                  ║") 
      gpu.set(a,b+3,"                  ║")
      gpu.set(a,b+4,"                  ║")
      gpu.set(a,b+5,"                  ║")
      gpu.set(a,b+6,"                  ║")
      gpu.set(a,b+7,"                  ║")
      gpu.set(a,b+8,"                  ║")
      gpu.set(a,b+9,"                  ║")
     gpu.set(a,b+10,"                  ║")
    
    end
    
    local function onTouch2(_,_,x,y,_,_)
    gpu.set(2,22,"x : "..x.." / y : "..y)
      if x > a+11 and x < a+15 then
        if y == b+5 then
    	  lvl = lvl + 10
    	elseif y == b+7 then
    	  lvl = lvl + 1	  
    	end
    	
      elseif x > a+3 and x < a+7 then
    	if y == b+5 then
    	  lvl = lvl - 10
    	elseif y == b+7 then
    	  lvl = lvl - 1	    
    	end
    	
      elseif y == b+9 and x > a+1 and x < a+9 then
        boucle2 = false
      elseif y == b+9 and x > a+9 and x < a+17 then
        br.setControlRodLevel(rod-1,lvl)
      end
      gpu.set(a+12,b+3,string.format("%3s",lvl))
    	
    end
    
    term.clear()
     gpu.set(1,1,"╔══════════════════════════════════════════════════════════════════════════════════════════════════╗")
     gpu.set(1,2,"║                                                                                                  ║")
     gpu.set(1,3,"║   ███████████████████████████████████████████████                                                ║")
     gpu.set(1,4,"║   ██ █   █ █   █ █   █ █   █ █   █ █   █ █   █ ██                                                ║")
     gpu.set(1,5,"║   ██    █   █ █   █ █   █ █   █ █   █ █   █    ██                                                ║")
     gpu.set(1,6,"║   ██ █   █ █   █ █   █ █   █ █   █ █   █ █   █ ██                                                ║")
     gpu.set(1,7,"║   ██    █   █ █   █ █   █ █   █ █   █ █   █    ██                                                ║")
     gpu.set(1,8,"║   ██ █   █ █   █ █   █ █   █ █   █ █   █ █   █ ██                                                ║")
     gpu.set(1,9,"║   ██    █   █ █   █ █   █ █   █ █   █ █   █    ██                                                ║")
    gpu.set(1,10,"║   ██ █   █ █   █ █   █ █   █ █   █ █   █ █   █ ██                                                ║")
    gpu.set(1,11,"║   ██    █   █ █   █ █   █ █   █ █   █ █   █    ██                                                ║")
    gpu.set(1,12,"║   ██ █   █ █   █ █   █ █   █ █   █ █   █ █   █ ██                                                ║")
    gpu.set(1,13,"║   ██    █   █ █   █ █   █ █   █ █   █ █   █    ██                                                ║")
    gpu.set(1,14,"║   ██ █   █ █   █ █   █ █   █ █   █ █   █ █   █ ██                                                ║")
    gpu.set(1,15,"║   ██    █   █ █   █ █   █ █   █ █   █ █   █    ██                                                ║")
    gpu.set(1,16,"║   ██ █   █ █   █ █   █ █   █ █   █ █   █ █   █ ██                                                ║")
    gpu.set(1,17,"║   ███████████████████████████████████████████████                                                ║")
    gpu.set(1,18,"║                                                                                                  ║")
    gpu.set(1,19,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣")
    gpu.set(1,20,"║                                                                                                  ║")
    gpu.set(1,21,"╠══════════════════════════════════════════════════════════════════════════════════════════════════╣")
    gpu.set(1,22,"║                                                                                                  ║")
    gpu.set(1,23,"║                                                                             ╠════════════════════╣")
    gpu.set(1,24,"║                                                                             ║                    ║")
    gpu.set(1,25,"║                                                                             ║ QUANTITE EN PEPITE ║")
    gpu.set(1,26,"║                                                                             ║            pépite  ║")
    gpu.set(1,27,"║                                                                             ║                    ║")
    gpu.set(1,28,"║                                                                             ╠════════════════════╣")
    gpu.set(1,29,"║                                                                             ║                    ║")
    gpu.set(1,30,"║                                                                             ║                    ║")
    gpu.set(1,31,"║                                                                             ║                    ║")
    gpu.set(1,32,"║                                                                             ║                    ║")
    gpu.set(1,33,"║                                                                             ║                    ║")
    gpu.set(1,34,"║                                                                             ║                    ║")
    gpu.set(1,35,"║                                                                             ║                    ║")
    gpu.set(1,36,"║                                                                             ║                    ║")
    gpu.set(1,37,"╠═════════════════════════════════════════════════════════════════════════════╩════════════════════╣")
    gpu.set(1,38,"║                                                                                                  ║")
    gpu.set(1,39,"║                                                                                                  ║")
    gpu.set(1,40,"║                                                                                                  ║")
    gpu.set(1,41,"║                                                                                                  ║")
    gpu.set(1,42,"║                                                                                                  ║")
    gpu.set(1,43,"║                                                                                                  ║")
    gpu.set(1,44,"║                                                                                                  ║")
    gpu.set(1,45,"║                                                                                                  ║")
    gpu.set(1,46,"║                                                                                                  ║")
    gpu.set(1,47,"║                                                                                                  ║")
    gpu.set(1,48,"║                                                                                                  ║")
    gpu.set(1,49,"║                                                                                                  ║")
    gpu.set(1,50,"╚══════════════════════════════════════════════════════════════════════════════════════════════════╝")
    
    
    local function onTouch(event,adress,x,y,clic,pseudo)
      local tclic
      if clic == 0  then
        tclic = "clic gauche"
      elseif clic == 1 then
        tclic = "Clic droit"
      else
        tclic = "Clic inconnu"
      end
      gpu.set(6,20,tclic.." de la part de "..pseudo.." / X : "..string.format("% 3s",x).." / Y : "..string.format("% 3s",y))
    	if x==1 and y==1 then
          computer.pushSignal("quit")
          term.setCursor(1,1)
          return false
        elseif y > 3 and y < 17 then
    	  if x > 7 and x < 49 then
    	    manualrod(x,y)
    	gpu.set(70,15,x.." / "..y)
    	  end
    	end
    end
    
    local function onTimer(_,timer)
      control()
      return true
    end
    
    event.listen("touch",onTouch)
    local timer = event.timer(0,onTimer,math.huge)
    event.pull("quit")
    event.cancel(timer)
    event.ignore("touch",onTouch)
    component.gpu.setResolution(160,50)
    term.clear()
    
  2. hello,

     

    actually i use a "touch" function for my programs, and I would want to deactivate the first touch function and activate a second with a click in a precise zone, then deactivate the second and reactivate the first function with a click in another zone.

     

    for the click it isn't a problem, but i don't know to activate and deactivate a function in the current program.

     

    for close my program, i use this

    event.ignore("touch",onTouch)
    

    and it work normally, but in the middle of the program, this code doesn't work.

     

    can you help me ?

  3. Hello

     

    I realizes a program to convert decimal in hexa.

    local function hexa(dec)
    local B,K,OUT,I,D = 16,"0123456789ABCDEF","",0
      if dec == 0 then
        OUT = "00"
      elseif dec > 0 and dec < 16 then
        D = dec + 1
        OUT = "0"..string.sub(K,D,D)
      elseif dec > 16 and dec < 256 then
        V1 = math.modf(dec/B)+1
        V2 = (dec-V1*16)
        OUT = string.sub(K,V1,V1)..string.sub(K,V2,V2)
      end
      return OUT
    end
    

    this program convert a lower number in 256, and i use this in a formule

    local function rod(x,y,n)
      lvl = br.getControlRodLevel(n)
      rouge = math.floor((100-lvl)*255/100)
      vert = math.floor(lvl*255/100)
      color = "#"..hexa(rouge)..hexa(vert).."00"
      setColor(color,0x0000FF)
      gpu.set(x,y,"█"..string.format("%3s",lvl).."█")
      setColor(0x0, 0xFFFFFF)
    end
    

    if i print color, i obtain a value "#00FF00" to change color, but the format is not valid. There is a function to change format of this value ?

     

    thank you.

  4. hello, i used a big reactor on my server, and in this reactor, i use 85 rods control system.

     

    OC (with adapter) is able to give me the number of rods in reactor and the level of rod's use, and i wan't to get back this informations of every rod.

    it's possible with a loop to get back and store this information in a table, but i don't know to use it.

  5. Hello

    When i use this upgrade, i need use the carriage return, but i don't no to use it :

    Component = require("component")

    Sides = require("sides")

    Sign = component.getPrimary("sign")

  6. hello

     

    i've a new problem with OC

     

    i want to use gpu.setColor, but there is a problem :

     

    i use this program in lua

     

    local term = require("term")
    local computer = require("computer")
    local component = require("component")
    local gpu = component.gpu
     
    term.clear()
     
    local function setColor(bg,fg)
      gpu.setBackground(bg)
      gpu.setForeground(fg)
    end
     
    setColor(0xFF00FF, 0x00FF00)
    gpu.set(6,7,"test1")
    setColor(0x00FF00, 0xFF00FF)
    gpu.set(6,8,"test2")
    setColor(0x000000, 0xFFFFFF)
     
    and the result 
     

    cn48hgYs.png

     

    "test2" is in the good color (backgournd and foreground, but the "test1" have a good background, but a bad foreground.

     

    can you help me to resolve it ?

     

    thanks

  7. how i use 2 screen in same time ?

    i want to print value in the screen 1, and others value in the screen 2 ?

     

    can you write

     

     

    i use this code

    local component = require("component")
    local gpu = component.gpu
     
    local screen = component.list("screen")
     
    screen1 = component.proxy(screen())
    screen2 = component.proxy(screen())
     
     
    for k,v in pairs(screen1) do print(k,v) end
    for k,v in pairs(screen2) do print(k,v) end
    

     and i can view the adress of each screen but i can't to get back the adress.

     

    and after can i use "gpu.set" to print in the two screens ?

     

    thank you

  8. hello.

    it's possible to add the railcraft steel and iron tank ?

    and the quantum tank of gregtech ?

     

    i want to create an inteface with the levels of oil, fuel, plasma and other liquids, and i need an interraction between adapter and gregtech blocs.

     

    for the IDSU, it's ok, but the tanks  :unsure:

     

  9. sorry

    i'm not explain correctly.

    i would to know if it's praticable to use a graphic interface to control redstone like a tactil screen ?

     

    on the second picture, it's an example of a graphic interface,

     

    and i'm search example of program with graphic interface.

  10. To start, i'm french and it's difficult for me to explain my project.

     

    I have 8 diesel group. they are separated in 2 big system. a system is connected to an IDSU.

     

    ToK5yVx.png

     

     

    Every system send an receive redstone informations by bundle :

      - 2 informations are received (Turn-ON and Turn-OFF)

      - 1 information is send (stat diesel)

      

     If the Turn-OFF information is true, the diesel is turned off. if it's false, the diesel is in automatic.

     If the Turn-ON information is true, the diesel is turned on. if it's false, the diesel is in automatic.

     Turn-ON and Turn-OFF can't be activated at the the same time.

     

     The IDSU can be deconnected by splitter cable control by redstone.

     

    My project.

     I wan't to use a graphic interface to control the 8 systems and the IDSU.i want use 2 bundle, 1 for send, and 1 for receive

     

     

    6eo4qyD.png

     

     Is it praticable ?

     

    thanks

×
×
  • Create New...

Important Information

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