]> git.lizzy.rs Git - Crafter.git/blob - mods/utility/OLDCODE.txt
remove server debug
[Crafter.git] / mods / utility / OLDCODE.txt
1 --[[
2 Mechanic ideology
3
4 spawn 3 entities - cook fuel output
5
6 detect on x or z axis
7
8 use recipe cook time
9
10 then pass output to cooked entity
11
12 when player hits entity then drop item towards player
13
14 when cooking have fire and smoke on cooking item
15
16 ]]--
17
18 --furnace class
19 minetest.register_craftitem("utility:nothing", {
20         description = "Nothing",
21         inventory_image = "wood.png",
22 })
23
24 local furnace = {}
25 --gap = 0.55
26 local fuel_height = 0.75
27 local cook_height = 1.3
28 local output_height = 1.85
29
30 --furnace
31 function furnace.get_hotbar_bg(x,y)
32         local out = ""
33         for i=0,7,1 do
34                 out = out .."image["..x+i..","..y..";1,1;gui_furnace_arrow_bg.png]"
35         end
36         return(out)
37 end
38
39 function furnace.get_inventory_drops(pos, inventory, drops)
40         local inv = minetest.get_meta(pos):get_inventory()
41         local n = #drops
42         for i = 1, inv:get_size(inventory) do
43                 local stack = inv:get_stack(inventory, i)
44                 if stack:get_count() > 0 then
45                         drops[n+1] = stack:to_table()
46                         n = n + 1
47                 end
48         end
49 end
50 --local aftercooked
51 --cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
52 --cookable = cooked.time ~= 0
53 --
54 -- Node definitions
55 --
56
57 local function furnace_setup(pos)
58         local obj = minetest.add_entity(vector.new(pos.x,pos.y+fuel_height,pos.z), "utility:fuel")
59         obj:get_luaentity().set_item(obj:get_luaentity(),"utility:nothing")
60         local obj = minetest.add_entity(vector.new(pos.x,pos.y+cook_height,pos.z), "utility:cook")
61         obj:get_luaentity().set_item(obj:get_luaentity(),"utility:nothing")
62         local obj = minetest.add_entity(vector.new(pos.x,pos.y+output_height,pos.z), "utility:output")
63         obj:get_luaentity().set_item(obj:get_luaentity(),"utility:nothing")
64 end
65
66 local function furnace_remove(pos)
67         for _,object in ipairs(minetest.get_objects_inside_radius(vector.new(pos.x,pos.y+fuel_height,pos.z), 0.1)) do
68                 if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "utility:fuel" then
69                         local pos = object:getpos()
70                         local item = object:get_luaentity().itemstring
71                         if item ~= "utility:nothing" then
72                                 local obj = minetest.add_item(pos,item)                     
73                         end
74                         object:remove()
75                 end
76         end
77         for _,object in ipairs(minetest.get_objects_inside_radius(vector.new(pos.x,pos.y+cook_height,pos.z), 0.1)) do
78                 if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "utility:cook" then
79                         local pos = object:getpos()
80                         local item = object:get_luaentity().itemstring
81                         if item ~= "utility:nothing" then
82                                 local obj = minetest.add_item(pos,item)
83                         end
84                         object:remove()
85                 end
86         end
87         for _,object in ipairs(minetest.get_objects_inside_radius(vector.new(pos.x,pos.y+output_height,pos.z), 0.1)) do
88                 if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "utility:output" then
89                         local pos = object:getpos()
90                         local item = object:get_luaentity().itemstring
91                         if item ~= "utility:nothing" then
92                                 local obj = minetest.add_item(pos,item)
93                         end
94                         object:remove()
95                 end
96         end
97 end
98
99 minetest.register_node("utility:furnace", {
100         description = "Furnace",
101         tiles = {
102                 "furnace_top.png", "furnace_bottom.png",
103                 "furnace_side.png", "furnace_side.png",
104                 "furnace_side.png", "furnace_front.png"
105         },
106         paramtype2 = "facedir",
107         groups = {stone=2},
108         legacy_facedir_simple = true,
109         is_ground_content = false,
110         sounds = main.stoneSound(),
111         on_construct = function(pos)
112                 furnace_setup(pos)
113         end,
114         on_destruct = function(pos)
115                 furnace_remove(pos)
116         end,
117 })
118
119 minetest.register_craft({
120         output = "utility:furnace",
121         recipe = {
122                 {"main:stone", "main:stone", "main:stone"},
123                 {"main:stone", "",           "main:stone"},
124                 {"main:stone", "main:stone", "main:stone"},
125         }
126 })
127
128 --------------------------------------------------------------------------------------------------
129 --[[
130
131 minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) --check if cookable
132
133 minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) --check if fuel
134
135 space in between = 0.55
136
137 ]]--
138
139
140 --fuel entity
141 minetest.register_entity("utility:fuel", {
142         initial_properties = {
143                 hp_max = 1,
144                 physical = true,
145                 collide_with_objects = false,
146                 collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
147                 visual = "wielditem",
148                 visual_size = {x = 0.6, y = 0.6},
149                 textures = {""},
150                 spritediv = {x = 1, y = 1},
151                 initial_sprite_basepos = {x = 0, y = 0},
152                 is_visible = false,
153                 pointable = true,
154         },
155
156         itemstring = "",
157         count = 0,
158         cooking = false,
159         cook_timer = false,
160         fuel_timer = 0,
161
162         set_item = function(self, item)
163                 local stack = ItemStack(item or self.itemstring)
164                 self.itemstring = stack:to_string()
165                 --if self.itemstring == "" then
166                         -- item not yet known
167                 --      return
168                 --end
169                 
170                 local count = stack:get_count()
171                 self.count = count
172
173                 -- Backwards compatibility: old clients use the texture
174                 -- to get the type of the item
175                 local itemname = stack:is_known() and stack:get_name() or "unknown"
176
177                 local max_count = stack:get_stack_max()
178                 local size = 0.25
179                 local coll_height = size * 0.75
180                 local def = minetest.registered_nodes[itemname]
181                 --local glow = def and def.light_source
182
183                 self.object:set_properties({
184                         is_visible = true,
185                         visual = "wielditem",
186                         textures = {itemname},
187                         visual_size = {x = size, y = size},
188                         --collisionbox = {-size, -coll_height, -size,
189                         --      size, coll_height, size},
190                         selectionbox = {-size, -size, -size, size, size, size},
191                         automatic_rotate = math.pi * 0.5 * 0.2 / size,
192                         wield_item = self.itemstring,
193                         glow = glow,
194                 })
195         end,
196
197         get_staticdata = function(self)
198                 return minetest.serialize({
199                         itemstring = self.itemstring,
200                         count = self.count,                     
201                 })
202         end,
203
204         on_activate = function(self, staticdata, dtime_s)
205                 if string.sub(staticdata, 1, string.len("return")) == "return" then
206                         local data = minetest.deserialize(staticdata)
207                         if data and type(data) == "table" then
208                                 self.itemstring = data.itemstring
209                                 self.count = data.count
210                         end
211                 else
212                         self.itemstring = staticdata
213                 end
214                 self.object:set_armor_groups({immortal = 1})
215                 self.object:set_velocity({x = 0, y = 0, z = 0})
216                 self.object:set_acceleration({x = 0, y = 0, z = 0})
217                 self:set_item()
218         end,
219         
220         on_rightclick = function(self, clicker)
221                 
222                 if not clicker or not clicker:is_player() then
223                         return
224                 end
225                 
226                 local stack = clicker:get_wielded_item()
227                 
228                 local item = stack:get_name()
229                 local count = stack:get_count()
230                 if stack:get_name() == "utility:nothing" then
231                         count = 0
232                 end
233                 
234                 --shoot out existing item
235                 if self.itemstring ~= item.." "..count and self.itemstring ~= "utility:nothing" then
236                         local pos = self.object:getpos()
237                         local pos2 = clicker:getpos()
238                         pos2.y = pos2.y + 1.25
239                         local obj = minetest.add_item(pos,self.itemstring)
240                         local dir = vector.subtract(pos2,pos)
241                         vector.multiply(dir,5)
242                         
243                         if obj then
244                                 obj:setvelocity(vector.new(dir.x,dir.y+3.5,dir.z))
245                         else
246                                 print("ERROR FURNACE RELEASED NON ITEM")
247                         end
248                 end
249                 
250                 if (item == "" or item == "hand:player") then
251                         self.set_item(self,"utility:nothing")
252                         self.object:set_nametag_attributes({
253                                 color = "red",
254                                 text = "",
255                         })
256                         return
257                 end
258                                 
259                 self.set_item(self, item.." "..count)
260                 
261                 self.object:set_nametag_attributes({
262                         color = "red",
263                         text = minetest.registered_items[item].description.." "..count,
264                 })
265                 
266                 stack = stack:clear()
267                 clicker:set_wielded_item("")
268         end,
269         
270         on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
271                 if not puncher or not puncher:is_player() then
272                         return
273                 end
274                 
275                 if self.itemstring == "utility:nothing" then
276                         return
277                 end
278                 
279                 local pos = self.object:getpos()
280                 local pos2 = puncher:getpos()
281                 pos2.y = pos2.y + 1.25
282                                 
283                 local obj = minetest.add_item(pos,self.itemstring)
284                 local dir = vector.subtract(pos2,pos)
285                 vector.multiply(dir,5)
286                 
287                 self.set_item(self,"utility:nothing")
288                 self.object:set_nametag_attributes({
289                         color = "red",
290                         text = "",
291                 })
292                 
293                 if obj then
294                         obj:setvelocity(vector.new(dir.x,dir.y+3.5,dir.z))
295                 else
296                         print("ERROR FURNACE RELEASED NON ITEM")
297                 end
298         end,
299
300         check_cook = function(self)
301                 local pos = self.object:getpos()
302                 --check the cook timer
303                 for _,object in ipairs(minetest.get_objects_inside_radius(vector.new(pos.x,pos.y+0.55,pos.z), 0.1)) do
304                         if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "utility:cook" then
305                                 local item = object:get_luaentity().itemstring
306                                 return(minetest.get_craft_result({method = "cooking", width = 1, items = {ItemStack(item)}}).time)
307                         end
308                 end
309         end,
310         
311         cook_item = function(self)
312                 local pos = self.object:getpos()
313                 for _,object in ipairs(minetest.get_objects_inside_radius(vector.new(pos.x,pos.y+0.55,pos.z), 0.1)) do
314                         if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "utility:cook" then
315                                 local item = ItemStack(object:get_luaentity().itemstring)
316                                 if not item then
317                                         return
318                                 end
319                                 local count = object:get_luaentity().count
320                                 local output = minetest.get_craft_result({method = "cooking", width = 1, items = {ItemStack(item)}}).item
321                                 local outputitem =  output:get_name()
322                                 local outputcount = output:get_count()
323                                 
324                                 
325                                 local itemname = item:get_name()
326                                 
327                                 count = count - 1
328                                 
329                                 object:get_luaentity().count = count
330                                 
331                                 local pos = self.object:getpos()
332                                 
333                                 --add to output
334                                 for _,object2 in ipairs(minetest.get_objects_inside_radius(vector.new(pos.x,pos.y+1.10,pos.z), 0.1)) do
335                                         if not object2:is_player() and object2:get_luaentity() and object2:get_luaentity().name == "utility:output" then
336                                                 local goal_item = ItemStack(object2:get_luaentity().itemstring)
337                                                 local goal_item_name = goal_item:get_name()
338                                                 local goal_item_count = goal_item:get_count()
339                                                 
340                                                 --cancel out if player took item
341                                                 if outputitem == "" then
342                                                         return
343                                                 end
344                                                 
345                                                 --add item to output or throw existing item out if not matched
346                                                 if goal_item_name ~= outputitem and goal_item_name ~= "utility:nothing" then
347                                                         local pos2 = object2:get_pos()
348                                                         local obj = minetest.add_item(pos2,object2:get_luaentity().itemstring)
349                                                         local dir = vector.new(math.random(-3,3),math.random(3,6),math.random(-3,3))
350                                                         --dir = vector.multiply(dir,2)
351                                                                                                                 
352                                                         if obj then
353                                                                 obj:setvelocity(vector.new(dir.x,dir.y,dir.z))
354                                                         else
355                                                                 print("ERROR FURNACE RELEASED NON ITEM")
356                                                         end
357                                                         object2:get_luaentity().count = 0
358                                                 end
359                                                 
360                                                 object2:get_luaentity().count =  object2:get_luaentity().count + outputcount
361                                                 object2:get_luaentity().set_item(object2:get_luaentity(), outputitem.." "..object2:get_luaentity().count)
362                                                 object2:set_nametag_attributes({
363                                                         color = "blue",
364                                                         text = outputitem.." "..object2:get_luaentity().count,
365                                                 })
366                                                 
367                                         end
368                                 end
369                                 
370                                 --update count and nametag
371                                 if object:get_luaentity().count == 0 then
372                                         object:get_luaentity().set_item(object:get_luaentity(), "utility:nothing")
373                                         object:set_nametag_attributes({
374                                                 color = "blue",
375                                                 text = "",
376                                         })
377                                 else
378                                         object:get_luaentity().set_item(object:get_luaentity(), itemname.." "..count)
379                                         object:set_nametag_attributes({
380                                                 color = "blue",
381                                                 text = itemname.." "..count,
382                                         })
383                                 end
384                         end
385                 end
386         end,
387         
388         spawn_particles = function(self,time)
389                 --print("time:"..time)
390                 local pos = self.object:getpos()
391                 minetest.add_particlespawner({
392                         amount = math.floor(10*time),
393                         time = time,
394                         minpos = vector.new(pos.x-0.3,pos.y-0.3,pos.z-0.3),
395                         maxpos = vector.new(pos.x+0.3,pos.y+0.3,pos.z+0.3),
396                         minvel = {x=0, y=0.2, z=0},
397                         maxvel = {x=0, y=0.5, z=0},
398                         minacc = {x=0, y=0, z=0},
399                         maxacc = {x=0, y=0, z=0},
400                         minexptime = 1.1,
401                         maxexptime = 1.3,
402                         minsize = 1,
403                         maxsize = 2,
404                         collisiondetection = false,
405                         vertical = true,
406                         texture = "flame.png",
407                 })
408                 
409                 
410                 minetest.add_particlespawner({
411                         amount = math.floor(10*time),
412                         time = time,
413                         minpos = vector.new(pos.x-0.3,pos.y+0.3,pos.z-0.3),
414                         maxpos = vector.new(pos.x+0.3,pos.y+0.6,pos.z+0.3),
415                         minvel = {x=0, y=0.2, z=0},
416                         maxvel = {x=0, y=0.7, z=0},
417                         minacc = {x=0, y=0, z=0},
418                         maxacc = {x=0, y=0, z=0},
419                         minexptime = 1.1,
420                         maxexptime = 1.5,
421                         minsize = 1,
422                         maxsize = 2,
423                         collisiondetection = false,
424                         vertical = false,
425                         texture = "smoke.png",
426                 })
427         end,
428         
429         
430         
431         --check if item is in the input then cook if so
432         on_step = function(self, dtime)
433                 if self.cooking == true then
434                         self.cooking_timer = self.cooking_timer - dtime
435                         if self.cooking_timer < 0 then
436                                 self.cooking_timer = 0
437                                 self.cook_item(self)
438                                 self.cooking = false
439                         end                                     
440                 end
441                 
442                 --check to start cooking countdown
443                 if self.cooking == false then
444                         local stack = ItemStack(self.itemstring)
445                         local fuel = minetest.get_craft_result({method =  "fuel", width = 1, items = {stack}}).time
446                         if fuel ~= 0 then
447                                 local cookie = self.check_cook(self)
448                                 if cookie ~= 0 then
449                                         --print("starting timer")
450                                         self.spawn_particles(self,fuel)
451                                         self.cooking_timer = cookie
452                                         self.cooking = true
453                                         --set up the fuel timer
454                                         if self.fuel_timer == 0 then
455                                                 self.fuel_timer = fuel
456                                         end
457                                 end
458                         end
459                 end
460                 
461                 --deplete fuel
462                 if self.fuel_timer >= 0 then
463                         self.fuel_timer = self.fuel_timer - dtime
464                         --print(self.fuel_timer)
465                 elseif self.fuel_timer < 0 then
466                         if ItemStack(self.itemstring):get_name() == "utility:nothing" then
467                                 return
468                         end
469                         if self.cooking == false then
470                                 return
471                         end
472                         self.count = self.count - 1
473                         
474                         local count = self.count
475                         local itemname = ItemStack(self.itemstring):get_name()
476                         
477                         if self.count == 0 then
478                                 self.set_item(self, "utility:nothing")
479                                 self.object:set_nametag_attributes({
480                                         color = "red",
481                                         text = "",
482                                 })
483                         else
484                                 self.set_item(self, itemname.." "..count)
485                                 self.object:set_nametag_attributes({
486                                         color = "red",
487                                         text = itemname.." "..count,
488                                 })
489                         end
490                         
491                         if self.count == 0 then 
492                                 return
493                         end
494                         
495                         --reset timer
496                         if self.cooking == true then
497                                 --print("resetting timer")
498                                 local time = minetest.get_craft_result({method =  "fuel", width = 1, items = {ItemStack(self.itemstring)}}).time
499                                 self.fuel_timer = time
500                         end
501                 end
502         end,    
503 })
504
505 ----------------------------------------------------------------------------
506 --cook entity
507 minetest.register_entity("utility:cook", {
508         initial_properties = {
509                 hp_max = 1,
510                 physical = true,
511                 collide_with_objects = false,
512                 collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
513                 visual = "wielditem",
514                 visual_size = {x = 0.6, y = 0.6},
515                 textures = {""},
516                 spritediv = {x = 1, y = 1},
517                 initial_sprite_basepos = {x = 0, y = 0},
518                 is_visible = false,
519                 pointable = true,
520         },
521
522         itemstring = "",
523         count = 0,
524
525         set_item = function(self, item)
526                 local stack = ItemStack(item or self.itemstring)
527                 self.itemstring = stack:to_string()
528                 --if self.itemstring == "" then
529                         -- item not yet known
530                 --      return
531                 --end
532                 
533                 local count = stack:get_count()
534                 if stack:get_name() == "utility:nothing" then
535                         count = 0
536                 end
537                 self.count = count
538
539                 -- Backwards compatibility: old clients use the texture
540                 -- to get the type of the item
541                 local itemname = stack:is_known() and stack:get_name() or "unknown"
542
543                 local max_count = stack:get_stack_max()
544                 local size = 0.25
545                 local coll_height = size * 0.75
546                 local def = minetest.registered_nodes[itemname]
547                 --local glow = def and def.light_source
548
549                 self.object:set_properties({
550                         is_visible = true,
551                         visual = "wielditem",
552                         textures = {itemname},
553                         visual_size = {x = size, y = size},
554                         --collisionbox = {-size, -coll_height, -size,
555                         --      size, coll_height, size},
556                         selectionbox = {-size, -size, -size, size, size, size},
557                         automatic_rotate = math.pi * 0.5 * 0.2 / size,
558                         wield_item = self.itemstring,
559                         glow = glow,
560                 })
561         end,
562
563         get_staticdata = function(self)
564                 return minetest.serialize({
565                         itemstring = self.itemstring,
566                         count = self.count,                     
567                 })
568         end,
569
570         on_activate = function(self, staticdata, dtime_s)
571                 if string.sub(staticdata, 1, string.len("return")) == "return" then
572                         local data = minetest.deserialize(staticdata)
573                         if data and type(data) == "table" then
574                                 self.itemstring = data.itemstring
575                                 self.count = data.count
576                         end
577                 else
578                         self.itemstring = staticdata
579                 end
580                 self.object:set_armor_groups({immortal = 1})
581                 self.object:set_velocity({x = 0, y = 0, z = 0})
582                 self.object:set_acceleration({x = 0, y = 0, z = 0})
583                 self:set_item()
584         end,
585         
586         on_rightclick = function(self, clicker)
587                 
588                 if not clicker or not clicker:is_player() then
589                         return
590                 end
591                 
592                 local stack = clicker:get_wielded_item()
593                 
594                 local item = stack:get_name()
595                 local count = stack:get_count()
596                 
597                 --shoot out existing item
598                 if self.itemstring ~= item.." "..count and self.itemstring ~= "utility:nothing" then
599                         local pos = self.object:getpos()
600                         local pos2 = clicker:getpos()
601                         pos2.y = pos2.y + 1.25
602                         local obj = minetest.add_item(pos,self.itemstring)
603                         local dir = vector.subtract(pos2,pos)
604                         vector.multiply(dir,5)
605                         
606                         if obj then
607                                 obj:setvelocity(vector.new(dir.x,dir.y+3.5,dir.z))
608                         else
609                                 print("ERROR FURNACE RELEASED NON ITEM")
610                         end
611                 end
612                 
613                 if (item == "" or item == "hand:player") then
614                         self.set_item(self,"utility:nothing")
615                         self.object:set_nametag_attributes({
616                                 color = "blue",
617                                 text = "",
618                         })
619                         return
620                 end
621                                 
622                 self.set_item(self, item.." "..count)
623                 
624                 self.object:set_nametag_attributes({
625                         color = "blue",
626                         text = minetest.registered_items[item].description.." "..count,
627                 })
628                 
629                 stack = stack:clear()
630                 clicker:set_wielded_item("")
631         end,
632         
633         on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
634                 if not puncher or not puncher:is_player() then
635                         return
636                 end
637                 
638                 if self.itemstring == "utility:nothing" then
639                         return
640                 end
641                 
642                 local pos = self.object:getpos()
643                 local pos2 = puncher:getpos()
644                 pos2.y = pos2.y + 1.25
645                                 
646                 local obj = minetest.add_item(pos,self.itemstring)
647                 local dir = vector.subtract(pos2,pos)
648                 vector.multiply(dir,5)
649                 
650                 self.set_item(self,"utility:nothing")
651                 self.object:set_nametag_attributes({
652                         color = "blue",
653                         text = "",
654                 })
655                 
656                 if obj then
657                         obj:setvelocity(vector.new(dir.x,dir.y+3.5,dir.z))
658                 else
659                         print("ERROR FURNACE RELEASED NON ITEM")
660                 end
661         end,
662
663
664         on_step = function(self, dtime)
665                 --set glow if cooking
666                 --local glow = def and def.light_source
667         end,
668 })
669 ----------------------------------------------------------------------------
670 --ouput entity
671 minetest.register_entity("utility:output", {
672         initial_properties = {
673                 hp_max = 1,
674                 physical = true,
675                 collide_with_objects = false,
676                 collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
677                 visual = "wielditem",
678                 visual_size = {x = 0.6, y = 0.6},
679                 textures = {""},
680                 spritediv = {x = 1, y = 1},
681                 initial_sprite_basepos = {x = 0, y = 0},
682                 is_visible = false,
683                 pointable = true,
684         },
685
686         itemstring = "",
687         count = 0,
688
689         set_item = function(self, item)
690                 local stack = ItemStack(item or self.itemstring)
691                 self.itemstring = stack:to_string()
692                 --if self.itemstring == "" then
693                         -- item not yet known
694                 --      return
695                 --end
696                 
697                 local count = stack:get_count()
698                 if stack:get_name() == "utility:nothing" then
699                         count = 0
700                 end
701                 self.count = count
702
703                 -- Backwards compatibility: old clients use the texture
704                 -- to get the type of the item
705                 local itemname = stack:is_known() and stack:get_name() or "unknown"
706
707                 local max_count = stack:get_stack_max()
708                 local size = 0.25
709                 local coll_height = size * 0.75
710                 local def = minetest.registered_nodes[itemname]
711                 --local glow = def and def.light_source
712
713                 self.object:set_properties({
714                         is_visible = true,
715                         visual = "wielditem",
716                         textures = {itemname},
717                         visual_size = {x = size, y = size},
718                         --collisionbox = {-size, -coll_height, -size,
719                         --      size, coll_height, size},
720                         selectionbox = {-size, -size, -size, size, size, size},
721                         automatic_rotate = math.pi * 0.5 * 0.2 / size,
722                         wield_item = self.itemstring,
723                         glow = glow,
724                 })
725         end,
726
727         get_staticdata = function(self)
728                 return minetest.serialize({
729                         itemstring = self.itemstring,
730                         count = self.count,                     
731                 })
732         end,
733
734         on_activate = function(self, staticdata, dtime_s)
735                 if string.sub(staticdata, 1, string.len("return")) == "return" then
736                         local data = minetest.deserialize(staticdata)
737                         if data and type(data) == "table" then
738                                 self.itemstring = data.itemstring
739                                 self.count = data.count
740                         end
741                 else
742                         self.itemstring = staticdata
743                 end
744                 self.object:set_armor_groups({immortal = 1})
745                 self.object:set_velocity({x = 0, y = 0, z = 0})
746                 self.object:set_acceleration({x = 0, y = 0, z = 0})
747                 self:set_item()
748         end,
749                 
750         on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
751                 if not puncher or not puncher:is_player() then
752                         return
753                 end
754                 
755                 if self.itemstring == "utility:nothing" then
756                         return
757                 end
758                 
759                 self.count = 0
760                 
761                 local pos = self.object:getpos()
762                 local pos2 = puncher:getpos()
763                 pos2.y = pos2.y + 1.25
764                                 
765                 local obj = minetest.add_item(pos,self.itemstring)
766                 local dir = vector.subtract(pos2,pos)
767                 vector.multiply(dir,5)
768                 
769                 self.set_item(self,"utility:nothing")
770                 self.object:set_nametag_attributes({
771                         color = "blue",
772                         text = "",
773                 })
774                 
775                 if obj then
776                         obj:setvelocity(vector.new(dir.x,dir.y+3.5,dir.z))
777                 else
778                         print("ERROR FURNACE RELEASED NON ITEM")
779                 end
780         end,
781
782
783         on_step = function(self, dtime)
784                 --set glow if cooking
785                 --local glow = def and def.light_source
786         end,
787 })
788
789
790 minetest.register_craft({
791         output = "utility:furnace",
792         recipe = {
793                 {"main:cobble", "main:cobble", "main:cobble"},
794                 {"main:cobble", "", "main:cobble"},
795                 {"main:cobble", "main:cobble", "main:cobble"},
796         },
797 })