Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- RCPanel by Westar
- version = '1'
- function getMonitor()
- return peripheral.find('monitor');
- end
- function getModem()
- return peripheral.find('modem');
- end
- function split(s, delimiter)
- result = {};
- for match in (s..delimiter):gmatch("(.-)"..delimiter) do
- table.insert(result, match);
- end
- return result;
- end
- function menu(options)
- local sid = 0;
- local maxSid = 0;
- while true do
- for k, v in pairs(options) do
- if k > maxSid then
- maxSid = k;
- end
- if sid == k then
- print('['..v.label..']');
- else
- print(' '..v.label..' ');
- end
- end
- local sEvent, param = os.pullEvent("key");
- if sEvent == 'key' then
- if param == 200 then
- if sid > 0 then
- sid = sid -1
- elseif sid == 0 then
- sid = maxSid;
- end
- elseif param == 208 then
- if sid < maxSid then
- sid = sid + 1;
- elseif sid == maxSid then
- sid = 0;
- end
- elseif param == 28 then
- return sid
- end
- end
- end
- end
- monitor = getMonitor();
- state = 0;
- function mainDisplay()
- print('RCPanel v'..version..' by Westar');
- newState = menu({
- {
- value = 1,
- label = 'Turtle'
- },
- {
- value = 2,
- label = 'Stats'
- },
- {
- value = 3,
- label = 'WIP'
- }
- });
- doState(newState);
- end
- function doState(newState)
- state = newState;
- if state == 0 then
- mainDisplay();
- end
- if state == 1 then
- turtleDisplay();
- end
- end
- doState(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement