Created
April 28, 2015 23:03
-
-
Save Keridos/c85a90312fccb2e30d18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local API = require("buttonAPI") | |
local event = require("event") | |
local computer = require("computer") | |
local term = require("term") | |
local component = require("component") | |
local gpu = component.gpu | |
local rs = component.redstone | |
local colors = require("colors") | |
local side = require("sides") | |
local mobtable = {} | |
function fillTable() | |
--API.setTable("Creeper", toggleSpawn, "Creeper", 3,5,3,10) | |
--API.setTable("Enderman", toggleSpawn, "Enderman", 7,5,3,10) | |
--API.setTable("Wither Skeleton", toggleSpawn, "Wither Skeleton", 10,20,8,10) | |
--API.setTable("Blaze", toggleSpawn, "Blaze", 22,32,8,10) | |
--API.setTable("Spider", toggleSpawn, "Spider", 12,14,19,29) | |
API.screen() | |
end | |
function setupTable() | |
mobtable["Creeper"] = 0 | |
mobtable["Enderman"] = 1 | |
mobtable["Wither Skeleton"] = 2 | |
mobtable["Blaze"] = 3 | |
mobtable["Spider"] = 4 | |
end | |
function enableSpawn(mob) | |
rs.setBundledOutput(0,mobtable(mob),15) | |
end | |
function disableSpawn(mob) | |
rs.setBundledOutput(0,mobtable(mob),0) | |
end | |
function toggleSpawn(mob) | |
API.toggleButton(mob) | |
if API.getButtonStatus(mob) then | |
enableSpawn(mob) | |
else | |
disableSpawn(mob) | |
end | |
API.screen() | |
end | |
function getClick() | |
local _, _, x, y = event.pull(1,touch) | |
if x == nil or y == nil then | |
local h, w = gpu.getResolution() | |
gpu.set(h, w, ".") | |
gpu.set(h, w, " ") | |
else | |
API.checkxy(x,y) | |
end | |
end | |
function init() | |
term.setCursorBlink(false) | |
gpu.setResolution(80, 25) | |
API.clear() | |
fillTable() | |
--API.heading("Button API Demo! Created in CC by DW20, ported to OC by MoparDan!") | |
--API.label(1,24,"A sample Label.") | |
end | |
function main() | |
init() | |
setupTable() | |
while true do | |
getClick() | |
end | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment