Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- local mon = term
- local id_spawnera = 3
- --mon.setTextScale(1)
- mon.setTextColor(colors.white)
- local button={}
- mon.setBackgroundColor(colors.black)
- local g_strona = 1
- local g_naglowek={}
- function UstawTabele(p_strona, p_name, p_funkcja, p_parametr, p_xmin, p_xmax, p_ymin, p_ymax, p_color)
- button[p_strona][p_name] = {}
- button[p_strona][p_name]["funkcja"] = p_funkcja
- button[p_strona][p_name]["parametr"] = p_parametr
- button[p_strona][p_name]["aktywny"] = false
- button[p_strona][p_name]["xmin"] = p_xmin
- button[p_strona][p_name]["ymin"] = p_ymin
- button[p_strona][p_name]["xmax"] = p_xmax
- button[p_strona][p_name]["ymax"] = p_ymax
- button[p_strona][p_name]["color"] = p_color
- end
- function Zmien_strona1()
- g_strona = 1
- end
- function Zmien_strona2()
- g_strona = 2
- end
- function Zmien_strona3()
- g_strona = 3
- end
- function Zmien_strona4()
- g_strona = 4
- end
- function Test()
- WyslijRednet("Test", "Wiadomosc testowa","N", 1)
- --print("Nacisneles na przycisk nr 2")
- end
- function Ustaw_spawner(p_kolor, p_on)
- if p_on == true then
- WyslijRednet("Ustaw_spawner", p_kolor,"N", id_spawnera)
- else
- WyslijRednet("Ustaw_spawner", p_kolor,"T", id_spawnera)
- end
- end
- function UtworzStrony()
- button[1] = {}
- button[2] = {}
- button[3] = {}
- button[4] = {}
- g_naglowek[1] = "Sterownia SafemodTV"
- g_naglowek[2] = "Mob Grinder"
- g_naglowek[3] = "Farmy i automaty"
- g_naglowek[4] = "Elektrownie"
- end
- function UtworzTabele()
- -- Strona 1
- UstawTabele(1, "Mob Grinder", Zmien_strona2, nil, 2, 25, 3, 5, colors.cyan)
- UstawTabele(1, "Farmy i automaty", Zmien_strona3, nil, 2, 25, 7, 9, colors.green)
- UstawTabele(1, "Elektrownie", Zmien_strona4, nil, 2, 25, 11, 13, colors.purple)
- -- Strona 2
- UstawTabele(2, "Creeper", Ustaw_spawner, "white", 2, 12, 3, 3)
- UstawTabele(2, "Szkielet", Ustaw_spawner, "orange", 2, 12, 5, 5)
- UstawTabele(2, "Spider", Ustaw_spawner, "magenta", 2, 12, 7, 7)
- UstawTabele(2, "Zombie", Ustaw_spawner, "lightBlue", 2, 12, 9, 9)
- UstawTabele(2, "ZombiePig", Ustaw_spawner, "yellow", 2, 12, 11, 11)
- UstawTabele(2, "Enderman", Ustaw_spawner, "lime", 2, 12, 13, 13)
- UstawTabele(2, "Pig", Ustaw_spawner, "pink", 2, 12, 15, 15)
- UstawTabele(2, "Sheep", Ustaw_spawner, "gray", 2, 12, 17, 17)
- UstawTabele(2, "Magma Cube", Ustaw_spawner, "lightGray", 15, 25, 3, 3)
- UstawTabele(2, "Witch", Ustaw_spawner, "cyan", 15, 25, 5, 5)
- UstawTabele(2, "Villager", Ustaw_spawner, "purple", 15, 25, 7, 7)
- UstawTabele(2, "Iron Golem", Ustaw_spawner, "blue", 15, 25, 9, 9)
- UstawTabele(2, "Cave Spider", Ustaw_spawner, "brown", 15, 25, 11, 11)
- UstawTabele(2, "B. Szkielet", Ustaw_spawner, "green", 15, 25, 13, 13)
- UstawTabele(2, "Cow", Ustaw_spawner, "red", 15, 25, 15, 15)
- UstawTabele(2, "Chicken", Ustaw_spawner, "black", 15, 25, 17, 17)
- UstawTabele(2, "Powrot", Zmien_strona1, nil, 2, 25, 19, 19, colors.cyan)
- -- Strona 3
- UstawTabele(3, "Powrot", Zmien_strona1, nil, 2, 25, 19, 19, colors.cyan)
- -- Strona 4
- UstawTabele(4, "Powrot", Zmien_strona1, nil, 2, 25, 19, 19, colors.cyan)
- end
- function UtworzPrzycisk(p_text, p_color, p_bData)
- mon.setBackgroundColor(p_color)
- local l_yspot = math.floor((p_bData["ymin"] + p_bData["ymax"]) /2)
- local l_xspot = math.floor((p_bData["xmax"] - p_bData["xmin"] - string.len(p_text)) /2) +1
- for j = p_bData["ymin"], p_bData["ymax"] do
- mon.setCursorPos(p_bData["xmin"], j)
- if j == l_yspot then
- for k = 0, p_bData["xmax"] - p_bData["xmin"] - string.len(p_text) +1 do
- if k == l_xspot then
- mon.write(p_text)
- else
- mon.write(" ")
- end
- end
- else
- for i = p_bData["xmin"], p_bData["xmax"] do
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function Wyswietl()
- local l_currColor
- for name,data in pairs(button[g_strona]) do
- local on = data["aktywny"]
- local color = data["color"]
- if color ~= nil then
- l_currColor = color
- elseif on == true then
- l_currColor = colors.lime
- else
- l_currColor = colors.red
- end
- UtworzPrzycisk(name, l_currColor, data)
- end
- end
- function SprawdzXY(x, y)
- for name, data in pairs(button[g_strona]) do
- if y>=data["ymin"] and y <= data["ymax"] then
- if x>=data["xmin"] and x<= data["xmax"] then
- data["funkcja"](data["parametr"], data["aktywny"])
- --if data["color"] == nil then
- data["aktywny"] = not data["aktywny"]
- --end
- end
- end
- end
- end
- function Kodow_znaki(p_id, p_znaki)
- p_id = tostring(p_id)
- for tidlenc=1, p_znaki do
- if string.len(p_id) == tidlenc
- then
- p_id = ("_"..p_id)
- end
- end
- return p_id
- end
- function WyslijRednet(p_typ, p_wiadomosc, p_aktywny, p_IdDocelowe)
- if p_wiadomosc and p_IdDocelowe then
- rednet.broadcast(Kodow_znaki(os.getComputerID(),4)..Kodow_znaki(p_IdDocelowe,4)..p_aktywny..Kodow_znaki(p_typ,16)..p_wiadomosc)
- end
- end
- function OdczytRednet(p_id, p_message)
- if p_id and p_message then
- if string.sub(p_message,6,10) == Kodow_znaki(os.getComputerID(),4) then
- end
- end
- end
- function Naglowek(p_text)
- w, h = mon.getSize()
- mon.setCursorPos((w-string.len(p_text))/2+1, 1)
- mon.write(p_text)
- end
- UtworzStrony()
- UtworzTabele()
- while true do
- mon.clear()
- Naglowek(g_naglowek[g_strona])
- Wyswietl()
- local event,p1,p2,p3 = os.pullEvent("mouse_click")
- if event == "mouse_click" then -- Event, Side, X, Y
- SprawdzXY(p2,p3)
- elseif event == "rednet_message" then -- Event, Id, Message
- OdczytRednet(p1, p2)
- end
- sleep(.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement