SHOW:
|
|
- or go back to the newest paste.
1 | - | local storage |
1 | + | local sideofreac |
2 | - | local player = false |
2 | + | |
3 | local max | |
4 | - | local id, mens, pl |
4 | + | local min |
5 | local reactor | |
6 | local monitor | |
7 | local maxstored | |
8 | - | print("Number of Storage:") |
8 | + | loacl scale |
9 | - | settings[1]="s"..read() |
9 | + | |
10 | ||
11 | function createsettings() | |
12 | local settings={} | |
13 | print("Side of Reactor") | |
14 | settings[1]=read() | |
15 | print("Side of Monitor:") | |
16 | settings[2]=read() | |
17 | - | storage=settings[1] |
17 | + | print("Max Amount of Energy Stored want (in /%):") |
18 | settings[3]=tonumber(read()) | |
19 | print("Min Amount of Energy Stored you want (in /%):") | |
20 | settings[4]=tonumber(read()) | |
21 | print("Max Amount of Energy Stored of the Reactor (in RF):") | |
22 | settings[5]=tonumber(read()) | |
23 | print("Scale:") | |
24 | settings[6]=tonumber(read()) | |
25 | save(settings,"settings.txt") | |
26 | end | |
27 | ||
28 | function loadsettings() | |
29 | local settings=load("settings.txt") | |
30 | sideofreac=settings[1] | |
31 | sideofmon=settings[2] | |
32 | max=settings[3] | |
33 | min=settings[4] | |
34 | maxstored=settings[5] | |
35 | scale=settings[6] | |
36 | - | local data=load("data.txt") |
36 | + | |
37 | - | local names={} |
37 | + | |
38 | - | local numbers={} |
38 | + | function split(inputstr, sep) |
39 | - | if #data~=0 then |
39 | + | if sep == nil then |
40 | - | for i=1,#data/2 then |
40 | + | sep = "%s" |
41 | - | names[i]=data[i*2-1] |
41 | + | end |
42 | - | numbers[i]=data[i*2] |
42 | + | local t |
43 | - | end |
43 | + | for str in string.gmatch(inputstr, "([^"..sep.."]+)") do |
44 | t = str | |
45 | break | |
46 | end | |
47 | return t | |
48 | end | |
49 | ||
50 | function save(table,name) | |
51 | local file = fs.open(name,"w") | |
52 | file.write(textutils.serialize(table)) | |
53 | - | local mon=peripheral.wrap(sideofmon) |
53 | + | |
54 | end | |
55 | - | if not exist("data.txt") then |
55 | + | |
56 | - | local id, mens, protocol = rednet.receive("data"..storage) |
56 | + | |
57 | - | local data=textutils.unserialize(mens) |
57 | + | |
58 | - | save(data,"data.txt") |
58 | + | |
59 | file.close() | |
60 | return textutils.unserialize(data) | |
61 | - | display() |
61 | + | |
62 | ||
63 | - | id, mens, pl = rednet.receive() |
63 | + | function setup() |
64 | - | if pl==("data"..storage) then |
64 | + | local cable=peripheral.wrap("sideofmon") |
65 | - | local data=textutils.unserialize(mens) |
65 | + | local names=cable.getNamesRemote() |
66 | - | save(data,"data.txt") |
66 | + | for i=1,#names do |
67 | - | display() |
67 | + | if string.sub(names[i],1,2)=="mon" then |
68 | - | end |
68 | + | monitor=names[i] |
69 | end | |
70 | end | |
71 | local cable=peripheral.wrap("sideofreac") | |
72 | local names=cable.getNamesRemote() | |
73 | for i=1,#names do | |
74 | if string.sub(names[i],1,2)=="Big" then | |
75 | reactor=names[i] | |
76 | end | |
77 | end | |
78 | end | |
79 | ||
80 | function display() | |
81 | mon=peripheral.wrap(monitor) | |
82 | reac=peripheral.wrap(reactor) | |
83 | local l,h=mon.getSize() | |
84 | local stored=rea.getEnergyStored() | |
85 | local info={"","Energy Output:",tostring(rea.getEnergyProducedLastTick()),"","Temperature",split(tostring(rea.getFuelTemperature(),","),"","Fuel Burnout",tostring(rea.getFuelConsumedLastTick())} | |
86 | local used=0 | |
87 | for i=1,#info do | |
88 | if used > string.len(info[i]) then | |
89 | used = string.len(info[i]) | |
90 | end | |
91 | if i==#info then l-used end | |
92 | end | |
93 | for i=1,#info do | |
94 | mon.write(info[i],1,i) | |
95 | end | |
96 | end | |
97 | ||
98 | local hsize=l*0,60 | |
99 | local lsize=(h-10) | |
100 | ||
101 | ||
102 | ||
103 | ||
104 | --------------------------------------------------- | |
105 | if not exist("settings.txt") then | |
106 | createsettings() | |
107 | end | |
108 | loadsettings() | |
109 | setup() | |
110 | ||
111 | ||
112 | ||
113 | ||
114 | while true do | |
115 | display() | |
116 | end |