SHOW:
|
|
- or go back to the newest paste.
| 1 | --mMultiOS | |
| 2 | - | --<~t<true>marcelOS<info<0||name<0|explorer>version<1|0.2>changePrint<2|false>eventfilter<0|mouse_click|window_resize|window_fullscreen>EventManager<3|true>Debug<3|true>>code<0|print("Hello, explorer run under marcelOS")>>other<info<0||name<0|explorer>version<2|0.2>>code<0|~i<23>print("Unknown OS ...")>>>
|
| 2 | + | --<~t<true>marcelOS<info<0||name<0|explorer>version<1|0.2>changePrint<2|false>eventfilter<0|internet|mouse_click|window_resize|window_fullscreen>EventManager<3|true>Debug<3|true>>code<0|print("Hello, explorer run under marcelOS")>>other<info<0||name<0|explorer>version<2|0.2>>code<0|~i<23>print("Unknown OS ...")>>>
|
| 3 | Application.window = windows.CreateWindow( "LightSystem" , Application , true) | |
| 4 | Application.window:SetSize(40,35) | |
| 5 | Application.window:FindSpace(111) | |
| 6 | -- denk drann beim Server in der 2ten Zeile beim eventfilter "internet" drinnen zu haben, andernfalls bekommt er keine internet events... | |
| 7 | ||
| 8 | function Rahmen() | |
| 9 | local streifen = string.rep("-",Application.window.width)
| |
| 10 | - | Application.window.l:setFontColor( colours.white ) |
| 10 | + | |
| 11 | - | term.setCursorPos(1,1) |
| 11 | + | Application.window:writePos(1,1,"Computerraum:") |
| 12 | - | term.setBackgroundColor(colors.black) |
| 12 | + | Application.window:writePos(15,1,"On",colors.white,colors.green) |
| 13 | - | Application.window:print( "Computerraum:" ) |
| 13 | + | Application.window:writePos(20,1,"Off",colors.white,colors.red) |
| 14 | - | term.setCursorPos(15,1) |
| 14 | + | Application.window:writePos(26,1,"Status:") |
| 15 | - | term.setBackgroundColor(colors.green) |
| 15 | + | Application.window:writePos(1,2,streifen) |
| 16 | - | Application.window:print( "On" ) |
| 16 | + | |
| 17 | - | term.setCursorPos(20,1) |
| 17 | + | |
| 18 | - | term.setBackgroundColor(colors.red) |
| 18 | + | |
| 19 | - | Application.window:print( "Off" ) |
| 19 | + | Application.window:writePos(1,3,"Serverraum:") |
| 20 | - | term.setCursorPos(26,1) |
| 20 | + | Application.window:writePos(15,3,"On",colors.white,colors.green) |
| 21 | - | term.setBackgroundColor(colors.black) |
| 21 | + | Application.window:writePos(20,3,"Off",colors.white,colors.red) |
| 22 | - | Application.window:print( "Status:" ) |
| 22 | + | Application.window:writePos(26,3,"Status:") |
| 23 | Application.window:writePos(1,4,streifen) | |
| 24 | - | Application.window.l:setFontColor( colours.white ) |
| 24 | + | |
| 25 | - | term.setCursorPos(1,2) |
| 25 | + | |
| 26 | - | term.setBackgroundColor(colors.black) |
| 26 | + | |
| 27 | - | Application.window:print( "----------------------------------------------------------------------------------------------------------------------------------------------------------" ) |
| 27 | + | Application.window:writePos(1,5,"Tekkitraum:") |
| 28 | Application.window:writePos(15,5,"On",colors.white,colors.green) | |
| 29 | - | Application.window.l:setFontColor( colours.white ) |
| 29 | + | Application.window:writePos(20,5,"Off",colors.white,colors.red) |
| 30 | - | term.setCursorPos(1,3) |
| 30 | + | Application.window:writePos(26,5,"Status:") |
| 31 | - | term.setBackgroundColor(colors.black) |
| 31 | + | Application.window:writePos(1,6,streifen) |
| 32 | - | Application.window:print( "Serverraum:" ) |
| 32 | + | |
| 33 | - | term.setCursorPos(15,3) |
| 33 | + | |
| 34 | - | term.setBackgroundColor(colors.green) |
| 34 | + | |
| 35 | - | Application.window:print( "On" ) |
| 35 | + | Application.window:writePos(1,7,"Lagerraum:") |
| 36 | - | term.setCursorPos(20,3) |
| 36 | + | Application.window:writePos(15,7,"On",colors.white,colors.green) |
| 37 | - | term.setBackgroundColor(colors.red) |
| 37 | + | Application.window:writePos(20,7,"Off",colors.white,colors.red) |
| 38 | - | Application.window:print( "Off" ) |
| 38 | + | Application.window:writePos(26,7,"Status:") |
| 39 | - | term.setCursorPos(26,3) |
| 39 | + | Application.window:writePos(1,8,streifen) |
| 40 | - | term.setBackgroundColor(colors.black) |
| 40 | + | |
| 41 | - | Application.window:print( "Status:" ) |
| 41 | + | |
| 42 | -- hier kein while true, da er sonnst immer zeichnen würde und niemals zur eventabfrage kommt. Außerdem soll er ja nur einmal zeichnen bei der Function Rahmen... | |
| 43 | - | Application.window.l:setFontColor( colours.white ) |
| 43 | + | |
| 44 | - | term.setCursorPos(1,4) |
| 44 | + | ComputerraumRahmen() |
| 45 | - | term.setBackgroundColor(colors.black) |
| 45 | + | ServerraumRahmen() |
| 46 | - | Application.window:print( "----------------------------------------------------------------------------------------------------------------------------------------------------------" ) |
| 46 | + | TekkitraumRahmen() |
| 47 | LagerraumRahmen() | |
| 48 | - | Application.window.l:setFontColor( colours.white ) |
| 48 | + | |
| 49 | - | term.setCursorPos(1,5) |
| 49 | + | |
| 50 | - | term.setBackgroundColor(colors.black) |
| 50 | + | |
| 51 | - | Application.window:print( "Tekkitraum:" ) |
| 51 | + | -- Auch hier kein While true,,, |
| 52 | - | term.setCursorPos(15,5) |
| 52 | + | |
| 53 | - | term.setBackgroundColor(colors.green) |
| 53 | + | |
| 54 | - | Application.window:print( "On" ) |
| 54 | + | |
| 55 | - | term.setCursorPos(20,5) |
| 55 | + | local event,side,x,y = os.pullEvent() |
| 56 | - | term.setBackgroundColor(colors.red) |
| 56 | + | -- Durch diese Debugausgabe werden alle Events angezeigt, das sollte es um einiges einfacher machen ;) |
| 57 | - | Application.window:print( "Off" ) |
| 57 | + | Debug(event,tostring(side) .. " " .. tostring(x) .. " " .. tostring(y)) |
| 58 | - | term.setCursorPos(26,5) |
| 58 | + | -- mouse_click statt monitor_toch abfragen... |
| 59 | - | term.setBackgroundColor(colors.black) |
| 59 | + | if event == "mouse_click" then |
| 60 | - | Application.window:print( "Status:" ) |
| 60 | + | |
| 61 | -- Die Klammern sind wichtig, das hat zwar nichts mit marcelOS zu tun , aber mit lua allgemein... | |
| 62 | - | Application.window.l:setFontColor( colours.white ) |
| 62 | + | if ((x == 15) and (y == 1)) or ((x == 16) and (y == 1)) then |
| 63 | - | term.setCursorPos(1,6) |
| 63 | + | |
| 64 | - | term.setBackgroundColor(colors.black) |
| 64 | + | -- 1 = ID des Servers |
| 65 | - | Application.window:print( "----------------------------------------------------------------------------------------------------------------------------------------------------------" ) |
| 65 | + | -- 100 = Port des Servers, falls mehrere Programme gleichzeitig senden... |
| 66 | -- "ComputerraumLightOn" = die Message | |
| 67 | - | Application.window.l:setFontColor( colours.white ) |
| 67 | + | ip.SendMessage( nil, 1, nil, 100, nil , "ComputerraumLightOn" ) |
| 68 | - | term.setCursorPos(1,7) |
| 68 | + | --rednet.send(1, "ComputerraumLightOn") --Zahl= Id des Server |
| 69 | - | term.setBackgroundColor(colors.black) |
| 69 | + | |
| 70 | - | Application.window:print( "Lagerraum:" ) |
| 70 | + | |
| 71 | - | term.setCursorPos(15,7) |
| 71 | + | if ((x == 20) and (y == 1)) or ((x == 21) and (y == 1)) or ((x == 22) and (y == 1)) then |
| 72 | - | term.setBackgroundColor(colors.green) |
| 72 | + | ip.SendMessage( nil, 1, nil, 100, nil , "ComputerraumLightOff" ) |
| 73 | - | Application.window:print( "On" ) |
| 73 | + | --rednet.send(1, "ComputerraumLightOff") --Zahl= Id des Server |
| 74 | - | term.setCursorPos(20,7) |
| 74 | + | |
| 75 | - | term.setBackgroundColor(colors.red) |
| 75 | + | |
| 76 | - | Application.window:print( "Off" ) |
| 76 | + | -- Die anderen Events wie das letzte erstellen... |
| 77 | - | term.setCursorPos(26,7) |
| 77 | + | |
| 78 | - | term.setBackgroundColor(colors.black) |
| 78 | + | |
| 79 | - | Application.window:print( "Status:" ) |
| 79 | + | |
| 80 | ||
| 81 | - | Application.window.l:setFontColor( colours.white ) |
| 81 | + | |
| 82 | - | term.setCursorPos(1,8) |
| 82 | + | |
| 83 | - | term.setBackgroundColor(colors.black) |
| 83 | + | |
| 84 | - | Application.window:print( "----------------------------------------------------------------------------------------------------------------------------------------------------------" ) |
| 84 | + | |
| 85 | mTask.sleepEvent(Application,1) | |
| 86 | - | while true do |
| 86 | + |