summaryrefslogtreecommitdiff
path: root/init.lua
blob: 26aa1d95dcfab7ef4f85475f10d2270f8a370173 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
-- feedlot mod Copyright (C) 2017 Gabriel PĂ©rez-Cerezo

local modpath = minetest.get_modpath( "feedlot" )
dofile(modpath.."/fakeplayer.lua")

local function get_formspec(pos)
   local spos = pos.x .. "," ..pos.y .. "," .. pos.z
   local xbg = default.gui_bg .. default.gui_bg_img .. default.gui_slots
--   local detached_inv = minetest.create_detached_inventory("mailbox_"..owner)
   return "size[8,5.5]" .. xbg .. default.get_hotbar_bg(0, 1.5) ..
      "label[0,0;Feedlot]" ..
      "list[nodemeta:" .. spos .. ";main;3.5,0;1,1;]" ..
      "list[current_player;main;0,1.5;8,1;]" ..
      "list[current_player;main;0,2.75;8,3;8]" ..
--			"listring[detached:mailbox_" .. owner .. ";drop]" ..
      "listring[current_player;main]"
end

minetest.register_node("feedlot:feedlot", {
			  description = "Feedlot",
			  tiles = {
			     "default_wood.png^feedlot_feed.png",
			     "default_wood.png",
			     "default_wood.png",
			     "default_wood.png",
			     "default_wood.png",
			     "default_wood.png"
			  },
			  drawtype = "nodebox",
			  paramtype = "light",
			  node_box = {
			     type = "fixed",
			     fixed = {
				{-0.5, -0.5, -0.5, 0.5, -0.1875, -0.4375}, -- NodeBox6
				{0.4375, -0.5, -0.5, 0.5, -0.1875, 0.5}, -- NodeBox7
				{-0.5, -0.5, 0.4375, 0.5, -0.1875, 0.5}, -- NodeBox8
				{-0.5, -0.5, -0.5, -0.4375, -0.1875, 0.5}, -- NodeBox9
				{-0.4375, -0.5, -0.4375, 0.4375, -0.375, 0.4375}, -- NodeBox10
			     }
			  },
			  
			  on_construct = function (pos)
			     local meta = minetest.get_meta(pos)
			     local inv = meta:get_inventory()
			     meta:set_string("formspec", get_formspec(pos))
			     inv:set_size("main", 1)
			  end,
			  can_dig = function (pos)
			     local meta = minetest.get_meta(pos)
			     local inv = meta:get_inventory()
			     return inv:is_empty("main")
			  end,
			  groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1}, 
			  tube = {
			     insert_object = function(pos, node, stack, direction)
				local meta = minetest.get_meta(pos)
				local inv = meta:get_inventory()
				local added = inv:add_item("main", stack)
				return added
			     end,
			     can_insert = function(pos, node, stack, direction)
				local meta = minetest.get_meta(pos)
				local inv = meta:get_inventory()
				return inv:room_for_item("main", stack)
			     end,
			     input_inventory = "main",
			     connect_sides = {left = 0, right = 0, front = 0, back = 0, top = 0, bottom = 1}},
})

local function is_mob(obj)
   return obj.get_luaentity and obj:get_luaentity().name and string.sub(obj:get_luaentity().name,1,string.len("mob"))=="mob"
end


minetest.register_abm({
      label = "lava cooling",
      nodenames = {"feedlot:feedlot"},
      interval = 5,
      chance = 1,

      action = function (pos)
	 local fake_player = feedlotFakePlayer.create(pos, "fake_player")
	 local objs = minetest.get_objects_inside_radius(pos, 3)
	 for _,obj in ipairs(objs) do
	    if not obj:is_player() and obj:get_armor_groups().fleshy and obj:get_armor_groups().fleshy > 0 and is_mob(obj) then
	       --	       obj:on_rightclick(fake_player)
	       obj:get_luaentity():on_rightclick(fake_player)
--	       minetest.chat_send_all("animal fed")
	    end
	 end
      end,
})
	   
minetest.register_craft({
      	output = "feedlot:feedlot",
	recipe = {
	   {"","",""},
	   {"default:wood", "farming:seed_wheat", "default:wood"},
	   {"default:wood", "default:wood", "default:wood"}
}})