Ah, yes. I am a noob when it comes to Lua, so if there is a very simple and obvious solution to this problem let me apologize in advance.
Alright, here is the problem: I have this mod Thut's Elevators installed so you can make realistically working elevators in Minecraft. I have this program to control the elevator through buttons on a tier 2 screen. But due to how the mod is made you can't have a screen on board in the elevator, so I need to have a screen on each new elevator destination. The buttons are working and can send the elevator from one screen, but I can't switch it to another screen and re-draw the buttons when arriving.
Here is the code:
local component =require("component")local tty =require("tty")localevent=require("event")local gpu = component.gpu
local lift = component.lift
local screen = component.screen
local bkgrdColor = gpu.getBackground()local buttons ={}local screens ={"a4bd2de3-cbaf-4a4b-ac3b-acf2dbd62bc1","f48c1033-81ea-432d-ae91-73bfaca47334","2bb63258-c785-42be-8598-573e457a38d7","c07ce065-ac3a-4877-9802-ee381036d1a1","cc5570bc-cbb1-4966-9586-171938103bcd","ef89a0c1-615a-4998-a6e2-d701a22260cf","acce1910-793e-4668-81a0-8ddac3f26bab",}local floors ={--The Y-coordinates the elevator stops by1-7."67","72","78","83","88","93","98",}local currentScreen = screens[1]localfunction newButton(x,y,number)
gpu.setBackground(0x990000)
gpu.fill(x,y,3,3," ")
gpu.set(x+1,y+1,number)
gpu.setBackground(bkgrdColor)
buttons[number]={x,y}endlocalfunction doButtons()
newButton(2,2,"1")
newButton(6,2,"2")
newButton(10,2,"3")
newButton(14,2,"4")
newButton(18,2,"5")
newButton(22,2,"6")
newButton(26,2,"7")end
gpu.setResolution(29,15)
tty.clear()
doButtons()whiletruedolocal _,_,x,y =event.pull("touch")for i in pairs(buttons)doif x >= buttons[i][1]and x <= buttons[i][1]+3and y >= buttons[i][2]and y <= buttons[i][2]+3then
currentScreen = screens[i]
gpu.setBackground(0x008153)
gpu.fill(buttons[i][1],buttons[i][2],3,3," ")
os.sleep(0.05)
lift.callFloor(tonumber(i))
gpu.setBackground(0x990000)
gpu.fill(buttons[i][1],buttons[i][2],3,3," ")
gpu.set(buttons[i][1]+1,buttons[i][2]+1,i)
gpu.setBackground(bkgrdColor)endendend
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.
Ah, yes. I am a noob when it comes to Lua, so if there is a very simple and obvious solution to this problem let me apologize in advance.
Alright, here is the problem: I have this mod Thut's Elevators installed so you can make realistically working elevators in Minecraft. I have this program to control the elevator through buttons on a tier 2 screen. But due to how the mod is made you can't have a screen on board in the elevator, so I need to have a screen on each new elevator destination. The buttons are working and can send the elevator from one screen, but I can't switch it to another screen and re-draw the buttons when arriving.
Here is the code:
The elevators API:
Link to post
Share on other sites