First commit
[kebab.git] / init.lua
1 -- Kebab mod Copyright (C) 2017 Gabriel Pérez-Cerezo
2 --
3 --
4 -- This program is free software: you can redistribute it and/or modify
5 -- it under the terms of the GNU Affero General Public License as
6 -- published by the Free Software Foundation, either version 3 of the
7 -- License, or (at your option) any later version.
8
9 -- This program is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU Affero General Public License for more details.
13
14 -- You should have received a copy of the GNU Affero General Public License
15 -- along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17
18 kebab = {}
19 minetest.register_craftitem("kebab:kebab_meat", {
20 description = "Kebab Meat",
21 inventory_image = "kebab_meat.png",
22 })
23 minetest.register_craftitem("kebab:doner_kebab", {
24 description = "Kebab Sandwich",
25 inventory_image = "kebab_doener.png",
26 on_use = minetest.item_eat(8),
27 })
28 kebab.cut_kebab = function (pos)
29 local node = minetest.get_node(pos)
30 number = node.name:match("%d")
31 if tonumber(number) > 1 then
32 node.name = "kebab:kebab_"..number-1
33 minetest.swap_node(pos, node)
34 return "kebab:kebab_meat"
35 elseif tonumber(number) == 1 then
36 minetest.set_node(pos, {name="air"})
37 return "kebab:kebab_meat"
38 end
39 end
40
41 local function player_cut_kebab(pos, node, player)
42 if player:get_wielded_item():get_name():match("sword") and player:get_inventory():room_for_item("main", "kebab:kebab_meat") then
43 player:get_inventory():add_item("main", kebab.cut_kebab(pos))
44 end
45
46 end
47
48
49 minetest.register_node("kebab:kebab_4", {
50 tiles = {
51 "kebab_kebab.png",
52 "kebab_kebab.png",
53 "kebab_kebab.png",
54 "kebab_kebab.png",
55 "kebab_kebab.png",
56 "kebab_kebab.png"
57 },
58 description = "Kebab rotisserie",
59 drawtype = "nodebox",
60 paramtype = "light",
61 node_box = {
62 type = "fixed",
63 fixed = {
64 {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625}, -- NodeBox1
65 {-0.1875, -0.375, -0.1875, 0.1875, 0.375, 0.1875}, -- NodeBox2
66 {-0.3125, -0.0625, -0.3125, 0.3125, 0.375, 0.3125}, -- NodeBox3
67 {-0.25, -0.25, -0.25, 0.25, 0.375, 0.25}, -- NodeBox4
68 }
69 },
70 on_punch = player_cut_kebab,
71 })
72 minetest.register_node("kebab:kebab_3", {
73 tiles = {
74 "kebab_kebab.png",
75 "kebab_kebab.png",
76 "kebab_kebab.png",
77 "kebab_kebab.png",
78 "kebab_kebab.png",
79 "kebab_kebab.png"
80 },
81 drawtype = "nodebox",
82 description = "Kebab rotisserie",
83 paramtype = "light",
84 node_box = {
85 type = "fixed",
86 fixed = {
87 {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625}, -- NodeBox1
88 {-0.1875, -0.375, -0.1875, 0.1875, 0.375, 0.1875}, -- NodeBox2
89 -- {-0.3125, -0.0625, -0.3125, 0.3125, 0.375, 0.3125}, -- NodeBox3
90 {-0.25, -0.25, -0.25, 0.25, 0.375, 0.25}, -- NodeBox4
91 }
92 },
93 on_punch = player_cut_kebab,
94 })
95 minetest.register_node("kebab:kebab_2", {
96 tiles = {
97 "kebab_kebab.png",
98 "kebab_kebab.png",
99 "kebab_kebab.png",
100 "kebab_kebab.png",
101 "kebab_kebab.png",
102 "kebab_kebab.png"
103 },
104 drawtype = "nodebox",
105 paramtype = "light",
106 description = "Kebab rotisserie",
107 node_box = {
108 type = "fixed",
109 fixed = {
110 {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625}, -- NodeBox1
111 {-0.1875, -0.25, -0.1875, 0.1875, 0.375, 0.1875}, -- NodeBox2
112 {-0.125, -0.375, -0.125, 0.125, 0.375, 0.125}, -- NodeBox2
113 -- {-0.3125, -0.0625, -0.3125, 0.3125, 0.375, 0.3125}, -- NodeBox3
114 -- {-0.25, -0.25, -0.25, 0.25, 0.375, 0.25}, -- NodeBox4
115 }
116 },
117 on_punch = player_cut_kebab,
118 })
119 minetest.register_node("kebab:kebab_1", {
120 tiles = {
121 "kebab_kebab.png",
122 "kebab_kebab.png",
123 "kebab_kebab.png",
124 "kebab_kebab.png",
125 "kebab_kebab.png",
126 "kebab_kebab.png"
127 },
128 drawtype = "nodebox",
129 description = "Kebab rotisserie",
130 paramtype = "light",
131 node_box = {
132 type = "fixed",
133 fixed = {
134 {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625}, -- NodeBox1
135 {-0.125, -0.375, -0.125, 0.125, 0.375, 0.125}, -- NodeBox2
136 -- {-0.3125, -0.0625, -0.3125, 0.3125, 0.375, 0.3125}, -- NodeBox3
137 -- {-0.25, -0.25, -0.25, 0.25, 0.375, 0.25}, -- NodeBox4
138 }
139 },
140 on_punch = player_cut_kebab,
141 })
142
143 minetest.register_craft({
144 output = "kebab:doner_kebab",
145 type = "shapeless",
146 recipe = {"kebab:kebab_meat", "farming:bread"}
147
148 })
149 minetest.register_craft({
150 output = "kebab:kebab_4",
151 recipe = {{"", "default:stick", ""},
152 {"", "mobs:meat", ""},
153 {"", "default:stick", ""}}
154
155 })