diff --git a/mods/amogus_entities/entities/amogus_entity.lua b/mods/amogus_entities/entities/amogus_entity.lua new file mode 100644 index 0000000..2174d18 --- /dev/null +++ b/mods/amogus_entities/entities/amogus_entity.lua @@ -0,0 +1,57 @@ +local entity = { + physical = true, + collisionbox = {-0.5, 0, -0.5, 0.5, 1, 0.5}, + + visual = "mesh", + visual_size = {x=10, y=10, z=10}, + + mesh = "amogus_entity.obj", + textures = {"amogus_entity.png"}, + + on_rightclick = function(self, clicker) + minetest.chat_send_player(clicker:get_player_name(), "AMOGUS") + end, + + is_going_forward = true, + gravity = 9.81/60, + speed = 0.1, + + on_step = function(self, dtime) + -- Switch "is_going_forward" 1% chance randomly between true and false + if math.random(200) == 1 then + self.is_going_forward = not self.is_going_forward + end + + -- Go forward if "is_going_forward" is true + if self.is_going_forward then + local pos = self.object:get_pos() + local dir = self.object:get_yaw() + pos.x = pos.x + math.cos(dir) * self.speed + pos.z = pos.z + math.sin(dir) * self.speed + self.object:set_pos(pos) + end + + -- some chance of turning left or right + if math.random(50) == 1 then + self.object:set_yaw(self.object:get_yaw() + math.pi/2) + elseif math.random(50) == 1 then + self.object:set_yaw(self.object:get_yaw() - math.pi/2) + end + + -- Make it also jump when running into some block + local pos = self.object:get_pos() + local bnode = minetest.get_node(pos) + if bnode.name ~= "air" then + local vel = self.object:get_velocity() + vel.y = vel.y + 5 + self.object:set_velocity(vel) + end + + -- change velocity by gravity + local vel = self.object:get_velocity() + vel.y = vel.y - self.gravity + self.object:set_velocity(vel) + + end +} +minetest.register_entity("amogus_entities:amogus", entity) \ No newline at end of file diff --git a/mods/amogus_entities/init.lua b/mods/amogus_entities/init.lua new file mode 100644 index 0000000..87d8ff0 --- /dev/null +++ b/mods/amogus_entities/init.lua @@ -0,0 +1,2 @@ +-- Load the entity's lua file +dofile(minetest.get_modpath("amogus_entities") .. "/entities/amogus_entity.lua") diff --git a/mods/amogus_entities/models/amogus_entity.obj b/mods/amogus_entities/models/amogus_entity.obj new file mode 100644 index 0000000..7d6fccf --- /dev/null +++ b/mods/amogus_entities/models/amogus_entity.obj @@ -0,0 +1,154 @@ +# Blender v3.4.0 OBJ File: 'amogus.blend' +# www.blender.org +o body +v 0.250000 1.312500 -0.250000 +v 0.250000 1.312500 -0.375000 +v 0.250000 1.000000 -0.250000 +v 0.250000 1.000000 -0.375000 +v -0.250000 1.312500 -0.375000 +v -0.250000 1.312500 -0.250000 +v -0.250000 1.000000 -0.375000 +v -0.250000 1.000000 -0.250000 +v 0.312500 1.125000 0.437500 +v 0.312500 1.125000 0.250000 +v 0.312500 0.375000 0.437500 +v 0.312500 0.375000 0.250000 +v -0.312500 1.125000 0.250000 +v -0.312500 1.125000 0.437500 +v -0.312500 0.375000 0.250000 +v -0.312500 0.375000 0.437500 +v 0.375000 1.437500 0.250000 +v 0.375000 1.437500 -0.250000 +v 0.375000 0.312500 0.250000 +v 0.375000 0.312500 -0.250000 +v -0.375000 1.437500 -0.250000 +v -0.375000 1.437500 0.250000 +v -0.375000 0.312500 -0.250000 +v -0.375000 0.312500 0.250000 +vt 0.000000 0.687500 +vt 0.500000 0.687500 +vt 0.500000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.687500 +vt 0.125000 0.687500 +vt 0.125000 1.000000 +vt 0.000000 1.000000 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.125000 1.000000 +vt 0.000000 1.000000 +vt -0.000000 0.687500 +vt 0.125000 0.687500 +vt 0.500000 1.000000 +vt 0.000000 0.875000 +vt 0.500000 0.875000 +vt 0.000000 0.875000 +vt 0.500000 0.875000 +vt 0.500000 1.000000 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vn 0.0000 0.0000 -1.0000 +vn 1.0000 0.0000 0.0000 +vn -0.0000 -0.0000 1.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 -1.0000 -0.0000 +s off +f 4/1/1 7/2/1 5/3/1 2/4/1 +f 3/5/2 4/6/2 2/7/2 1/8/2 +f 12/9/3 19/10/3 17/11/3 10/12/3 +f 7/13/4 8/14/4 6/15/4 5/16/4 +f 6/17/5 1/8/5 2/18/5 5/19/5 +f 7/20/6 4/21/6 3/22/6 8/14/6 +f 13/23/3 10/12/3 17/11/3 22/24/3 +f 11/25/2 12/9/2 10/12/2 9/26/2 +f 16/27/3 11/25/3 9/26/3 14/28/3 +f 15/29/4 16/27/4 14/28/4 13/23/4 +f 14/28/5 9/26/5 10/12/5 13/23/5 +f 15/29/6 12/9/6 11/25/6 16/27/6 +f 15/29/3 13/23/3 22/24/3 24/30/3 +f 19/10/2 20/31/2 18/32/2 17/11/2 +f 23/33/4 24/30/4 22/24/4 21/34/4 +f 22/24/5 17/11/5 18/32/5 21/34/5 +f 23/33/6 20/31/6 19/10/6 24/30/6 +f 15/29/3 24/30/3 19/10/3 12/9/3 +f 6/35/1 21/34/1 18/32/1 1/36/1 +f 8/37/1 23/33/1 21/34/1 6/35/1 +f 3/38/1 1/36/1 18/32/1 20/31/1 +f 8/37/1 3/38/1 20/31/1 23/33/1 +o left_leg +v -0.062500 0.437500 0.187500 +v -0.062500 0.437500 -0.187500 +v -0.062500 -0.000000 0.187500 +v -0.062500 0.000000 -0.187500 +v -0.312500 0.437500 -0.187500 +v -0.312500 0.437500 0.187500 +v -0.312500 0.000000 -0.187500 +v -0.312500 -0.000000 0.187500 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vn 0.0000 0.0000 -1.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 -0.0000 1.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 -1.0000 -0.0000 +s off +f 28/39/7 31/40/7 29/41/7 26/42/7 +f 27/43/8 28/39/8 26/42/8 25/44/8 +f 32/45/9 27/43/9 25/44/9 30/46/9 +f 31/40/10 32/45/10 30/46/10 29/41/10 +f 30/46/11 25/44/11 26/42/11 29/41/11 +f 31/40/12 28/39/12 27/43/12 32/45/12 +o right_leg +v 0.312500 0.437500 0.187500 +v 0.312500 0.437500 -0.187500 +v 0.312500 -0.000000 0.187500 +v 0.312500 0.000000 -0.187500 +v 0.062500 0.437500 -0.187500 +v 0.062500 0.437500 0.187500 +v 0.062500 0.000000 -0.187500 +v 0.062500 -0.000000 0.187500 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vt 0.968971 0.969702 +vn 0.0000 0.0000 -1.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 -0.0000 1.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 -1.0000 -0.0000 +s off +f 36/47/13 39/48/13 37/49/13 34/50/13 +f 35/51/14 36/47/14 34/50/14 33/52/14 +f 40/53/15 35/51/15 33/52/15 38/54/15 +f 39/48/16 40/53/16 38/54/16 37/49/16 +f 38/54/17 33/52/17 34/50/17 37/49/17 +f 39/48/18 36/47/18 35/51/18 40/53/18 diff --git a/mods/amogus_entities/textures/amogus_entity.png b/mods/amogus_entities/textures/amogus_entity.png new file mode 100644 index 0000000..fc50eee Binary files /dev/null and b/mods/amogus_entities/textures/amogus_entity.png differ diff --git a/mods/amogus_items/init.lua b/mods/amogus_items/init.lua index 630981f..97a32d4 100644 --- a/mods/amogus_items/init.lua +++ b/mods/amogus_items/init.lua @@ -1,11 +1,30 @@ minetest.register_craftitem("amogus_items:amogus", { description = "Amogus", inventory_image = "amogus_item.png", + on_use = function(itemstack, user) minetest.sound_play("amogus_sound", { pos = user:get_pos(), gain = 1.0, max_hear_distance = 5 }) - end + end, + + --on_place = function(itemstack, placer, pointed_thing) + -- local pos = pointed_thing.above + -- local dir = placer:get_look_dir() + -- local yaw = math.atan(dir.x/dir.z) + -- if dir.z > 0 then + -- yaw = yaw + math.pi + -- end + -- minetest.add_entity(pos, "amogus_entities:amogus", yaw) + --end + + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.type == "node" then + local pos = pointed_thing.above + minetest.add_entity(pos, "amogus_entities:amogus") + end + return itemstack + end }) \ No newline at end of file