]> git.lizzy.rs Git - Crafter.git/commitdiff
Put in base for mobs
authorOilboi <oil.boi.minetest@gmail.com>
Mon, 17 Feb 2020 07:56:57 +0000 (02:56 -0500)
committerOilboi <oil.boi.minetest@gmail.com>
Mon, 17 Feb 2020 07:56:57 +0000 (02:56 -0500)
mods/mob/init.lua [new file with mode: 0644]
todo.txt

diff --git a/mods/mob/init.lua b/mods/mob/init.lua
new file mode 100644 (file)
index 0000000..a68aeb1
--- /dev/null
@@ -0,0 +1,28 @@
+--this is where mobs are defined
+minetest.register_globalstep(function(dtime)
+       --collection
+       for _,player in ipairs(minetest.get_connected_players()) do
+               --don't magnetize to dead players
+               if player:get_hp() > 0 then
+                       local pos = player:getpos()
+                       local inv = player:get_inventory()
+                       --radial detection
+                       for _,object in ipairs(minetest.get_objects_inside_radius({x=pos.x,y=pos.y+eye_height,z=pos.z}, 3)) do
+                               if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
+                                       if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
+                                               if object:get_luaentity().collectable == true and object:get_luaentity().collected == false then
+                                                       minetest.sound_play("pickup", {
+                                                               to_player = player,
+                                                               gain = 0.4,
+                                                               pitch = math.random(60,100)/100
+                                                       })
+                                                       inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
+                                                       object:moveto({x=pos.x,y=pos.y+eye_height,z=pos.z,continuous=true})
+                                                       object:get_luaentity().collected = true
+                                               end
+                                       end
+                               end
+                       end
+               end
+       end
+end)
index a2c1f6f42fac1ee5734d0131f2c98d2ca5f7959e..20b460947a32a1ce5b3a85e683c45b41b4a662bd 100644 (file)
--- a/todo.txt
+++ b/todo.txt
 --sand fall down
 --tnt throw player - and items
 --water flow faster
-torches with particle
+--torches with particle
+make a mob
 crafting bench
-make a mob?
 fishing
 bows
 3d character
+boat