I have recently written a script for advanced computers and advanced monitors. It so far does nothing except for allow you to select the option that you want.
What it does
Currently, nothing. It has huge potential and the possibility to be expanded to larger monitors and control stuff, but for now, it just makes pretty colored text for the words on and off.
Goal
I hope to make this into its own fully standalone setup (not that it isn't already) that can control tier 5 spawners from the soul shards mod. I have not yet done so, but will post when it is done. Tip: If Redpower is installed, you can use cover strips to cover up the gold border around the monitor.
Setup
Requires an advanced computer witha monitor to the right (configurable) with at least the size of 4 wide by 3 high advanced monitors. Right click to change the state of things.
Script
Here is the script, you can directly download from pastebin.com if you have http access turned on in the config by pasting in
pastebin get 6jjXTe4m "name for script"
into the advanced computer.Code on:
New code: http://pastebin.com/6jjXTe4m
Screenshots:
Spoiler
Old Code:
Spoiler
Please note, code pasted here is not necessarily up to date at all times. Please check pastebin.com for the most recent version of the code.
--Requires advanced monitors and computers!!!
function toggle(n)
if not n then
return
end
local state=lightState[n]
if state then
state = false
else
state = true
end
lightState[n] = state
return state
end
function sayState(n)
if not n then
return
end
x = buttonX[n]-1
y = buttonY[n]
term.setCursorPos(x,y)
if lightState[n] then
term.setTextColor(colors.lime)
write("on ")
term.setTextColor(colors.white)
else
term.setTextColor(colors.red)
write("off")
term.setTextColor(colors.white)
end
end
function getButton(xPos,yPos)
for i=1,12 do
bxPos=buttonX[i]
byPos=buttonY[i]
xMax=bxPos+2
xMin=bxPos-2
yMax=byPos+1
yMin=byPos-1
if xPos >= xMin and xPos <= xMax and yPos >= yMin and yPos <= yMax then
return i
end
end
end
function mPrint(w)
write(w)
x,y=term.getCursorPos()
term.setCursorPos(1,y+1)
end
function allTheSame()
local state = lightState[1]
for i=2,10 do
if state==lightState[i] then
else return false
end
end
return true
end
function stateWriter()
mPrint(" _____ _____ _____ _____")
write(" ")
for i=1,4 do
write("|")
term.setTextColor(colors.red)
write("off")
term.setTextColor(colors.white)
if i<4 then
write("| ")
else
mPrint("|")
end
end
mPrint(" ~~~~~ ~~~~~ ~~~~~ ~~~~~")
end
function startText()
term.setCursorPos(1,1)
mPrint("_______________________________________")
mPrint(" Welcome to spawn select! Control mob")
mPrint(" spawn choice by right click on screen")
mPrint(" ")
mPrint(" Skele Wither Ender Zombie")
stateWriter()
mPrint(" ")
mPrint(" Creep Witch Pigman Cow")
stateWriter()
mPrint(" ")
mPrint(" Blaze Slime Toggle Master")
stateWriter()
mPrint("_______________________________________")
end
function bundleState()
end
display = peripheral.wrap("right")
term.redirect(display)
term.clear()
term.setCursorPos(1,1)
buttonX = {
5,15,25,35,
5,15,25,35,
5,15,25,35
}
buttonY = {
7,7,7,7,
12,12,12,12,
17,17,17,17
}
lightState = {false,false,false,false,false,false,false,false,false,false,false,false}
spawnerColor = {
colors.white, colors.orange, colors.magenta, colors.lightBlue,
colors.yellow, colors.lime, colors.pink, colors.gray,
colors.lightGray, colors.cyan, colors.purple, colors.blue
}
local resume=true
startText()
for i=1,10 do
sayState(i)
end
term.setCursorPos(buttonX[12]-1,buttonY[12])
term.setTextColor(colors.red)
write("off")
term.setTextColor(colors.white)
term.setCursorPos(buttonX[11]-1,buttonY[11])
term.setTextColor(colors.cyan)
write("TGL")
term.setTextColor(colors.white)
while resume == true do
local event, side, xPos, yPos = os.pullEvent("monitor_touch")
local button = getButton(xPos,yPos)
if button==11 then
for i=1,10 do
toggle(i)
end
elseif button==12 then
toggle(12)
for i=1,10 do
lightState[i]=lightState[12]
end
sayState(12)
allSame=true
else
term.setCursorPos(buttonX[12]-1,buttonY[12])
term.setTextColor(colors.lightGray)
write("---")
term.setTextColor(colors.white)
toggle(button)
end
for i=1,10 do
sayState(i)
end
if allTheSame() then
lightState[12]=lightState[1]
sayState(12)
else
term.setCursorPos(buttonX[12]-1,buttonY[12])
term.setTextColor(colors.lightGray)
write("---")
term.setTextColor(colors.white)
end
end
--[==[Tables are used to quite an extent throughout this program.
The order of said tables is important as these must remain consistent in order for the script to execute.]==]
If you spot any errors, please point them out. :)/>