]> git.lizzy.rs Git - Crafter.git/blob - mods/hopper/init.lua
Add in jetpacks
[Crafter.git] / mods / hopper / init.lua
1 -- define global
2 hopper = {}
3
4 -- internationalization boilerplate
5 local MP = minetest.get_modpath(minetest.get_current_modname())
6 local S = minetest.get_translator("hopper")
7
8 hopper.formspec_bg = "background[-0.19,-0.25;9.41,9.49;gui_hb_bg.png]"
9
10 dofile(MP.."/config.lua")
11 dofile(MP.."/api.lua")
12 dofile(MP.."/utility.lua")
13 dofile(MP.."/doc.lua")
14 dofile(MP.."/nodes/hoppers.lua")
15 dofile(MP.."/nodes/chute.lua")
16 dofile(MP.."/nodes/sorter.lua")
17 dofile(MP.."/crafts.lua")
18 dofile(MP.."/abms.lua")
19
20
21 -------------------------------------------------------------------------------------------
22 -- Formspec handling
23
24 minetest.register_on_player_receive_fields(function(player, formname, fields)
25         if "hopper_formspec:" == string.sub(formname, 1, 16) then
26                 local pos = minetest.string_to_pos(string.sub(formname, 17, -1))
27                 local meta = minetest.get_meta(pos)
28                 local eject_setting = meta:get_string("eject") == "true"
29                 local filter_all_setting = meta:get_string("filter_all") == "true"
30                 if fields.eject then
31                         if eject_setting then
32                                 meta:set_string("eject", nil)
33                         else
34                                 meta:set_string("eject", "true")
35                         end
36                 end
37                 if fields.filter_all then
38                         if filter_all_setting then
39                                 meta:set_string("filter_all", nil)
40                         else
41                                 meta:set_string("filter_all", "true")
42                         end                     
43                 end
44         end
45 end)