commit | author | age
|
ee0765
|
1 |
-- This file includes the functions and data structures for registering machines and tools for LV, MV, HV types. |
S |
2 |
-- We use the technic namespace for these functions and data to avoid eventual conflict. |
|
3 |
|
|
4 |
technic.receiver = "RE" |
|
5 |
technic.producer = "PR" |
|
6 |
technic.battery = "BA" |
|
7 |
|
|
8 |
technic.machines = {} |
|
9 |
technic.power_tools = {} |
|
10 |
|
|
11 |
function technic.register_tier(tier, description) |
|
12 |
technic.machines[tier] = {} |
|
13 |
technic.cables[tier] = {} |
|
14 |
end |
|
15 |
|
|
16 |
function technic.register_machine(tier, nodename, machine_type) |
|
17 |
if not technic.machines[tier] then |
|
18 |
return |
|
19 |
end |
|
20 |
technic.machines[tier][nodename] = machine_type |
|
21 |
end |
|
22 |
|
|
23 |
function technic.register_power_tool(craftitem, max_charge) |
|
24 |
technic.power_tools[craftitem] = max_charge |
|
25 |
end |
|
26 |
|
|
27 |
|
|
28 |
-- Utility functions. Not sure exactly what they do.. water.lua uses the two first. |
|
29 |
function technic.get_RE_item_load(load1, max_load) |
|
30 |
if load1 == 0 then load1 = 65535 end |
|
31 |
local temp = 65536 - load1 |
|
32 |
temp = temp / 65535 * max_load |
|
33 |
return math.floor(temp + 0.5) |
|
34 |
end |
|
35 |
|
|
36 |
function technic.set_RE_item_load(load1, max_load) |
|
37 |
if load1 == 0 then return 65535 end |
|
38 |
local temp = load1 / max_load * 65535 |
|
39 |
temp = 65536 - temp |
|
40 |
return math.floor(temp) |
|
41 |
end |
|
42 |
|
|
43 |
-- Wear down a tool depending on the remaining charge. |
|
44 |
function technic.set_RE_wear(item_stack, item_load, max_load) |
|
45 |
local temp = 65536 - math.floor(item_load / max_load * 65535) |
|
46 |
item_stack.wear = tostring(temp) |
|
47 |
return item_stack |
|
48 |
end |