This commit is contained in:
oilboi 2020-03-03 01:59:30 -05:00
parent 4b75574a57
commit 70acce079a
7 changed files with 89 additions and 64 deletions

View File

@ -1,56 +0,0 @@
--these are helpers to create entities
entity = {}
entity.move = function(self)
if self.path then
local vel = self.object:getvelocity()
local pos = self.object:getpos()
pos.y = 0
local goal = table.copy(self.path[1])
goal.y = 0
local dir = vector.normalize(vector.subtract(goal,pos))
local goal = vector.multiply(dir,2)
local acceleration = vector.new(goal.x-vel.x,0,goal.z-vel.z)
self.object:add_velocity(acceleration)
end
end
entity.jump = function(self)
if self.path then
local pos = vector.floor(vector.add(self.object:getpos(), 0.5))
local pos2 = self.path[1]
if pos2.y > pos.y 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
end
entity.delete_path_node = function(self)
local pos = vector.floor(vector.add(self.object:getpos(), 0.5))
local goalnode = self.path[1]
local at_goal = vector.equals(pos, goalnode)
if at_goal then
--print("deleting path node")
table.remove(self.path, 1)
end
if table.getn(self.path) == 0 then
self.path = nil
end
end

View File

@ -1,11 +1,11 @@
function main.stoneSound(table)
table = table or {}
table.dig = table.dig or
{name = "stone",gain=0.3}
{name = "stone",gain=0.2}
table.footstep = table.footstep or
{name = "stone", gain = 0.2}
{name = "stone", gain = 0.1}
table.dug = table.dug or
{name = "stone_break", gain = 1.0}
{name = "stone", gain = 1.0}
table.place = table.place or
{name = "stone", gain = 1.0}
--default.node_sound_defaults(table)

View File

@ -1 +0,0 @@
entity_lib

View File

@ -6,6 +6,67 @@ local path = minetest.get_modpath(minetest.get_current_modname())
dofile(path.."/spawning.lua")
dofile(path.."/items.lua")
--these are helpers to create entities
local entity = {}
entity.move = function(self)
if self.path then
local vel = self.object:getvelocity()
local pos = self.object:getpos()
pos.y = 0
local goal = table.copy(self.path[1])
goal.y = 0
local dir = vector.normalize(vector.subtract(goal,pos))
local goal = vector.multiply(dir,2)
local acceleration = vector.new(goal.x-vel.x,0,goal.z-vel.z)
self.object:add_velocity(acceleration)
end
end
entity.jump = function(self)
if self.path then
local pos = vector.floor(vector.add(self.object:getpos(), 0.5))
local pos2 = self.path[1]
if pos2.y > pos.y 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
end
entity.delete_path_node = function(self)
local pos = vector.floor(vector.add(self.object:getpos(), 0.5))
local goalnode = self.path[1]
local at_goal = vector.equals(pos, goalnode)
if at_goal then
--print("deleting path node")
table.remove(self.path, 1)
end
if table.getn(self.path) == 0 then
self.path = nil
end
end
local max_speed = 0.5
minetest.register_entity("mob:pig", {
@ -162,7 +223,7 @@ minetest.register_entity("mob:pig", {
local pos2 = self.find_position(self)
if not self.path and pos2 then
print("updated goal position")
--print("updated goal position")
self.goal_position = pos2
local pos = vector.floor(vector.add(self.object:getpos(),0.5))
local path = minetest.find_path(pos,pos2,10,1,3,"A*_noprefetch")
@ -178,7 +239,7 @@ minetest.register_entity("mob:pig", {
local pos2 = self.goal_position
if self.path then
print("updated goal position")
--print("updated goal position")
self.goal_position = pos2
local pos = vector.floor(vector.add(self.object:getpos(),0.5))
local path = minetest.find_path(pos,pos2,10,1,3,"A*_noprefetch")

View File

@ -15,7 +15,7 @@ minetest.register_globalstep(function(dtime)
if spawn then
timer = timer + dtime
if timer >= tick and math.random(1,chance) == chance then
print("ticking")
--print("ticking")
timer = 0
--check through players
for _,player in ipairs(minetest.get_connected_players()) do
@ -48,7 +48,7 @@ minetest.register_globalstep(function(dtime)
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))
--print("Spawning at: "..minetest.pos_to_string(mob_pos))
minetest.add_entity(mob_pos,"mob:pig")
end
end

View File

@ -177,3 +177,21 @@ minetest.register_globalstep(function(dtime)
end
end)
local inv = "size[8,7.5]"..
"image[1,0.6;1,2;player.png]"..
"list[current_player;main;0,3.5;8,4;]"..
"list[current_player;craftpreview;7,1;1,1;]"..
"listring[]"..
"list[current_player;craft;3,0;3,3;]"
minetest.register_on_joinplayer(function(player)
player:set_inventory_formspec(inv)
end)
minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info)
print("inv test")
end)

View File

@ -36,6 +36,9 @@ ALPHA STATE CHANGELOG
--water buckets
--buckets water farmland
make mobs pathfind again when moving into new node
crafting bench