RealBadAngel
2013-07-17 3bc6cad6710ad76f8a829a575f03fea00c589134
commit | author | age
ee5c6c 1 -- This file includes the functions and data structures for registering machines and tools for LV, MV, HV types.
fa8469 2 -- We use the technic namespace for these functions and data to avoid eventual conflict.
ee5c6c 3
3bc6ca 4 -- register power tools here
R 5 technic.power_tools = {}
6 technic.register_power_tool = function(craftitem,max_charge)
7                     technic.power_tools[craftitem] = max_charge
8                  end
9
ee5c6c 10 -- register LV machines here
K 11 technic.LV_machines    = {}
3bc6ca 12
ee5c6c 13 technic.register_LV_machine = function(nodename,type)
K 14                  technic.LV_machines[nodename] = type
15                   end
16
17 technic.unregister_LV_machine = function(nodename,type)
18                    technic.LV_machines[nodename] = nil
19                 end
20
21 -- register MV machines here
22 technic.MV_machines    = {}
23 technic.MV_power_tools = {}
24 technic.register_MV_machine = function(nodename,type)
25                  technic.MV_machines[nodename] = type
26                   end
27
28 technic.unregister_MV_machine = function(nodename)
29                    technic.MV_machines[nodename] = nil
30                 end
31
32 -- register HV machines here
33 technic.HV_machines    = {}
34 technic.HV_power_tools = {}
35 technic.register_HV_machine = function(nodename,type)
36                  technic.HV_machines[nodename] = type
37                   end
38
39 technic.unregister_HV_machine = function(nodename)
40                    technic.HV_machines[nodename] = nil
41                 end
42
43 -- Utility functions. Not sure exactly what they do.. water.lua uses the two first.
44 function technic.get_RE_item_load (load1,max_load)
45    if load1==0 then load1=65535 end
46    local temp = 65536-load1
47    temp= temp/65535*max_load
48    return math.floor(temp + 0.5)
49 end
50
51 function technic.set_RE_item_load (load1,max_load)
52    if load1 == 0 then return 65535 end
53    local temp=load1/max_load*65535
54    temp=65536-temp
55    return math.floor(temp)
56 end
57
58 -- Wear down a tool depending on the remaining charge.
59 function technic.set_RE_wear (item_stack,load,max_load)
60    local temp=65536-math.floor(load/max_load*65535)
61    item_stack["wear"]=tostring(temp)
62    return item_stack
63 end