minetest.register_alias("mapgen_stone", "main:stone")
minetest.register_alias("mapgen_dirt", "main:dirt")
minetest.register_alias("mapgen_dirt_with_grass", "main:grass")
-minetest.register_alias("mapgen_water_source", "main:waterSource")
+minetest.register_alias("mapgen_water_source", "main:water")
minetest.register_alias("mapgen_sand", "main:sand")
minetest.register_alias("mapgen_tree", "main:tree")
minetest.register_alias("mapgen_leaves", "main:leaves")
depth_filler = 3,
node_riverbed = "main:sand",
depth_riverbed = 2,
- node_cave_liquid = "main:waterSource",
+ node_cave_liquid = "main:water",
--node_dungeon = "main:cobble",
--node_dungeon_alt = "default:mossycobble",
--node_dungeon_stair = "stairs:stair_cobble",
},
})
-minetest.register_node("main:waterSource", {
+minetest.register_node("main:water", {
description = "Water Source",
drawtype = "liquid",
waving = 3,
drop = "",
drowning = 1,
liquidtype = "source",
- liquid_alternative_flowing = "main:waterFlow",
- liquid_alternative_source = "main:waterSource",
+ liquid_alternative_flowing = "main:waterflow",
+ liquid_alternative_source = "main:water",
liquid_viscosity = 1,
post_effect_color = {a = 103, r = 30, g = 60, b = 90},
groups = {water = 1, liquid = 1, cools_lava = 1, bucket = 1, source = 1},
--sounds = default.node_sound_water_defaults(),
})
-minetest.register_node("main:waterFlow", {
+minetest.register_node("main:waterflow", {
description = "Water Flow",
drawtype = "flowingliquid",
waving = 3,
drop = "",
drowning = 1,
liquidtype = "flowing",
- liquid_alternative_flowing = "main:waterFlow",
- liquid_alternative_source = "main:waterSource",
+ liquid_alternative_flowing = "main:waterflow",
+ liquid_alternative_source = "main:water",
liquid_viscosity = 1,
post_effect_color = {a = 103, r = 30, g = 60, b = 90},
groups = {water = 1, liquid = 1, notInCreative = 1, cools_lava = 1},
--print(id,tool,level,material)
local groupcaps
if group[id] == "dirt" then
- groupcaps2={dirt = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=level*20, maxlevel=level},}
+ groupcaps2={dirt = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=(level/2)*5, maxlevel=level},}
end
if group[id] == "wood" then
- groupcaps2={wood = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=level*20, maxlevel=level},}
+ groupcaps2={wood = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=(level/2)*5, maxlevel=level},}
end
if group[id] == "stone" then
- groupcaps2={stone = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=level*20, maxlevel=level},}
+ groupcaps2={stone = {times={[4]=4-level/2,[3]=3.5-level/2,[2]=3.0-level/2,[1]=2.8-level/2}, uses=(level/2)*5, maxlevel=level},}
end
minetest.register_tool("main:"..material..tool, {
description = material:gsub("^%l", string.upper).." "..tool:gsub("^%l", string.upper),
groupcaps=groupcaps2,
--damage_groups = {fleshy=2},
},
- sound = {breaks = "default_tool_breaks"}, -- change this
+ sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
groups = {flammable = 2, tool=1 }
})
end
groupcaps={leaves = {times={[4]=0.7,[3]=0.7,[2]=0.7,[1]=0.7}, uses=level*20, maxlevel=4},},
damage_groups = {fleshy=3},
},
- sound = {breaks = "default_tool_breaks"}, -- change this
+ sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
groups = {weapon=1 }
})
end
visual_size = {x=1, y=1},
textures = {"minecart.png"},
automatic_face_movement_dir = 90.0,
+ automatic_face_movement_max_rotation_per_sec = 600,
},
rider = nil,
if minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name].walkable then
minetest.set_node(pointed_thing.above, {name="minecart:rail"})
itemstack:take_item(1)
+ print(minetest.get_node(pointed_thing.above).param1)
return(itemstack)
end
end,
--this is where mobs are defined
-local timer = 0
-minetest.register_globalstep(function(dtime)
- timer = timer + dtime
- if timer >= 0.5 then
- timer = 0
- --check through players
- for _,player in ipairs(minetest.get_connected_players()) do
- --don't spawn near dead players
- if player:get_hp() > 0 then
-
- local mob_number = math.random(0,2)
-
- local pos = vector.floor(vector.add(player:getpos(),0.5))
-
- local checkpos = minetest.find_nodes_in_area_under_air(vector.new(pos.x-50,pos.y-50,pos.z-50), vector.new(pos.x+50,pos.y+50,pos.z+50), {"main:grass","main:sand"})
-
-
- --[[
- local block = vector.floor(vector.divide(pos,16))
- block = vector.multiply(block, 16) --get the chunk actual base
- for x = 0,15 do
- for y = 0,15 do
- for z = 0,15 do
-
- if minetest.get_node(vector.new(block.x+x,block.y+y-1,block.z+z)).name ~= "air" and minetest.get_node(vector.new(block.x+x,block.y+y,block.z+z)).name == "air" then
-
- minetest.add_particle({
- pos = vector.new(block.x+x,block.y+y,block.z+z),
- velocity = {x=0, y=0, z=0},
- acceleration = {x=0, y=0, z=0},
- -- Spawn particle at pos with velocity and acceleration
- expirationtime = 0.5,
- -- Disappears after expirationtime seconds
- size = 2,
- -- Scales the visual size of the particle texture.
+local path = minetest.get_modpath(minetest.get_current_modname())
- collisiondetection = false,
- -- If true collides with `walkable` nodes and, depending on the
- -- `object_collision` field, objects too.
+dofile(path.."/spawning.lua")
+dofile(path.."/items.lua")
- collision_removal = false,
- -- If true particle is removed when it collides.
- -- Requires collisiondetection = true to have any effect.
+local max_speed = 0.5
- object_collision = false,
- -- If true particle collides with objects that are defined as
- -- `physical = true,` and `collide_with_objects = true,`.
- -- Requires collisiondetection = true to have any effect.
+minetest.register_entity("mob:pig", {
+ initial_properties = {
+ hp_max = 1,
+ physical = true,
+ collide_with_objects = false,
+ collisionbox = {-0.45, -0.01, -0.45, 0.45, 0.865, 0.45},
+ visual = "mesh",
+ visual_size = {x = 3, y = 3},
+ mesh = "pig.b3d",
+ textures = {
+ "nothing.png", -- baby
+ "pig.png", -- base
+ "nothing.png", -- saddle
+ },
+ is_visible = true,
+ pointable = true,
+ automatic_face_movement_dir = -90.0,
+ automatic_face_movement_max_rotation_per_sec = 300,
+ },
- vertical = false,
- -- If true faces player using y axis only
+ timer = 0,
+ hp = 5,
+ direction_timer = 0,
+ direction_timer_goal = 0,
+ direction_change = false,
+ change_direction = false,
+ speed = 0,
+ direction_goal = vector.new(0,0,0),
- texture = "dirt.png",
- })
- end
- end
- end
- end
- ]]--
+ get_staticdata = function(self)
+ return minetest.serialize({
+ --range = self.range,
+ hp = self.hp,
+ })
+ end,
+
+ on_activate = function(self, staticdata, dtime_s)
+ self.object:set_armor_groups({immortal = 1})
+ --self.object:set_velocity({x = math.random(-5,5), y = 5, z = math.random(-5,5)})
+ self.object:set_acceleration({x = 0, y = -9.81, z = 0})
+ if string.sub(staticdata, 1, string.len("return")) == "return" then
+ local data = minetest.deserialize(staticdata)
+ if data and type(data) == "table" then
+ --self.range = data.range
+ self.hp = data.hp
end
end
- end
-end)
+ self.object:set_animation({x=0,y=40}, 20, 0, true)
+ self.object:set_hp(self.hp)
+ end,
+
+ on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
+ self.jump(self,true)
+ local hurt = tool_capabilities.damage_groups.fleshy
+ local hp = self.object:get_hp()
+ self.object:set_hp(hp-hurt)
+ if hp > 1 then
+ minetest.sound_play("hurt", {object=self.object, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100})
+ end
+ self.hp = hp-hurt
+ end,
+
+ on_death = function(self, killer)
+ local pos = self.object:getpos()
+ pos.y = pos.y + 0.4
+ minetest.sound_play("mob_die", {pos = pos, gain = 1.0})
+ minetest.add_particlespawner({
+ amount = 40,
+ time = 0.001,
+ minpos = pos,
+ maxpos = pos,
+ minvel = vector.new(-5,-5,-5),
+ maxvel = vector.new(5,5,5),
+ minacc = {x=0, y=0, z=0},
+ maxacc = {x=0, y=0, z=0},
+ minexptime = 1.1,
+ maxexptime = 1.5,
+ minsize = 1,
+ maxsize = 2,
+ collisiondetection = false,
+ vertical = false,
+ texture = "smoke.png",
+ })
+ local obj = minetest.add_item(pos,"mob:raw_porkchop")
+ obj:get_luaentity().collection_timer = 2
+ end,
+
+ --this makes the mob change it's direction when aimlessly walking
+ direction = function(self,dtime)
+ self.direction_timer = self.direction_timer + dtime
+
+ self.change_direction = false
+
+ --change direction
+ if self.direction_timer >= self.direction_timer_goal then
+ --print("changing direction")
+ self.direction_timer = 0
+ self.direction_timer_goal = math.random(2,4)
+ self.change_direction = true
+ end
+ end,
+
+ --this sets a random direction and speed when walking
+ walk_random = function(self)
+ if self.change_direction == true then
+ self.direction_goal = vector.new(math.random(-2,2),0,math.random(-2,2))
+ self.speed = math.random(1,2)
+
+ --print(dump(self.direction_goal))
+ end
+ end,
+
+
+ --This makes the mob walk at a certain speed
+ move = function(self)
+ local vel = self.object:getvelocity()
+ local goal = self.direction_goal
+ local acceleration = vector.new(goal.x-vel.x,0,goal.z-vel.z)
+ self.object:add_velocity(acceleration)
+ end,
+
+ --make the mob jump
+ jump = function(self,punched)
+ local pos = self.object:getpos()
+ local ray = Raycast(pos, vector.add(pos,self.direction_goal), false, false)
+ local vel = self.object:getvelocity()
+
+ if (punched or ray:next()) and minetest.get_node(vector.new(pos.x,pos.y-0.02,pos.z)).name ~= "air" and self.swimming == false then
+ --print("jump")
+ local vel = self.object:getvelocity()
+ local goal = 5
+ local acceleration = vector.new(0,goal-vel.y,0)
+ self.object:add_velocity(acceleration)
+ end
+ end,
+
+ --makes the mob swim
+ swim = function(self)
+ local pos = self.object:getpos()
+ pos.y = pos.y + 0.4
+ local node = minetest.get_node(pos).name
+ local vel = self.object:getvelocity()
+ local goal = 1
+ local acceleration = vector.new(0,goal-vel.y,0)
+ self.swimming = false
+
+ if node == ("main:water" or "main:water_flow") then
+ self.swimming = true
+ self.object:add_velocity(acceleration)
+ end
+ end,
+
+ --sets the mob animation and speed
+ set_animation = function(self)
+ local distance = vector.distance(vector.new(0,0,0), self.direction_goal)
+ self.object:set_animation_frame_speed(distance*20)
+ end,
+
+ on_step = function(self, dtime)
+ self.direction(self,dtime)
+ if not self.path then
+ self.walk_random(self)
+ end
+
+ self.move(self)
+ self.swim(self)
+ self.jump(self,false)
+ self.set_animation(self)
+ end,
+})
--- /dev/null
+--items
+minetest.register_craftitem("mob:raw_porkchop", {
+ description = "Raw Porkchop",
+ inventory_image = "raw_porkchop.png",
+})
+minetest.register_craftitem("mob:cooked_porkchop", {
+ description = "Cooked Porkchop",
+ inventory_image = "cooked_porkchop.png",
+})
+
+--cooking
+minetest.register_craft({
+ type = "cooking",
+ output = "mob:cooked_porkchop",
+ recipe = "mob:raw_porkchop",
+ cooktime = 3,
+})
--- /dev/null
+--this is where mob spawning is defined
+
+--spawn mob in a square doughnut shaped radius
+local chance = 20
+local tick = 0.2
+local timer = 0
+--inner and outer part of square donut radius
+local inner = 24
+local outer = 128
+
+minetest.register_globalstep(function(dtime)
+ timer = timer + dtime
+ if timer >= tick and math.random(1,chance) == chance then
+ print("ticking")
+ timer = 0
+ --check through players
+ for _,player in ipairs(minetest.get_connected_players()) do
+ --don't spawn near dead players
+ if player:get_hp() > 0 then
+
+ --local mob_number = math.random(0,2)
+
+ local int = {-1,1}
+ local pos = vector.floor(vector.add(player:getpos(),0.5))
+
+ local x,z
+
+ --this is used to determine the axis buffer from the player
+ local axis = math.random(0,1)
+
+ --cast towards the direction
+ if axis == 0 then --x
+ x = pos.x + math.random(inner,outer)*int[math.random(1,2)]
+ z = pos.z + math.random(-outer,outer)
+ else --z
+ z = pos.z + math.random(inner,outer)*int[math.random(1,2)]
+ x = pos.x + math.random(-outer,outer)
+ end
+
+
+ local spawner = minetest.find_nodes_in_area_under_air(vector.new(x,pos.y-32,z), vector.new(x,pos.y+32,z), {"main:grass","main:sand","main:water"})
+
+ --print(dump(spawner))
+ if table.getn(spawner) > 0 then
+ local mob_pos = spawner[1]
+ mob_pos.y = mob_pos.y + 1
+ print("Spawning at: "..minetest.pos_to_string(mob_pos))
+ minetest.add_entity(mob_pos,"mob:pig")
+ end
+ end
+ end
+ elseif timer > tick then
+ timer = 0
+ end
+end)
local obj = minetest.add_entity(vector.new(pos.x+x,pos.y+y,pos.z+z),"tnt:tnt")
obj:get_luaentity().range = 5
obj:get_luaentity().timer = math.random(1,10)*math.random()
- minetest.sound_play("tnt_ignite", {object=obj, gain = 1.0, max_hear_distance = range*range*range})
+ --minetest.sound_play("tnt_ignite", {object=obj, gain = 1.0, max_hear_distance = range*range*range})
elseif n ~= "air" and n ~= "ignore" then
if math.random()>0.99 then
local item = minetest.get_node_drops(n, "main:diamondpick")[1]
},
timer = 5,
+ range = 7,
get_staticdata = function(self)
return minetest.serialize({
texture = "smoke.png",
attached = self.object,
})
+ minetest.sound_play("tnt_ignite", {object = self.object, gain = 1.0, max_hear_distance = self.range*self.range*self.range})
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
local obj = minetest.add_entity(pos,"tnt:tnt")
local range = 7
obj:get_luaentity().range = range
- minetest.sound_play("tnt_ignite", {object = obj, gain = 1.0, max_hear_distance = range*range*range})
minetest.remove_node(pos)
end,
})
--tnt throw player - and items
--water flow faster
--torches with particle
-ladders - only placeable on walls
make a mob
+ladders - only placeable on walls
+fix torches not deleting particles when mounted node dug
crafting bench
fishing
bows
3d character
boat
+shiftclick with tool tries to place torch