replace spaces with tabs
This commit is contained in:
parent
11de50be41
commit
ff6ef525ca
@ -5,41 +5,41 @@ local time_night = {begin = 19000, ending = 5500}
|
||||
|
||||
--node boxes are from mineclone2
|
||||
local function create_spawnpoint(pos,clicker)
|
||||
local time = minetest.get_timeofday() * 24000
|
||||
|
||||
if time > time_night.begin or time < time_night.ending then
|
||||
local name = clicker:get_player_name()
|
||||
local string_pos = minetest.pos_to_string(pos)
|
||||
mod_storage:set_string(name, string_pos)
|
||||
minetest.chat_send_player(name, "Your respawn point has been set!")
|
||||
minetest.set_timeofday(time_night.ending/24000)
|
||||
else
|
||||
minetest.chat_send_player(clicker:get_player_name(), "You can only sleep at night!")
|
||||
end
|
||||
local time = minetest.get_timeofday() * 24000
|
||||
|
||||
if time > time_night.begin or time < time_night.ending then
|
||||
local name = clicker:get_player_name()
|
||||
local string_pos = minetest.pos_to_string(pos)
|
||||
mod_storage:set_string(name, string_pos)
|
||||
minetest.chat_send_player(name, "Your respawn point has been set!")
|
||||
minetest.set_timeofday(time_night.ending/24000)
|
||||
else
|
||||
minetest.chat_send_player(clicker:get_player_name(), "You can only sleep at night!")
|
||||
end
|
||||
end
|
||||
|
||||
--delete player spawnpoint if remove bed
|
||||
local function remove_spawnpoint(pos,clicker)
|
||||
local name = clicker:get_player_name()
|
||||
local string_pos = mod_storage:get_string(name)
|
||||
if string_pos ~= "" then
|
||||
local pos2 = minetest.string_to_pos(string_pos)
|
||||
if vector.equals(pos,pos2) then
|
||||
mod_storage:set_string(name, "")
|
||||
minetest.chat_send_player(name, "Your respawn point has been removed!")
|
||||
end
|
||||
end
|
||||
local name = clicker:get_player_name()
|
||||
local string_pos = mod_storage:get_string(name)
|
||||
if string_pos ~= "" then
|
||||
local pos2 = minetest.string_to_pos(string_pos)
|
||||
if vector.equals(pos,pos2) then
|
||||
mod_storage:set_string(name, "")
|
||||
minetest.chat_send_player(name, "Your respawn point has been removed!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--try to send the player to their bed
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local string_pos = mod_storage:get_string(name)
|
||||
if string_pos ~= "" then
|
||||
local pos = minetest.string_to_pos(string_pos)
|
||||
player:setpos(pos)
|
||||
return(true)
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local string_pos = mod_storage:get_string(name)
|
||||
if string_pos ~= "" then
|
||||
local pos = minetest.string_to_pos(string_pos)
|
||||
player:setpos(pos)
|
||||
return(true)
|
||||
end
|
||||
end)
|
||||
--these are beds
|
||||
minetest.register_node("bed:bed", {
|
||||
@ -51,29 +51,29 @@ minetest.register_node("bed:bed", {
|
||||
groups = {wood = 1, hard = 1, axe = 1, hand = 3, instant=1},
|
||||
sounds = main.woodSound(),
|
||||
drawtype = "nodebox",
|
||||
node_placement_prediction = "",
|
||||
on_construct = function(pos)
|
||||
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local facedir = minetest.facedir_to_dir(param2)
|
||||
|
||||
--cancel if not air
|
||||
if minetest.get_node(vector.add(pos,facedir)).name ~= "air" then
|
||||
minetest.remove_node(pos)
|
||||
local obj = minetest.add_item(pos, "bed:bed")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
facedir = vector.multiply(facedir,-1)
|
||||
param2 = minetest.dir_to_facedir(facedir, false)
|
||||
|
||||
|
||||
minetest.add_node(pos,{name="bed:bed_front", param2=param2})
|
||||
|
||||
facedir = vector.multiply(facedir,-1)
|
||||
minetest.add_node(vector.add(pos,facedir),{name="bed:bed_back", param2=param2})
|
||||
end,
|
||||
node_placement_prediction = "",
|
||||
on_construct = function(pos)
|
||||
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local facedir = minetest.facedir_to_dir(param2)
|
||||
|
||||
--cancel if not air
|
||||
if minetest.get_node(vector.add(pos,facedir)).name ~= "air" then
|
||||
minetest.remove_node(pos)
|
||||
local obj = minetest.add_item(pos, "bed:bed")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
facedir = vector.multiply(facedir,-1)
|
||||
param2 = minetest.dir_to_facedir(facedir, false)
|
||||
|
||||
|
||||
minetest.add_node(pos,{name="bed:bed_front", param2=param2})
|
||||
|
||||
facedir = vector.multiply(facedir,-1)
|
||||
minetest.add_node(vector.add(pos,facedir),{name="bed:bed_back", param2=param2})
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("bed:bed_front", {
|
||||
@ -85,28 +85,28 @@ minetest.register_node("bed:bed_front", {
|
||||
sounds = main.woodSound(),
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -5/16, -0.5, 0.5, 0.06, 0.5},
|
||||
{-0.5, -0.5, 0.5, -5/16, -5/16, 5/16},
|
||||
{0.5, -0.5, 0.5, 5/16, -5/16, 5/16},
|
||||
},
|
||||
},
|
||||
node_placement_prediction = "",
|
||||
drop = "bed:bed",
|
||||
on_dig = function(pos, node, digger)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local facedir = minetest.facedir_to_dir(param2)
|
||||
facedir = vector.multiply(facedir,-1)
|
||||
local obj = minetest.add_item(pos, "bed:bed")
|
||||
minetest.remove_node(pos)
|
||||
minetest.remove_node(vector.add(pos,facedir))
|
||||
remove_spawnpoint(pos,digger)
|
||||
remove_spawnpoint(vector.add(pos,facedir),digger)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
create_spawnpoint(pos,clicker)
|
||||
end,
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -5/16, -0.5, 0.5, 0.06, 0.5},
|
||||
{-0.5, -0.5, 0.5, -5/16, -5/16, 5/16},
|
||||
{0.5, -0.5, 0.5, 5/16, -5/16, 5/16},
|
||||
},
|
||||
},
|
||||
node_placement_prediction = "",
|
||||
drop = "bed:bed",
|
||||
on_dig = function(pos, node, digger)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local facedir = minetest.facedir_to_dir(param2)
|
||||
facedir = vector.multiply(facedir,-1)
|
||||
local obj = minetest.add_item(pos, "bed:bed")
|
||||
minetest.remove_node(pos)
|
||||
minetest.remove_node(vector.add(pos,facedir))
|
||||
remove_spawnpoint(pos,digger)
|
||||
remove_spawnpoint(vector.add(pos,facedir),digger)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
create_spawnpoint(pos,clicker)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("bed:bed_back", {
|
||||
@ -119,33 +119,33 @@ minetest.register_node("bed:bed_back", {
|
||||
drawtype = "nodebox",
|
||||
node_placement_prediction = "",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -5/16, -0.5, 0.5, 0.06, 0.5},
|
||||
{-0.5, -0.5, -0.5, -5/16, -5/16, -5/16},
|
||||
{0.5, -0.5, -0.5, 5/16, -5/16, -5/16},
|
||||
},
|
||||
},
|
||||
drop = "bed:bed",
|
||||
on_dig = function(pos, node, digger)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local facedir = minetest.facedir_to_dir(param2)
|
||||
local obj = minetest.add_item(pos, "bed:bed")
|
||||
minetest.remove_node(pos)
|
||||
minetest.remove_node(vector.add(pos,facedir))
|
||||
remove_spawnpoint(pos,digger)
|
||||
remove_spawnpoint(vector.add(pos,facedir),digger)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local facedir = minetest.facedir_to_dir(param2)
|
||||
create_spawnpoint(vector.add(pos,facedir),clicker)
|
||||
end,
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -5/16, -0.5, 0.5, 0.06, 0.5},
|
||||
{-0.5, -0.5, -0.5, -5/16, -5/16, -5/16},
|
||||
{0.5, -0.5, -0.5, 5/16, -5/16, -5/16},
|
||||
},
|
||||
},
|
||||
drop = "bed:bed",
|
||||
on_dig = function(pos, node, digger)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local facedir = minetest.facedir_to_dir(param2)
|
||||
local obj = minetest.add_item(pos, "bed:bed")
|
||||
minetest.remove_node(pos)
|
||||
minetest.remove_node(vector.add(pos,facedir))
|
||||
remove_spawnpoint(pos,digger)
|
||||
remove_spawnpoint(vector.add(pos,facedir),digger)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local facedir = minetest.facedir_to_dir(param2)
|
||||
create_spawnpoint(vector.add(pos,facedir),clicker)
|
||||
end,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "bed:bed",
|
||||
recipe = {
|
||||
{"main:leaves", "main:leaves", "main:leaves"},
|
||||
{"main:wood", "main:wood", "main:wood"},
|
||||
},
|
||||
output = "bed:bed",
|
||||
recipe = {
|
||||
{"main:leaves", "main:leaves", "main:leaves"},
|
||||
{"main:wood", "main:wood", "main:wood"},
|
||||
},
|
||||
})
|
||||
|
@ -1,225 +1,225 @@
|
||||
--minetest.get_node_level(pos)
|
||||
minetest.register_entity("boat:boat", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.4, -0.35, -0.4, 0.4, 0.3, 0.4},
|
||||
visual = "mesh",
|
||||
mesh = "boat.obj",
|
||||
textures = {"boat.png"},
|
||||
visual_size = {x=3,y=3,z=3},
|
||||
is_visible = true,
|
||||
automatic_face_movement_dir = 90.0,
|
||||
automatic_face_movement_max_rotation_per_sec = 600,
|
||||
},
|
||||
|
||||
rider = nil,
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.4, -0.35, -0.4, 0.4, 0.3, 0.4},
|
||||
visual = "mesh",
|
||||
mesh = "boat.obj",
|
||||
textures = {"boat.png"},
|
||||
visual_size = {x=3,y=3,z=3},
|
||||
is_visible = true,
|
||||
automatic_face_movement_dir = 90.0,
|
||||
automatic_face_movement_max_rotation_per_sec = 600,
|
||||
},
|
||||
|
||||
rider = nil,
|
||||
|
||||
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
--itemstring = self.itemstring,
|
||||
})
|
||||
end,
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
--itemstring = self.itemstring,
|
||||
})
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if string.sub(staticdata, 1, string.len("return")) == "return" then
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if data and type(data) == "table" then
|
||||
--self.itemstring = data.itemstring
|
||||
end
|
||||
else
|
||||
--self.itemstring = staticdata
|
||||
end
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||
self.object:set_acceleration({x = 0, y = -9.81, z = 0})
|
||||
end,
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
local pos = self.object:getpos()
|
||||
minetest.add_item(pos, "boat:boat")
|
||||
self.object:remove()
|
||||
end,
|
||||
|
||||
|
||||
on_rightclick = function(self,clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
local player_name = clicker:get_player_name()
|
||||
|
||||
if self.rider and player_name == self.rider then
|
||||
clicker:set_detach()
|
||||
self.rider = nil
|
||||
elseif not self.rider then
|
||||
self.rider = player_name
|
||||
clicker:set_attach(self.object, "", {x=0, y=-4.5, z=0}, {x=0, y=0, z=0})
|
||||
--player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
||||
--carts:manage_attachment(clicker, self.object)
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if string.sub(staticdata, 1, string.len("return")) == "return" then
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if data and type(data) == "table" then
|
||||
--self.itemstring = data.itemstring
|
||||
end
|
||||
else
|
||||
--self.itemstring = staticdata
|
||||
end
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||
self.object:set_acceleration({x = 0, y = -9.81, z = 0})
|
||||
end,
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
local pos = self.object:getpos()
|
||||
minetest.add_item(pos, "boat:boat")
|
||||
self.object:remove()
|
||||
end,
|
||||
|
||||
|
||||
on_rightclick = function(self,clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
local player_name = clicker:get_player_name()
|
||||
|
||||
if self.rider and player_name == self.rider then
|
||||
clicker:set_detach()
|
||||
self.rider = nil
|
||||
elseif not self.rider then
|
||||
self.rider = player_name
|
||||
clicker:set_attach(self.object, "", {x=0, y=-4.5, z=0}, {x=0, y=0, z=0})
|
||||
--player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
||||
--carts:manage_attachment(clicker, self.object)
|
||||
|
||||
-- player_api does not update the animation
|
||||
-- when the player is attached, reset to default animation
|
||||
|
||||
--player_api.set_animation(clicker, "stand")
|
||||
end
|
||||
end,
|
||||
--check if the boat is stuck on land
|
||||
check_if_on_land = function(self)
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y - 0.37
|
||||
local bottom_node = minetest.get_node(pos).name
|
||||
if (bottom_node == "main:water" or bottom_node == "main:waterflow" or bottom_node == "air") then
|
||||
self.on_land = false
|
||||
else
|
||||
self.on_land = true
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
--players drive the baot
|
||||
drive = function(self)
|
||||
if self.rider and not self.on_land == true then
|
||||
local rider = minetest.get_player_by_name(self.rider)
|
||||
local move = rider:get_player_control().up
|
||||
self.moving = nil
|
||||
if move then
|
||||
local currentvel = self.object:getvelocity()
|
||||
local goal = rider:get_look_dir()
|
||||
goal = vector.multiply(goal,9)
|
||||
local acceleration = vector.new(goal.x-currentvel.x,0,goal.z-currentvel.z)
|
||||
acceleration = vector.multiply(acceleration, 0.01)
|
||||
self.object:add_velocity(acceleration)
|
||||
self.moving = true
|
||||
end
|
||||
else
|
||||
self.moving = nil
|
||||
end
|
||||
end,
|
||||
|
||||
--players push boat
|
||||
push = function(self)
|
||||
local pos = self.object:getpos()
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
if object:is_player() and object:get_player_name() ~= self.rider then
|
||||
local player_pos = object:getpos()
|
||||
pos.y = 0
|
||||
player_pos.y = 0
|
||||
|
||||
local currentvel = self.object:getvelocity()
|
||||
local vel = vector.subtract(pos, player_pos)
|
||||
vel = vector.normalize(vel)
|
||||
local distance = vector.distance(pos,player_pos)
|
||||
distance = (1-distance)*10
|
||||
vel = vector.multiply(vel,distance)
|
||||
local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z)
|
||||
self.object:add_velocity(acceleration)
|
||||
acceleration = vector.multiply(acceleration, -1)
|
||||
object:add_player_velocity(acceleration)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
--makes the boat float
|
||||
float = function(self)
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos).name
|
||||
self.swimming = false
|
||||
|
||||
--flow normally if floating else don't
|
||||
if node == "main:water" or node =="main:waterflow" then
|
||||
self.swimming = true
|
||||
local vel = self.object:getvelocity()
|
||||
local goal = 3
|
||||
local acceleration = vector.new(0,goal-vel.y,0)
|
||||
self.object:add_velocity(acceleration)
|
||||
end
|
||||
end,
|
||||
|
||||
--makes boats flow
|
||||
flow = function(self)
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y - 0.4
|
||||
local node = minetest.get_node(pos).name
|
||||
local node_above = minetest.get_node(vector.new(pos.x,pos.y+1,pos.z)).name
|
||||
local goalx = 0
|
||||
local goalz = 0
|
||||
--print(node_above)
|
||||
if (node == "main:waterflow" or node == "main:water" ) and not self.moving == true and (node_above ~= "main:water" and node_above ~= "main:waterflow") then
|
||||
local currentvel = self.object:getvelocity()
|
||||
local level = minetest.get_node_level(pos)
|
||||
local pos = self.object:getpos()
|
||||
for x = -1,1 do
|
||||
for y = -1,0 do
|
||||
for z = -1,1 do
|
||||
if (x == 0 and z ~= 0) or (z == 0 and x ~=0) then
|
||||
local nodename = minetest.get_node(vector.new(pos.x+x,pos.y+y,pos.z+z)).name
|
||||
local level2 = minetest.get_node_level(vector.new(pos.x+x,pos.y+y,pos.z+z))
|
||||
if (level2 < level and nodename == "main:waterflow") or (nodename == "main:water" and level2 == 7) then
|
||||
goalx = x*7
|
||||
goalz = z*7
|
||||
--break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--only add velocity if there is one
|
||||
--else this stops the boat
|
||||
if goalx ~= 0 or goalz ~= 0 then
|
||||
local acceleration = vector.new(goalx-currentvel.x,0,goalz-currentvel.z)
|
||||
acceleration = vector.multiply(acceleration, 0.01)
|
||||
self.object:add_velocity(acceleration)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
--slows the boat down
|
||||
slowdown = function(self)
|
||||
if not self.moving == true then
|
||||
local vel = self.object:getvelocity()
|
||||
local deceleration = vector.multiply(vel, -0.01)
|
||||
self.object:add_velocity(deceleration)
|
||||
end
|
||||
end,
|
||||
-- player_api does not update the animation
|
||||
-- when the player is attached, reset to default animation
|
||||
|
||||
--player_api.set_animation(clicker, "stand")
|
||||
end
|
||||
end,
|
||||
--check if the boat is stuck on land
|
||||
check_if_on_land = function(self)
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y - 0.37
|
||||
local bottom_node = minetest.get_node(pos).name
|
||||
if (bottom_node == "main:water" or bottom_node == "main:waterflow" or bottom_node == "air") then
|
||||
self.on_land = false
|
||||
else
|
||||
self.on_land = true
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
--players drive the baot
|
||||
drive = function(self)
|
||||
if self.rider and not self.on_land == true then
|
||||
local rider = minetest.get_player_by_name(self.rider)
|
||||
local move = rider:get_player_control().up
|
||||
self.moving = nil
|
||||
if move then
|
||||
local currentvel = self.object:getvelocity()
|
||||
local goal = rider:get_look_dir()
|
||||
goal = vector.multiply(goal,9)
|
||||
local acceleration = vector.new(goal.x-currentvel.x,0,goal.z-currentvel.z)
|
||||
acceleration = vector.multiply(acceleration, 0.01)
|
||||
self.object:add_velocity(acceleration)
|
||||
self.moving = true
|
||||
end
|
||||
else
|
||||
self.moving = nil
|
||||
end
|
||||
end,
|
||||
|
||||
--players push boat
|
||||
push = function(self)
|
||||
local pos = self.object:getpos()
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
if object:is_player() and object:get_player_name() ~= self.rider then
|
||||
local player_pos = object:getpos()
|
||||
pos.y = 0
|
||||
player_pos.y = 0
|
||||
|
||||
local currentvel = self.object:getvelocity()
|
||||
local vel = vector.subtract(pos, player_pos)
|
||||
vel = vector.normalize(vel)
|
||||
local distance = vector.distance(pos,player_pos)
|
||||
distance = (1-distance)*10
|
||||
vel = vector.multiply(vel,distance)
|
||||
local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z)
|
||||
self.object:add_velocity(acceleration)
|
||||
acceleration = vector.multiply(acceleration, -1)
|
||||
object:add_player_velocity(acceleration)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
--makes the boat float
|
||||
float = function(self)
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos).name
|
||||
self.swimming = false
|
||||
|
||||
--flow normally if floating else don't
|
||||
if node == "main:water" or node =="main:waterflow" then
|
||||
self.swimming = true
|
||||
local vel = self.object:getvelocity()
|
||||
local goal = 3
|
||||
local acceleration = vector.new(0,goal-vel.y,0)
|
||||
self.object:add_velocity(acceleration)
|
||||
end
|
||||
end,
|
||||
|
||||
--makes boats flow
|
||||
flow = function(self)
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y - 0.4
|
||||
local node = minetest.get_node(pos).name
|
||||
local node_above = minetest.get_node(vector.new(pos.x,pos.y+1,pos.z)).name
|
||||
local goalx = 0
|
||||
local goalz = 0
|
||||
--print(node_above)
|
||||
if (node == "main:waterflow" or node == "main:water" ) and not self.moving == true and (node_above ~= "main:water" and node_above ~= "main:waterflow") then
|
||||
local currentvel = self.object:getvelocity()
|
||||
local level = minetest.get_node_level(pos)
|
||||
local pos = self.object:getpos()
|
||||
for x = -1,1 do
|
||||
for y = -1,0 do
|
||||
for z = -1,1 do
|
||||
if (x == 0 and z ~= 0) or (z == 0 and x ~=0) then
|
||||
local nodename = minetest.get_node(vector.new(pos.x+x,pos.y+y,pos.z+z)).name
|
||||
local level2 = minetest.get_node_level(vector.new(pos.x+x,pos.y+y,pos.z+z))
|
||||
if (level2 < level and nodename == "main:waterflow") or (nodename == "main:water" and level2 == 7) then
|
||||
goalx = x*7
|
||||
goalz = z*7
|
||||
--break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--only add velocity if there is one
|
||||
--else this stops the boat
|
||||
if goalx ~= 0 or goalz ~= 0 then
|
||||
local acceleration = vector.new(goalx-currentvel.x,0,goalz-currentvel.z)
|
||||
acceleration = vector.multiply(acceleration, 0.01)
|
||||
self.object:add_velocity(acceleration)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
--slows the boat down
|
||||
slowdown = function(self)
|
||||
if not self.moving == true then
|
||||
local vel = self.object:getvelocity()
|
||||
local deceleration = vector.multiply(vel, -0.01)
|
||||
self.object:add_velocity(deceleration)
|
||||
end
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
self.check_if_on_land(self)
|
||||
self.push(self)
|
||||
self.drive(self)
|
||||
self.float(self)
|
||||
self.flow(self)
|
||||
self.slowdown(self)
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
self.check_if_on_land(self)
|
||||
self.push(self)
|
||||
self.drive(self)
|
||||
self.float(self)
|
||||
self.flow(self)
|
||||
self.slowdown(self)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("boat:boat", {
|
||||
description = "Boat",
|
||||
inventory_image = "boatitem.png",
|
||||
wield_image = "boatitem.png",
|
||||
liquids_pointable = true,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "water")>0 then
|
||||
minetest.add_entity(pointed_thing.under, "boat:boat")
|
||||
else
|
||||
return
|
||||
end
|
||||
description = "Boat",
|
||||
inventory_image = "boatitem.png",
|
||||
wield_image = "boatitem.png",
|
||||
liquids_pointable = true,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "water")>0 then
|
||||
minetest.add_entity(pointed_thing.under, "boat:boat")
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
itemstack:take_item()
|
||||
itemstack:take_item()
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "boat:boat",
|
||||
recipe = {
|
||||
{"main:wood", "", "main:wood"},
|
||||
{"main:wood", "main:wood", "main:wood"},
|
||||
},
|
||||
output = "boat:boat",
|
||||
recipe = {
|
||||
{"main:wood", "", "main:wood"},
|
||||
{"main:wood", "main:wood", "main:wood"},
|
||||
},
|
||||
})
|
||||
|
@ -24,9 +24,9 @@ minetest.register_node("craftingtable:craftingtable", {
|
||||
end,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "craftingtable:craftingtable",
|
||||
recipe = {
|
||||
{"main:wood","main:wood"},
|
||||
{"main:wood","main:wood"}
|
||||
}
|
||||
output = "craftingtable:craftingtable",
|
||||
recipe = {
|
||||
{"main:wood","main:wood"},
|
||||
{"main:wood","main:wood"}
|
||||
}
|
||||
})
|
||||
|
@ -4,133 +4,133 @@ local material = {"wood","stone","iron","gold","diamond"}
|
||||
|
||||
|
||||
local function till_soil(pos)
|
||||
local is_dirt = minetest.get_node_group(minetest.get_node(pos).name, "dirt") > 0
|
||||
local is_farmland = minetest.get_node_group(minetest.get_node(pos).name, "farmland") > 0
|
||||
if is_dirt and not is_farmland then
|
||||
minetest.sound_play("dirt",{pos=pos})
|
||||
minetest.set_node(pos,{name="farming:farmland_dry"})
|
||||
return(true)
|
||||
end
|
||||
local is_dirt = minetest.get_node_group(minetest.get_node(pos).name, "dirt") > 0
|
||||
local is_farmland = minetest.get_node_group(minetest.get_node(pos).name, "farmland") > 0
|
||||
if is_dirt and not is_farmland then
|
||||
minetest.sound_play("dirt",{pos=pos})
|
||||
minetest.set_node(pos,{name="farming:farmland_dry"})
|
||||
return(true)
|
||||
end
|
||||
end
|
||||
|
||||
for level,material in pairs(material) do
|
||||
local wear = 5000-(950*level)
|
||||
print(wear)
|
||||
minetest.register_tool("farming:"..material.."hoe", {
|
||||
description = material:gsub("^%l", string.upper).." Hoe",
|
||||
inventory_image = material.."hoe.png",
|
||||
tool_capabilities = {
|
||||
--full_punch_interval = 1.2,
|
||||
--max_drop_level=0,
|
||||
groupcaps={
|
||||
dirt = {times={[4]=4-level/4,[3]=3.5-level/4,[2]=3.0-level/4,[1]=2.8-level/4}, uses=(level/2)*3, maxlevel=level},
|
||||
sand = {times={[4]=4-level/4,[3]=3.5-level/4,[2]=3.0-level/4,[1]=2.8-level/4}, uses=(level/2)*3, maxlevel=level},
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
|
||||
groups = {flammable = 2, tool=1 },
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local tilled = till_soil(pointed_thing.under)
|
||||
if tilled == true then itemstack:add_wear(wear) end
|
||||
|
||||
local damage = itemstack:get_wear()
|
||||
|
||||
if damage <= 0 then
|
||||
minetest.sound_play("tool_break",{object=placer})
|
||||
end
|
||||
return(itemstack)
|
||||
end,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "farming:"..material.."hoe",
|
||||
recipe = {
|
||||
{"","main:"..material, "main:"..material},
|
||||
{"","main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "farming:"..material.."hoe",
|
||||
recipe = {
|
||||
{"main:"..material,"main:"..material, ""},
|
||||
{"","main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
local wear = 5000-(950*level)
|
||||
print(wear)
|
||||
minetest.register_tool("farming:"..material.."hoe", {
|
||||
description = material:gsub("^%l", string.upper).." Hoe",
|
||||
inventory_image = material.."hoe.png",
|
||||
tool_capabilities = {
|
||||
--full_punch_interval = 1.2,
|
||||
--max_drop_level=0,
|
||||
groupcaps={
|
||||
dirt = {times={[4]=4-level/4,[3]=3.5-level/4,[2]=3.0-level/4,[1]=2.8-level/4}, uses=(level/2)*3, maxlevel=level},
|
||||
sand = {times={[4]=4-level/4,[3]=3.5-level/4,[2]=3.0-level/4,[1]=2.8-level/4}, uses=(level/2)*3, maxlevel=level},
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
|
||||
groups = {flammable = 2, tool=1 },
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local tilled = till_soil(pointed_thing.under)
|
||||
if tilled == true then itemstack:add_wear(wear) end
|
||||
|
||||
local damage = itemstack:get_wear()
|
||||
|
||||
if damage <= 0 then
|
||||
minetest.sound_play("tool_break",{object=placer})
|
||||
end
|
||||
return(itemstack)
|
||||
end,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "farming:"..material.."hoe",
|
||||
recipe = {
|
||||
{"","main:"..material, "main:"..material},
|
||||
{"","main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "farming:"..material.."hoe",
|
||||
recipe = {
|
||||
{"main:"..material,"main:"..material, ""},
|
||||
{"","main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
local farmland = {"wet","dry"}
|
||||
|
||||
for level,dryness in pairs(farmland) do
|
||||
local coloring = 160/level
|
||||
local coloring = 160/level
|
||||
|
||||
minetest.register_node("farming:farmland_"..dryness,{
|
||||
description = "Farmland",
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
sounds = main.dirtSound(),
|
||||
--paramtype2 = "wallmounted",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
--{xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
minetest.register_node("farming:farmland_"..dryness,{
|
||||
description = "Farmland",
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
sounds = main.dirtSound(),
|
||||
--paramtype2 = "wallmounted",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
--{xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 6/16, 0.5},
|
||||
},
|
||||
wetness = math.abs(level-2),
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
--{xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 6/16, 0.5},
|
||||
},
|
||||
wetness = math.abs(level-2),
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
--{xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 6/16, 0.5},
|
||||
},
|
||||
tiles = {"dirt.png^farmland.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring},
|
||||
groups = {dirt = 1, soft = 1, shovel = 1, hand = 1, soil=1,farmland=1},
|
||||
drop="main:dirt",
|
||||
})
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 6/16, 0.5},
|
||||
},
|
||||
tiles = {"dirt.png^farmland.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring,"dirt.png^[colorize:black:"..coloring},
|
||||
groups = {dirt = 1, soft = 1, shovel = 1, hand = 1, soil=1,farmland=1},
|
||||
drop="main:dirt",
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
--drying and wetting abm for farmland
|
||||
minetest.register_abm({
|
||||
label = "Farmland Wet",
|
||||
nodenames = {"farming:farmland_dry"},
|
||||
neighbors = {"air","group:crop"},
|
||||
interval = 3,
|
||||
chance = 150,
|
||||
action = function(pos)
|
||||
local found = minetest.find_node_near(pos, 3, {"main:water","main:waterflow"})
|
||||
if found then
|
||||
minetest.set_node(pos,{name="farming:farmland_wet"})
|
||||
else
|
||||
minetest.set_node(pos,{name="main:dirt"})
|
||||
end
|
||||
end,
|
||||
label = "Farmland Wet",
|
||||
nodenames = {"farming:farmland_dry"},
|
||||
neighbors = {"air","group:crop"},
|
||||
interval = 3,
|
||||
chance = 150,
|
||||
action = function(pos)
|
||||
local found = minetest.find_node_near(pos, 3, {"main:water","main:waterflow"})
|
||||
if found then
|
||||
minetest.set_node(pos,{name="farming:farmland_wet"})
|
||||
else
|
||||
minetest.set_node(pos,{name="main:dirt"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
minetest.register_abm({
|
||||
label = "Farmland dry",
|
||||
nodenames = {"farming:farmland_wet"},
|
||||
neighbors = {"air"},
|
||||
interval = 5,
|
||||
chance = 500,
|
||||
action = function(pos)
|
||||
local found = minetest.find_node_near(pos, 3, {"main:water","main:waterflow"})
|
||||
if not found then
|
||||
minetest.set_node(pos,{name="farming:farmland_dry"})
|
||||
end
|
||||
end,
|
||||
label = "Farmland dry",
|
||||
nodenames = {"farming:farmland_wet"},
|
||||
neighbors = {"air"},
|
||||
interval = 5,
|
||||
chance = 500,
|
||||
action = function(pos)
|
||||
local found = minetest.find_node_near(pos, 3, {"main:water","main:waterflow"})
|
||||
if not found then
|
||||
minetest.set_node(pos,{name="farming:farmland_dry"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("farming:grass", {
|
||||
description = "Tall Grass",
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
tiles = {"tallgrass.png"},
|
||||
paramtype2 = "degrotate",
|
||||
buildable_to = true,
|
||||
@ -140,134 +140,134 @@ minetest.register_node("farming:grass", {
|
||||
type = "fixed",
|
||||
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 4 / 16, 4 / 16}
|
||||
},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
rarity = 10,
|
||||
items = {"farming:seeds"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
rarity = 10,
|
||||
items = {"farming:seeds"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
--wheat definitions
|
||||
local wheat_max = 7
|
||||
minetest.register_abm({
|
||||
label = "crops grow",
|
||||
nodenames = {"group:crops"},
|
||||
neighbors = {"group:farmland"},
|
||||
interval = 3,
|
||||
chance = 150,
|
||||
action = function(pos)
|
||||
|
||||
local node_under = minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name
|
||||
local wetness = minetest.registered_nodes[node_under].wetness
|
||||
|
||||
if wetness == 0 or not wetness then
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.get_node(pos).name
|
||||
local stage = minetest.registered_nodes[node].grow_stage
|
||||
if stage < wheat_max then
|
||||
minetest.set_node(pos,{name="farming:wheat_"..stage+1})
|
||||
end
|
||||
end,
|
||||
label = "crops grow",
|
||||
nodenames = {"group:crops"},
|
||||
neighbors = {"group:farmland"},
|
||||
interval = 3,
|
||||
chance = 150,
|
||||
action = function(pos)
|
||||
|
||||
local node_under = minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name
|
||||
local wetness = minetest.registered_nodes[node_under].wetness
|
||||
|
||||
if wetness == 0 or not wetness then
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.get_node(pos).name
|
||||
local stage = minetest.registered_nodes[node].grow_stage
|
||||
if stage < wheat_max then
|
||||
minetest.set_node(pos,{name="farming:wheat_"..stage+1})
|
||||
end
|
||||
end,
|
||||
})
|
||||
for i = 0,wheat_max do
|
||||
local drop = ""
|
||||
if i == wheat_max then
|
||||
drop = {
|
||||
max_items = 2,
|
||||
items= {
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
--rarity = 10,
|
||||
items = {"farming:wheat"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
rarity = 3,
|
||||
items = {"farming:seeds"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
|
||||
minetest.register_node("farming:wheat_"..i, {
|
||||
description = "Wheat Stage "..i,
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
tiles = {"wheat_stage_"..i..".png"},
|
||||
paramtype2 = "degrotate",
|
||||
buildable_to = true,
|
||||
grow_stage = i,
|
||||
groups = {leaves = 1, plant = 1, axe = 1, hand = 0,dig_immediate=1,attached_node=1,crops=1},
|
||||
sounds = main.grassSound(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 4 / 16, 4 / 16}
|
||||
},
|
||||
drop = drop,
|
||||
})
|
||||
local drop = ""
|
||||
if i == wheat_max then
|
||||
drop = {
|
||||
max_items = 2,
|
||||
items= {
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
--rarity = 10,
|
||||
items = {"farming:wheat"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
rarity = 3,
|
||||
items = {"farming:seeds"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
|
||||
minetest.register_node("farming:wheat_"..i, {
|
||||
description = "Wheat Stage "..i,
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
tiles = {"wheat_stage_"..i..".png"},
|
||||
paramtype2 = "degrotate",
|
||||
buildable_to = true,
|
||||
grow_stage = i,
|
||||
groups = {leaves = 1, plant = 1, axe = 1, hand = 0,dig_immediate=1,attached_node=1,crops=1},
|
||||
sounds = main.grassSound(),
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 4 / 16, 4 / 16}
|
||||
},
|
||||
drop = drop,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
minetest.register_craftitem("farming:seeds", {
|
||||
description = "Seeds",
|
||||
inventory_image = "seeds.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
local pb = pointed_thing.above
|
||||
if minetest.get_node_group(minetest.get_node(vector.new(pb.x,pb.y-1,pb.z)).name, "farmland") == 0 or minetest.get_node(pointed_thing.above).name ~= "air" then
|
||||
return itemstack
|
||||
end
|
||||
description = "Seeds",
|
||||
inventory_image = "seeds.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
local pb = pointed_thing.above
|
||||
if minetest.get_node_group(minetest.get_node(vector.new(pb.x,pb.y-1,pb.z)).name, "farmland") == 0 or minetest.get_node(pointed_thing.above).name ~= "air" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
|
||||
retval = fakestack:set_name("farming:wheat_0")
|
||||
retval = fakestack:set_name("farming:wheat_0")
|
||||
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
itemstack:set_name("farming:seeds")
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
itemstack:set_name("farming:seeds")
|
||||
|
||||
if retval then
|
||||
minetest.sound_play("leaves", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
if retval then
|
||||
minetest.sound_play("leaves", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
@ -283,34 +283,34 @@ minetest.register_decoration({
|
||||
|
||||
|
||||
minetest.register_craftitem("farming:wheat", {
|
||||
description = "Wheat",
|
||||
inventory_image = "wheat_harvested.png",
|
||||
description = "Wheat",
|
||||
inventory_image = "wheat_harvested.png",
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("farming:bread", {
|
||||
description = "Bread",
|
||||
inventory_image = "bread.png",
|
||||
health = 3,
|
||||
description = "Bread",
|
||||
inventory_image = "bread.png",
|
||||
health = 3,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming:toast", {
|
||||
description = "Toast",
|
||||
inventory_image = "bread.png^[colorize:black:100",
|
||||
health = 5,
|
||||
description = "Toast",
|
||||
inventory_image = "bread.png^[colorize:black:100",
|
||||
health = 5,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "farming:bread",
|
||||
recipe = {
|
||||
{"farming:wheat", "farming:wheat", "farming:wheat"}
|
||||
}
|
||||
output = "farming:bread",
|
||||
recipe = {
|
||||
{"farming:wheat", "farming:wheat", "farming:wheat"}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "farming:toast",
|
||||
recipe = "farming:bread",
|
||||
cooktime = 3,
|
||||
type = "cooking",
|
||||
output = "farming:toast",
|
||||
recipe = "farming:bread",
|
||||
cooktime = 3,
|
||||
})
|
||||
|
@ -2,53 +2,53 @@
|
||||
|
||||
--Create an initial hand tool
|
||||
minetest.register_item(":", {
|
||||
type = "none",
|
||||
wield_image = "wieldhand.png",
|
||||
wield_scale = {x=1,y=1,z=2.5},
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
stone = {times={[4]=11.5,[3]=8.5,[2]=6.70,[1]=5.5}, uses=0, maxlevel=1},
|
||||
dirt = {times={[4]=11.0,[3]=8.4,[2]=6.40,[1]=4.2}, uses=0, maxlevel=1},
|
||||
sand = {times={[4]=11.0,[3]=8.4,[2]=6.40,[1]=4.2}, uses=0, maxlevel=1},
|
||||
wood = {times={[4]=11.5,[3]=8.5,[2]=6.70,[1]=5.5}, uses=0, maxlevel=1},
|
||||
leaves = {times={[4]=4.5,[3]=3.2,[2]=2.20,[1]=1.2}, uses=0, maxlevel=0},
|
||||
instant = {times={[1]=0.1,},uses=0,maxlevel=1},
|
||||
dig_immediate = {times={[2]=0,[3]=0,[1]=0,},uses=0,maxlevel=1},
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
}
|
||||
type = "none",
|
||||
wield_image = "wieldhand.png",
|
||||
wield_scale = {x=1,y=1,z=2.5},
|
||||
tool_capabilities = {
|
||||
full_punch_interval = 0.9,
|
||||
max_drop_level = 0,
|
||||
groupcaps = {
|
||||
stone = {times={[4]=11.5,[3]=8.5,[2]=6.70,[1]=5.5}, uses=0, maxlevel=1},
|
||||
dirt = {times={[4]=11.0,[3]=8.4,[2]=6.40,[1]=4.2}, uses=0, maxlevel=1},
|
||||
sand = {times={[4]=11.0,[3]=8.4,[2]=6.40,[1]=4.2}, uses=0, maxlevel=1},
|
||||
wood = {times={[4]=11.5,[3]=8.5,[2]=6.70,[1]=5.5}, uses=0, maxlevel=1},
|
||||
leaves = {times={[4]=4.5,[3]=3.2,[2]=2.20,[1]=1.2}, uses=0, maxlevel=0},
|
||||
instant = {times={[1]=0.1,},uses=0,maxlevel=1},
|
||||
dig_immediate = {times={[2]=0,[3]=0,[1]=0,},uses=0,maxlevel=1},
|
||||
},
|
||||
damage_groups = {fleshy=1},
|
||||
}
|
||||
})
|
||||
|
||||
-- This is a fake node that should never be placed in the world
|
||||
local def = minetest.registered_items[""]
|
||||
minetest.register_node("hand:player", {
|
||||
description = "",
|
||||
tiles = {"player.png"},
|
||||
visual_scale = 1,
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
paramtype = "light",
|
||||
drawtype = "mesh",
|
||||
mesh = "hand.b3d",
|
||||
-- Prevent construction
|
||||
node_placement_prediction = "",
|
||||
on_construct = function(pos)
|
||||
minetest.log("error", "Tried to place hand at "..minetest.pos_to_string(pos))
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
drop = "",
|
||||
on_drop = function()
|
||||
return ""
|
||||
end,
|
||||
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
|
||||
range = def.range,
|
||||
description = "",
|
||||
tiles = {"player.png"},
|
||||
visual_scale = 1,
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
paramtype = "light",
|
||||
drawtype = "mesh",
|
||||
mesh = "hand.b3d",
|
||||
-- Prevent construction
|
||||
node_placement_prediction = "",
|
||||
on_construct = function(pos)
|
||||
minetest.log("error", "Tried to place hand at "..minetest.pos_to_string(pos))
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
drop = "",
|
||||
on_drop = function()
|
||||
return ""
|
||||
end,
|
||||
groups = { dig_immediate = 3, not_in_creative_inventory = 1 },
|
||||
range = def.range,
|
||||
})
|
||||
|
||||
|
||||
--Create a hand list and then enable the hand node
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
player:get_inventory():set_size("hand", 1)
|
||||
player:get_inventory():set_stack("hand", 1, "hand:player")
|
||||
player:get_inventory():set_size("hand", 1)
|
||||
player:get_inventory():set_stack("hand", 1, "hand:player")
|
||||
end)
|
||||
|
||||
|
@ -9,54 +9,54 @@ dofile(path.."/magnet.lua")
|
||||
|
||||
--handle node drops
|
||||
function minetest.handle_node_drops(pos, drops, digger)
|
||||
for _,item in ipairs(drops) do
|
||||
local count, name
|
||||
if type(item) == "string" then
|
||||
count = 1
|
||||
name = item
|
||||
else
|
||||
count = item:get_count()
|
||||
name = item:get_name()
|
||||
end
|
||||
for i=1,count do
|
||||
local obj = minetest.add_item(pos, name)
|
||||
if obj ~= nil then
|
||||
local x=math.random(-2,2)*math.random()
|
||||
local y=math.random(2,5)
|
||||
local z=math.random(-2,2)*math.random()
|
||||
obj:setvelocity({x=x, y=y, z=z})
|
||||
end
|
||||
end
|
||||
end
|
||||
for _,item in ipairs(drops) do
|
||||
local count, name
|
||||
if type(item) == "string" then
|
||||
count = 1
|
||||
name = item
|
||||
else
|
||||
count = item:get_count()
|
||||
name = item:get_name()
|
||||
end
|
||||
for i=1,count do
|
||||
local obj = minetest.add_item(pos, name)
|
||||
if obj ~= nil then
|
||||
local x=math.random(-2,2)*math.random()
|
||||
local y=math.random(2,5)
|
||||
local z=math.random(-2,2)*math.random()
|
||||
obj:setvelocity({x=x, y=y, z=z})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Minetest: builtin/item_entity.lua
|
||||
|
||||
function minetest.spawn_item(pos, item)
|
||||
-- Take item in any format
|
||||
local stack = ItemStack(item)
|
||||
local obj = minetest.add_entity(pos, "__builtin:item")
|
||||
-- Don't use obj if it couldn't be added to the map.
|
||||
if obj then
|
||||
obj:get_luaentity():set_item(stack:to_string())
|
||||
end
|
||||
return obj
|
||||
-- Take item in any format
|
||||
local stack = ItemStack(item)
|
||||
local obj = minetest.add_entity(pos, "__builtin:item")
|
||||
-- Don't use obj if it couldn't be added to the map.
|
||||
if obj then
|
||||
obj:get_luaentity():set_item(stack:to_string())
|
||||
end
|
||||
return obj
|
||||
end
|
||||
|
||||
function minetest.throw_item(pos, item)
|
||||
-- Take item in any format
|
||||
local stack = ItemStack(item)
|
||||
local obj = minetest.add_entity(pos, "__builtin:item")
|
||||
-- Don't use obj if it couldn't be added to the map.
|
||||
if obj then
|
||||
obj:get_luaentity():set_item(stack:to_string())
|
||||
local x=math.random(-2,2)*math.random()
|
||||
local y=math.random(2,5)
|
||||
local z=math.random(-2,2)*math.random()
|
||||
obj:setvelocity({x=x, y=y, z=z})
|
||||
end
|
||||
return obj
|
||||
-- Take item in any format
|
||||
local stack = ItemStack(item)
|
||||
local obj = minetest.add_entity(pos, "__builtin:item")
|
||||
-- Don't use obj if it couldn't be added to the map.
|
||||
if obj then
|
||||
obj:get_luaentity():set_item(stack:to_string())
|
||||
local x=math.random(-2,2)*math.random()
|
||||
local y=math.random(2,5)
|
||||
local z=math.random(-2,2)*math.random()
|
||||
obj:setvelocity({x=x, y=y, z=z})
|
||||
end
|
||||
return obj
|
||||
end
|
||||
|
||||
--override drops
|
||||
@ -77,7 +77,7 @@ function minetest.item_drop(itemstack, dropper, pos)
|
||||
dir.z = dir.z * 2.9
|
||||
obj:set_velocity(dir)
|
||||
obj:get_luaentity().dropped_by = dropper:get_player_name()
|
||||
obj:get_luaentity().collection_timer = 0
|
||||
obj:get_luaentity().collection_timer = 0
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
@ -93,317 +93,317 @@ local gravity = tonumber(minetest.settings:get("movement_gravity")) or 9.81
|
||||
|
||||
|
||||
minetest.register_entity(":__builtin:item", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.4, y = 0.4},
|
||||
textures = {""},
|
||||
spritediv = {x = 1, y = 1},
|
||||
initial_sprite_basepos = {x = 0, y = 0},
|
||||
is_visible = false,
|
||||
pointable = false,
|
||||
},
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
|
||||
visual = "wielditem",
|
||||
visual_size = {x = 0.4, y = 0.4},
|
||||
textures = {""},
|
||||
spritediv = {x = 1, y = 1},
|
||||
initial_sprite_basepos = {x = 0, y = 0},
|
||||
is_visible = false,
|
||||
pointable = false,
|
||||
},
|
||||
|
||||
itemstring = "",
|
||||
moving_state = true,
|
||||
slippery_state = false,
|
||||
physical_state = true,
|
||||
-- Item expiry
|
||||
age = 0,
|
||||
-- Pushing item out of solid nodes
|
||||
force_out = nil,
|
||||
force_out_start = nil,
|
||||
--Collection Variables
|
||||
collection_timer = 2,
|
||||
collection_timer_goal = collection.collection_time,
|
||||
collection_height = collection.collection_height,
|
||||
collectable = false,
|
||||
try_timer = 0,
|
||||
collected = false,
|
||||
delete_timer = 0,
|
||||
radius = collection.magnet_radius,
|
||||
itemstring = "",
|
||||
moving_state = true,
|
||||
slippery_state = false,
|
||||
physical_state = true,
|
||||
-- Item expiry
|
||||
age = 0,
|
||||
-- Pushing item out of solid nodes
|
||||
force_out = nil,
|
||||
force_out_start = nil,
|
||||
--Collection Variables
|
||||
collection_timer = 2,
|
||||
collection_timer_goal = collection.collection_time,
|
||||
collection_height = collection.collection_height,
|
||||
collectable = false,
|
||||
try_timer = 0,
|
||||
collected = false,
|
||||
delete_timer = 0,
|
||||
radius = collection.magnet_radius,
|
||||
|
||||
set_item = function(self, item)
|
||||
local stack = ItemStack(item or self.itemstring)
|
||||
self.itemstring = stack:to_string()
|
||||
if self.itemstring == "" then
|
||||
-- item not yet known
|
||||
return
|
||||
end
|
||||
set_item = function(self, item)
|
||||
local stack = ItemStack(item or self.itemstring)
|
||||
self.itemstring = stack:to_string()
|
||||
if self.itemstring == "" then
|
||||
-- item not yet known
|
||||
return
|
||||
end
|
||||
|
||||
-- Backwards compatibility: old clients use the texture
|
||||
-- to get the type of the item
|
||||
local itemname = stack:is_known() and stack:get_name() or "unknown"
|
||||
-- Backwards compatibility: old clients use the texture
|
||||
-- to get the type of the item
|
||||
local itemname = stack:is_known() and stack:get_name() or "unknown"
|
||||
|
||||
local max_count = stack:get_stack_max()
|
||||
local count = math.min(stack:get_count(), max_count)
|
||||
local size = 0.2 + 0.1 * (count / max_count) ^ (1 / 3)
|
||||
local coll_height = size * 0.75
|
||||
local def = minetest.registered_nodes[itemname]
|
||||
local glow = def and def.light_source
|
||||
local max_count = stack:get_stack_max()
|
||||
local count = math.min(stack:get_count(), max_count)
|
||||
local size = 0.2 + 0.1 * (count / max_count) ^ (1 / 3)
|
||||
local coll_height = size * 0.75
|
||||
local def = minetest.registered_nodes[itemname]
|
||||
local glow = def and def.light_source
|
||||
|
||||
self.object:set_properties({
|
||||
is_visible = true,
|
||||
visual = "wielditem",
|
||||
textures = {itemname},
|
||||
visual_size = {x = size, y = size},
|
||||
collisionbox = {-size, -coll_height, -size,
|
||||
size, coll_height, size},
|
||||
selectionbox = {-size, -size, -size, size, size, size},
|
||||
automatic_rotate = math.pi * 0.5 * 0.2 / size,
|
||||
wield_item = self.itemstring,
|
||||
glow = glow,
|
||||
})
|
||||
self.object:set_properties({
|
||||
is_visible = true,
|
||||
visual = "wielditem",
|
||||
textures = {itemname},
|
||||
visual_size = {x = size, y = size},
|
||||
collisionbox = {-size, -coll_height, -size,
|
||||
size, coll_height, size},
|
||||
selectionbox = {-size, -size, -size, size, size, size},
|
||||
automatic_rotate = math.pi * 0.5 * 0.2 / size,
|
||||
wield_item = self.itemstring,
|
||||
glow = glow,
|
||||
})
|
||||
|
||||
end,
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
itemstring = self.itemstring,
|
||||
age = self.age,
|
||||
dropped_by = self.dropped_by,
|
||||
collection_timer = self.collection_timer,
|
||||
collectable = self.collectable,
|
||||
try_timer = self.try_timer,
|
||||
collected = self.collected,
|
||||
delete_timer = self.delete_timer,
|
||||
collector = self.collector,
|
||||
})
|
||||
end,
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
itemstring = self.itemstring,
|
||||
age = self.age,
|
||||
dropped_by = self.dropped_by,
|
||||
collection_timer = self.collection_timer,
|
||||
collectable = self.collectable,
|
||||
try_timer = self.try_timer,
|
||||
collected = self.collected,
|
||||
delete_timer = self.delete_timer,
|
||||
collector = self.collector,
|
||||
})
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if string.sub(staticdata, 1, string.len("return")) == "return" then
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if data and type(data) == "table" then
|
||||
self.itemstring = data.itemstring
|
||||
self.age = (data.age or 0) + dtime_s
|
||||
self.dropped_by = data.dropped_by
|
||||
|
||||
self.collection_timer = data.collection_timer
|
||||
self.collectable = data.collectable
|
||||
self.try_timer = data.try_timer
|
||||
self.collected = data.collected
|
||||
self.delete_timer = data.delete_timer
|
||||
self.collector = data.collector
|
||||
--print("restored timer: "..self.collection_timer)
|
||||
end
|
||||
else
|
||||
self.itemstring = staticdata
|
||||
|
||||
local x=math.random(-2,2)*math.random()
|
||||
local y=math.random(2,5)
|
||||
local z=math.random(-2,2)*math.random()
|
||||
self.object:setvelocity(vector.new(x,y,z))
|
||||
-- print(self.collection_timer)
|
||||
end
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
self.object:set_velocity({x = 0, y = 2, z = 0})
|
||||
self.object:set_acceleration({x = 0, y = -gravity, z = 0})
|
||||
self:set_item()
|
||||
end,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
if string.sub(staticdata, 1, string.len("return")) == "return" then
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if data and type(data) == "table" then
|
||||
self.itemstring = data.itemstring
|
||||
self.age = (data.age or 0) + dtime_s
|
||||
self.dropped_by = data.dropped_by
|
||||
|
||||
self.collection_timer = data.collection_timer
|
||||
self.collectable = data.collectable
|
||||
self.try_timer = data.try_timer
|
||||
self.collected = data.collected
|
||||
self.delete_timer = data.delete_timer
|
||||
self.collector = data.collector
|
||||
--print("restored timer: "..self.collection_timer)
|
||||
end
|
||||
else
|
||||
self.itemstring = staticdata
|
||||
|
||||
local x=math.random(-2,2)*math.random()
|
||||
local y=math.random(2,5)
|
||||
local z=math.random(-2,2)*math.random()
|
||||
self.object:setvelocity(vector.new(x,y,z))
|
||||
-- print(self.collection_timer)
|
||||
end
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
self.object:set_velocity({x = 0, y = 2, z = 0})
|
||||
self.object:set_acceleration({x = 0, y = -gravity, z = 0})
|
||||
self:set_item()
|
||||
end,
|
||||
|
||||
enable_physics = function(self)
|
||||
if not self.physical_state then
|
||||
self.physical_state = true
|
||||
self.object:set_properties({physical = true})
|
||||
self.object:set_velocity({x=0, y=0, z=0})
|
||||
self.object:set_acceleration({x=0, y=-gravity, z=0})
|
||||
end
|
||||
end,
|
||||
enable_physics = function(self)
|
||||
if not self.physical_state then
|
||||
self.physical_state = true
|
||||
self.object:set_properties({physical = true})
|
||||
self.object:set_velocity({x=0, y=0, z=0})
|
||||
self.object:set_acceleration({x=0, y=-gravity, z=0})
|
||||
end
|
||||
end,
|
||||
|
||||
disable_physics = function(self)
|
||||
if self.physical_state then
|
||||
self.physical_state = false
|
||||
self.object:set_properties({physical = false})
|
||||
self.object:set_velocity({x=0, y=0, z=0})
|
||||
self.object:set_acceleration({x=0, y=0, z=0})
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
--if item set to be collected then only execute go to player
|
||||
if self.collected == true then
|
||||
if not self.collector then
|
||||
self.collected = false
|
||||
print("throwing exception")
|
||||
return
|
||||
end
|
||||
local collector = minetest.get_player_by_name(self.collector)
|
||||
if collector then
|
||||
self.object:setacceleration(vector.new(0,0,0))
|
||||
self.disable_physics(self)
|
||||
--get the variables
|
||||
local pos = self.object:getpos()
|
||||
local pos2 = collector:getpos()
|
||||
local player_velocity = collector:get_player_velocity()
|
||||
pos2.y = pos2.y + self.collection_height
|
||||
|
||||
local direction = vector.normalize(vector.subtract(pos2,pos))
|
||||
local distance = vector.distance(pos2,pos)
|
||||
|
||||
|
||||
--remove if too far away
|
||||
if distance > self.radius then
|
||||
distance = 0
|
||||
end
|
||||
|
||||
local multiplier = (self.radius*5) - distance
|
||||
local velocity = vector.multiply(direction,multiplier)
|
||||
|
||||
local velocity = vector.add(player_velocity,velocity)
|
||||
|
||||
self.object:setvelocity(velocity)
|
||||
|
||||
if distance < 0.2 then
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
|
||||
--self.delete_timer = self.delete_timer + dtime
|
||||
--this is where the item gets removed from world
|
||||
--if self.delete_timer > 1 then
|
||||
-- self.object:remove()
|
||||
--end
|
||||
return
|
||||
else
|
||||
print(self.collector.." does not exist")
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
|
||||
--allow entity to be collected after timer
|
||||
if self.collectable == false and self.collection_timer >= self.collection_timer_goal then
|
||||
self.collectable = true
|
||||
elseif self.collectable == false then
|
||||
self.collection_timer = self.collection_timer + dtime
|
||||
end
|
||||
|
||||
self.age = self.age + dtime
|
||||
if time_to_live > 0 and self.age > time_to_live then
|
||||
self.itemstring = ""
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
disable_physics = function(self)
|
||||
if self.physical_state then
|
||||
self.physical_state = false
|
||||
self.object:set_properties({physical = false})
|
||||
self.object:set_velocity({x=0, y=0, z=0})
|
||||
self.object:set_acceleration({x=0, y=0, z=0})
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
--if item set to be collected then only execute go to player
|
||||
if self.collected == true then
|
||||
if not self.collector then
|
||||
self.collected = false
|
||||
print("throwing exception")
|
||||
return
|
||||
end
|
||||
local collector = minetest.get_player_by_name(self.collector)
|
||||
if collector then
|
||||
self.object:setacceleration(vector.new(0,0,0))
|
||||
self.disable_physics(self)
|
||||
--get the variables
|
||||
local pos = self.object:getpos()
|
||||
local pos2 = collector:getpos()
|
||||
local player_velocity = collector:get_player_velocity()
|
||||
pos2.y = pos2.y + self.collection_height
|
||||
|
||||
local direction = vector.normalize(vector.subtract(pos2,pos))
|
||||
local distance = vector.distance(pos2,pos)
|
||||
|
||||
|
||||
--remove if too far away
|
||||
if distance > self.radius then
|
||||
distance = 0
|
||||
end
|
||||
|
||||
local multiplier = (self.radius*5) - distance
|
||||
local velocity = vector.multiply(direction,multiplier)
|
||||
|
||||
local velocity = vector.add(player_velocity,velocity)
|
||||
|
||||
self.object:setvelocity(velocity)
|
||||
|
||||
if distance < 0.2 then
|
||||
self.object:remove()
|
||||
end
|
||||
|
||||
|
||||
--self.delete_timer = self.delete_timer + dtime
|
||||
--this is where the item gets removed from world
|
||||
--if self.delete_timer > 1 then
|
||||
-- self.object:remove()
|
||||
--end
|
||||
return
|
||||
else
|
||||
print(self.collector.." does not exist")
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
|
||||
--allow entity to be collected after timer
|
||||
if self.collectable == false and self.collection_timer >= self.collection_timer_goal then
|
||||
self.collectable = true
|
||||
elseif self.collectable == false then
|
||||
self.collection_timer = self.collection_timer + dtime
|
||||
end
|
||||
|
||||
self.age = self.age + dtime
|
||||
if time_to_live > 0 and self.age > time_to_live then
|
||||
self.itemstring = ""
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
local node = minetest.get_node_or_nil({
|
||||
x = pos.x,
|
||||
y = pos.y + self.object:get_properties().collisionbox[2] - 0.05,
|
||||
z = pos.z
|
||||
})
|
||||
-- Delete in 'ignore' nodes
|
||||
if node and node.name == "ignore" then
|
||||
self.itemstring = ""
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
local pos = self.object:get_pos()
|
||||
local node = minetest.get_node_or_nil({
|
||||
x = pos.x,
|
||||
y = pos.y + self.object:get_properties().collisionbox[2] - 0.05,
|
||||
z = pos.z
|
||||
})
|
||||
-- Delete in 'ignore' nodes
|
||||
if node and node.name == "ignore" then
|
||||
self.itemstring = ""
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
local is_stuck = false
|
||||
local snode = minetest.get_node_or_nil(pos)
|
||||
if snode then
|
||||
local sdef = minetest.registered_nodes[snode.name] or {}
|
||||
is_stuck = (sdef.walkable == nil or sdef.walkable == true)
|
||||
and (sdef.collision_box == nil or sdef.collision_box.type == "regular")
|
||||
and (sdef.node_box == nil or sdef.node_box.type == "regular")
|
||||
end
|
||||
local is_stuck = false
|
||||
local snode = minetest.get_node_or_nil(pos)
|
||||
if snode then
|
||||
local sdef = minetest.registered_nodes[snode.name] or {}
|
||||
is_stuck = (sdef.walkable == nil or sdef.walkable == true)
|
||||
and (sdef.collision_box == nil or sdef.collision_box.type == "regular")
|
||||
and (sdef.node_box == nil or sdef.node_box.type == "regular")
|
||||
end
|
||||
|
||||
-- Push item out when stuck inside solid node
|
||||
if is_stuck then
|
||||
local shootdir
|
||||
local order = {
|
||||
{x=1, y=0, z=0}, {x=-1, y=0, z= 0},
|
||||
{x=0, y=0, z=1}, {x= 0, y=0, z=-1},
|
||||
}
|
||||
-- Push item out when stuck inside solid node
|
||||
if is_stuck then
|
||||
local shootdir
|
||||
local order = {
|
||||
{x=1, y=0, z=0}, {x=-1, y=0, z= 0},
|
||||
{x=0, y=0, z=1}, {x= 0, y=0, z=-1},
|
||||
}
|
||||
|
||||
-- Check which one of the 4 sides is free
|
||||
for o = 1, #order do
|
||||
local cnode = minetest.get_node(vector.add(pos, order[o])).name
|
||||
local cdef = minetest.registered_nodes[cnode] or {}
|
||||
if cnode ~= "ignore" and cdef.walkable == false then
|
||||
shootdir = order[o]
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If none of the 4 sides is free, check upwards
|
||||
if not shootdir then
|
||||
shootdir = {x=0, y=1, z=0}
|
||||
local cnode = minetest.get_node(vector.add(pos, shootdir)).name
|
||||
if cnode == "ignore" then
|
||||
shootdir = nil -- Do not push into ignore
|
||||
end
|
||||
end
|
||||
-- Check which one of the 4 sides is free
|
||||
for o = 1, #order do
|
||||
local cnode = minetest.get_node(vector.add(pos, order[o])).name
|
||||
local cdef = minetest.registered_nodes[cnode] or {}
|
||||
if cnode ~= "ignore" and cdef.walkable == false then
|
||||
shootdir = order[o]
|
||||
break
|
||||
end
|
||||
end
|
||||
-- If none of the 4 sides is free, check upwards
|
||||
if not shootdir then
|
||||
shootdir = {x=0, y=1, z=0}
|
||||
local cnode = minetest.get_node(vector.add(pos, shootdir)).name
|
||||
if cnode == "ignore" then
|
||||
shootdir = nil -- Do not push into ignore
|
||||
end
|
||||
end
|
||||
|
||||
if shootdir then
|
||||
-- Set new item moving speed accordingly
|
||||
local newv = vector.multiply(shootdir, 3)
|
||||
self:disable_physics()
|
||||
self.object:set_velocity(newv)
|
||||
if shootdir then
|
||||
-- Set new item moving speed accordingly
|
||||
local newv = vector.multiply(shootdir, 3)
|
||||
self:disable_physics()
|
||||
self.object:set_velocity(newv)
|
||||
|
||||
self.force_out = newv
|
||||
self.force_out_start = vector.round(pos)
|
||||
return
|
||||
end
|
||||
elseif self.force_out then
|
||||
-- This code runs after the entity got a push from the above code.
|
||||
-- It makes sure the entity is entirely outside the solid node
|
||||
local c = self.object:get_properties().collisionbox
|
||||
local s = self.force_out_start
|
||||
local f = self.force_out
|
||||
local ok = (f.x > 0 and pos.x + c[1] > s.x + 0.5) or
|
||||
(f.y > 0 and pos.y + c[2] > s.y + 0.5) or
|
||||
(f.z > 0 and pos.z + c[3] > s.z + 0.5) or
|
||||
(f.x < 0 and pos.x + c[4] < s.x - 0.5) or
|
||||
(f.z < 0 and pos.z + c[6] < s.z - 0.5)
|
||||
if ok then
|
||||
-- Item was successfully forced out
|
||||
self.force_out = nil
|
||||
self:enable_physics()
|
||||
end
|
||||
end
|
||||
self.force_out = newv
|
||||
self.force_out_start = vector.round(pos)
|
||||
return
|
||||
end
|
||||
elseif self.force_out then
|
||||
-- This code runs after the entity got a push from the above code.
|
||||
-- It makes sure the entity is entirely outside the solid node
|
||||
local c = self.object:get_properties().collisionbox
|
||||
local s = self.force_out_start
|
||||
local f = self.force_out
|
||||
local ok = (f.x > 0 and pos.x + c[1] > s.x + 0.5) or
|
||||
(f.y > 0 and pos.y + c[2] > s.y + 0.5) or
|
||||
(f.z > 0 and pos.z + c[3] > s.z + 0.5) or
|
||||
(f.x < 0 and pos.x + c[4] < s.x - 0.5) or
|
||||
(f.z < 0 and pos.z + c[6] < s.z - 0.5)
|
||||
if ok then
|
||||
-- Item was successfully forced out
|
||||
self.force_out = nil
|
||||
self:enable_physics()
|
||||
end
|
||||
end
|
||||
|
||||
if not self.physical_state then
|
||||
return -- Don't do anything
|
||||
end
|
||||
if not self.physical_state then
|
||||
return -- Don't do anything
|
||||
end
|
||||
|
||||
-- Slide on slippery nodes
|
||||
local vel = self.object:get_velocity()
|
||||
local def = node and minetest.registered_nodes[node.name]
|
||||
local is_moving = (def and not def.walkable) or
|
||||
vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0
|
||||
local is_slippery = false
|
||||
-- Slide on slippery nodes
|
||||
local vel = self.object:get_velocity()
|
||||
local def = node and minetest.registered_nodes[node.name]
|
||||
local is_moving = (def and not def.walkable) or
|
||||
vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0
|
||||
local is_slippery = false
|
||||
|
||||
if def and def.walkable then
|
||||
local slippery = minetest.get_item_group(node.name, "slippery")
|
||||
is_slippery = slippery ~= 0
|
||||
if is_slippery and (math.abs(vel.x) > 0.2 or math.abs(vel.z) > 0.2) then
|
||||
-- Horizontal deceleration
|
||||
local slip_factor = 4.0 / (slippery + 4)
|
||||
self.object:set_acceleration({
|
||||
x = -vel.x * slip_factor,
|
||||
y = 0,
|
||||
z = -vel.z * slip_factor
|
||||
})
|
||||
elseif vel.y == 0 then
|
||||
is_moving = false
|
||||
end
|
||||
end
|
||||
if def and def.walkable then
|
||||
local slippery = minetest.get_item_group(node.name, "slippery")
|
||||
is_slippery = slippery ~= 0
|
||||
if is_slippery and (math.abs(vel.x) > 0.2 or math.abs(vel.z) > 0.2) then
|
||||
-- Horizontal deceleration
|
||||
local slip_factor = 4.0 / (slippery + 4)
|
||||
self.object:set_acceleration({
|
||||
x = -vel.x * slip_factor,
|
||||
y = 0,
|
||||
z = -vel.z * slip_factor
|
||||
})
|
||||
elseif vel.y == 0 then
|
||||
is_moving = false
|
||||
end
|
||||
end
|
||||
|
||||
if self.moving_state == is_moving and
|
||||
self.slippery_state == is_slippery then
|
||||
-- Do not update anything until the moving state changes
|
||||
return
|
||||
end
|
||||
if self.moving_state == is_moving and
|
||||
self.slippery_state == is_slippery then
|
||||
-- Do not update anything until the moving state changes
|
||||
return
|
||||
end
|
||||
|
||||
self.moving_state = is_moving
|
||||
self.slippery_state = is_slippery
|
||||
self.moving_state = is_moving
|
||||
self.slippery_state = is_slippery
|
||||
|
||||
if is_moving then
|
||||
self.object:set_acceleration({x = 0, y = -gravity, z = 0})
|
||||
else
|
||||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
||||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||
end
|
||||
end,
|
||||
if is_moving then
|
||||
self.object:set_acceleration({x = 0, y = -gravity, z = 0})
|
||||
else
|
||||
self.object:set_acceleration({x = 0, y = 0, z = 0})
|
||||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -1,38 +1,38 @@
|
||||
--The item collection magnet
|
||||
--Item collection
|
||||
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+collection.collection_height,z=pos.z}, collection.magnet_radius)) do
|
||||
local pos2 = object:getpos()
|
||||
if (collection.allow_lower == false and vector.subtract(pos2,pos).y >= 0) or collection.allow_lower == true then
|
||||
|
||||
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:get_luaentity().collector = player:get_player_name()
|
||||
object:get_luaentity().collected = true
|
||||
-- print("Set flag at item: "..dump(object:getpos()))
|
||||
--object:moveto({x=pos.x,y=pos.y+eye_height,z=pos.z,continuous=true})
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--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+collection.collection_height,z=pos.z}, collection.magnet_radius)) do
|
||||
local pos2 = object:getpos()
|
||||
if (collection.allow_lower == false and vector.subtract(pos2,pos).y >= 0) or collection.allow_lower == true then
|
||||
|
||||
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:get_luaentity().collector = player:get_player_name()
|
||||
object:get_luaentity().collected = true
|
||||
-- print("Set flag at item: "..dump(object:getpos()))
|
||||
--object:moveto({x=pos.x,y=pos.y+eye_height,z=pos.z,continuous=true})
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -1,37 +1,37 @@
|
||||
-- Item definitions
|
||||
minetest.register_craftitem("main:bucket", {
|
||||
description = "Bucket",
|
||||
inventory_image = "bucket.png",
|
||||
--wield_image = "bucket.png",
|
||||
liquids_pointable = true,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
--set it to water
|
||||
if minetest.get_node(pointed_thing.under).name == "main:water" then
|
||||
itemstack:replace(ItemStack("main:bucket_water"))
|
||||
minetest.remove_node(pointed_thing.under)
|
||||
return(itemstack)
|
||||
end
|
||||
end
|
||||
description = "Bucket",
|
||||
inventory_image = "bucket.png",
|
||||
--wield_image = "bucket.png",
|
||||
liquids_pointable = true,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
--set it to water
|
||||
if minetest.get_node(pointed_thing.under).name == "main:water" then
|
||||
itemstack:replace(ItemStack("main:bucket_water"))
|
||||
minetest.remove_node(pointed_thing.under)
|
||||
return(itemstack)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("main:bucket_water", {
|
||||
description = "Bucket with Water",
|
||||
inventory_image = "bucket_water.png",
|
||||
--wield_image = "bucket.png",
|
||||
liquids_pointable = false,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
--set it to water
|
||||
local is_farmland = minetest.get_node(pointed_thing.under).name == "farming:farmland_dry"
|
||||
local node = minetest.get_node(pointed_thing.above).name
|
||||
if node == "air" or node == "main:water" or node == "main:waterflow" then
|
||||
minetest.set_node(pointed_thing.above,{name="main:water"})
|
||||
itemstack:replace(ItemStack("main:bucket"))
|
||||
return(itemstack)
|
||||
elseif is_farmland then
|
||||
minetest.set_node(pointed_thing.under,{name="farming:farmland_wet"})
|
||||
itemstack:replace(ItemStack("main:bucket"))
|
||||
return(itemstack)
|
||||
end
|
||||
end
|
||||
description = "Bucket with Water",
|
||||
inventory_image = "bucket_water.png",
|
||||
--wield_image = "bucket.png",
|
||||
liquids_pointable = false,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
--set it to water
|
||||
local is_farmland = minetest.get_node(pointed_thing.under).name == "farming:farmland_dry"
|
||||
local node = minetest.get_node(pointed_thing.above).name
|
||||
if node == "air" or node == "main:water" or node == "main:waterflow" then
|
||||
minetest.set_node(pointed_thing.above,{name="main:water"})
|
||||
itemstack:replace(ItemStack("main:bucket"))
|
||||
return(itemstack)
|
||||
elseif is_farmland then
|
||||
minetest.set_node(pointed_thing.under,{name="farming:farmland_wet"})
|
||||
itemstack:replace(ItemStack("main:bucket"))
|
||||
return(itemstack)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@ -2,137 +2,137 @@
|
||||
|
||||
--cooking
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "main:diamond",
|
||||
recipe = "main:diamondore",
|
||||
cooktime = 12,
|
||||
type = "cooking",
|
||||
output = "main:diamond",
|
||||
recipe = "main:diamondore",
|
||||
cooktime = 12,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "main:coal 4",
|
||||
recipe = "main:coalore",
|
||||
cooktime = 3,
|
||||
type = "cooking",
|
||||
output = "main:coal 4",
|
||||
recipe = "main:coalore",
|
||||
cooktime = 3,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "main:charcoal",
|
||||
recipe = "main:tree",
|
||||
cooktime = 2,
|
||||
type = "cooking",
|
||||
output = "main:charcoal",
|
||||
recipe = "main:tree",
|
||||
cooktime = 2,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "main:gold",
|
||||
recipe = "main:goldore",
|
||||
cooktime = 9,
|
||||
type = "cooking",
|
||||
output = "main:gold",
|
||||
recipe = "main:goldore",
|
||||
cooktime = 9,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "main:iron",
|
||||
recipe = "main:ironore",
|
||||
cooktime = 6,
|
||||
type = "cooking",
|
||||
output = "main:iron",
|
||||
recipe = "main:ironore",
|
||||
cooktime = 6,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "main:stone",
|
||||
recipe = "main:cobble",
|
||||
cooktime = 3,
|
||||
type = "cooking",
|
||||
output = "main:stone",
|
||||
recipe = "main:cobble",
|
||||
cooktime = 3,
|
||||
})
|
||||
|
||||
--fuel fuel fuel
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "main:stick",
|
||||
burntime = 1,
|
||||
type = "fuel",
|
||||
recipe = "main:stick",
|
||||
burntime = 1,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "main:tree",
|
||||
burntime = 24,
|
||||
type = "fuel",
|
||||
recipe = "main:tree",
|
||||
burntime = 24,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "main:wood",
|
||||
burntime = 12,
|
||||
type = "fuel",
|
||||
recipe = "main:wood",
|
||||
burntime = 12,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "main:leaves",
|
||||
burntime = 3,
|
||||
type = "fuel",
|
||||
recipe = "main:leaves",
|
||||
burntime = 3,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "main:coal",
|
||||
burntime = 20,
|
||||
type = "fuel",
|
||||
recipe = "main:coal",
|
||||
burntime = 20,
|
||||
})
|
||||
---crafting
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "main:wood 4",
|
||||
recipe = {"main:tree"},
|
||||
type = "shapeless",
|
||||
output = "main:wood 4",
|
||||
recipe = {"main:tree"},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "main:stick 4",
|
||||
recipe = {
|
||||
{"main:wood"},
|
||||
{"main:wood"}
|
||||
}
|
||||
output = "main:stick 4",
|
||||
recipe = {
|
||||
{"main:wood"},
|
||||
{"main:wood"}
|
||||
}
|
||||
})
|
||||
|
||||
local tool = {"wood","stone", "iron","gold","diamond"}--the tool name
|
||||
local material = {"wood","cobble","iron","gold","diamond"}--material to craft
|
||||
|
||||
for id,tool in pairs(tool) do
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."pick",
|
||||
recipe = {
|
||||
{"main:"..material[id], "main:"..material[id], "main:"..material[id]},
|
||||
{"", "main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."shovel",
|
||||
recipe = {
|
||||
{"","main:"..material[id], ""},
|
||||
{"", "main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."axe",
|
||||
recipe = {
|
||||
{"main:"..material[id], "main:"..material[id], ""},
|
||||
{"main:"..material[id], "main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."axe",
|
||||
recipe = {
|
||||
{"", "main:"..material[id], "main:"..material[id]},
|
||||
{"", "main:stick", "main:"..material[id]},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."sword",
|
||||
recipe = {
|
||||
{"","main:"..material[id], ""},
|
||||
{"","main:"..material[id], ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."pick",
|
||||
recipe = {
|
||||
{"main:"..material[id], "main:"..material[id], "main:"..material[id]},
|
||||
{"", "main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."shovel",
|
||||
recipe = {
|
||||
{"","main:"..material[id], ""},
|
||||
{"", "main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."axe",
|
||||
recipe = {
|
||||
{"main:"..material[id], "main:"..material[id], ""},
|
||||
{"main:"..material[id], "main:stick", ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."axe",
|
||||
recipe = {
|
||||
{"", "main:"..material[id], "main:"..material[id]},
|
||||
{"", "main:stick", "main:"..material[id]},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "main:"..tool.."sword",
|
||||
recipe = {
|
||||
{"","main:"..material[id], ""},
|
||||
{"","main:"..material[id], ""},
|
||||
{"", "main:stick", ""}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "main:ladder",
|
||||
recipe = {
|
||||
{"main:stick","", "main:stick"},
|
||||
{"main:stick","main:stick", "main:stick"},
|
||||
{"main:stick", "", "main:stick"}
|
||||
}
|
||||
output = "main:ladder",
|
||||
recipe = {
|
||||
{"main:stick","", "main:stick"},
|
||||
{"main:stick","main:stick", "main:stick"},
|
||||
{"main:stick", "", "main:stick"}
|
||||
}
|
||||
})
|
||||
|
@ -1,17 +1,17 @@
|
||||
--grass spread abm
|
||||
minetest.register_abm({
|
||||
label = "Grass Grow",
|
||||
nodenames = {"main:dirt"},
|
||||
neighbors = {"main:grass"},
|
||||
interval = 10,
|
||||
chance = 2000,
|
||||
action = function(pos)
|
||||
local light = minetest.get_node_light(pos, nil)
|
||||
--print(light)
|
||||
if light < 10 then
|
||||
--print("failed to grow grass at "..dump(pos))
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos,{name="main:grass"})
|
||||
end,
|
||||
label = "Grass Grow",
|
||||
nodenames = {"main:dirt"},
|
||||
neighbors = {"main:grass"},
|
||||
interval = 10,
|
||||
chance = 2000,
|
||||
action = function(pos)
|
||||
local light = minetest.get_node_light(pos, nil)
|
||||
--print(light)
|
||||
if light < 10 then
|
||||
--print("failed to grow grass at "..dump(pos))
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos,{name="main:grass"})
|
||||
end,
|
||||
})
|
||||
|
@ -1,37 +1,37 @@
|
||||
--item definition
|
||||
|
||||
minetest.register_craftitem("main:apple", {
|
||||
description = "Apple",
|
||||
inventory_image = "apple.png",
|
||||
health = 1,
|
||||
description = "Apple",
|
||||
inventory_image = "apple.png",
|
||||
health = 1,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:stick", {
|
||||
description = "Stick",
|
||||
inventory_image = "stick.png",
|
||||
description = "Stick",
|
||||
inventory_image = "stick.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:coal", {
|
||||
description = "Coal",
|
||||
inventory_image = "coal.png",
|
||||
description = "Coal",
|
||||
inventory_image = "coal.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:charcoal", {
|
||||
description = "Charcoal",
|
||||
inventory_image = "charcoal.png",
|
||||
description = "Charcoal",
|
||||
inventory_image = "charcoal.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:iron", {
|
||||
description = "Iron",
|
||||
inventory_image = "iron.png",
|
||||
description = "Iron",
|
||||
inventory_image = "iron.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:gold", {
|
||||
description = "Gold",
|
||||
inventory_image = "gold.png",
|
||||
description = "Gold",
|
||||
inventory_image = "gold.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem("main:diamond", {
|
||||
description = "Diamond",
|
||||
inventory_image = "diamond.png",
|
||||
description = "Diamond",
|
||||
inventory_image = "diamond.png",
|
||||
})
|
||||
|
@ -11,97 +11,97 @@ minetest.register_alias("mapgen_leaves", "main:leaves")
|
||||
print("Initializing biomes")
|
||||
--[[
|
||||
minetest.register_biome({
|
||||
name = "greenhills",
|
||||
node_top = " main:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "main:grass",
|
||||
depth_filler = 3,
|
||||
--node_riverbed = "default:sand",
|
||||
--depth_riverbed = 2,
|
||||
--node_dungeon = "default:cobble",
|
||||
--node_dungeon_alt = "default:mossycobble",
|
||||
--node_dungeon_stair = "stairs:stair_cobble",
|
||||
y_max = 31000,
|
||||
y_min = -31000,
|
||||
--heat_point = 50,
|
||||
--humidity_point = 35,
|
||||
})
|
||||
name = "greenhills",
|
||||
node_top = " main:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "main:grass",
|
||||
depth_filler = 3,
|
||||
--node_riverbed = "default:sand",
|
||||
--depth_riverbed = 2,
|
||||
--node_dungeon = "default:cobble",
|
||||
--node_dungeon_alt = "default:mossycobble",
|
||||
--node_dungeon_stair = "stairs:stair_cobble",
|
||||
y_max = 31000,
|
||||
y_min = -31000,
|
||||
--heat_point = 50,
|
||||
--humidity_point = 35,
|
||||
})
|
||||
]]--
|
||||
|
||||
minetest.register_biome({
|
||||
name = "grassland",
|
||||
node_top = "main:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "main:dirt",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "main:dirt",
|
||||
depth_riverbed = 2,
|
||||
--node_dungeon = "default:cobble",
|
||||
--node_dungeon_alt = "default:mossycobble",
|
||||
--node_dungeon_stair = "stairs:stair_cobble",
|
||||
y_max = 31000,
|
||||
y_min = 6,
|
||||
heat_point = 50,
|
||||
humidity_point = 35,
|
||||
})
|
||||
name = "grassland",
|
||||
node_top = "main:grass",
|
||||
depth_top = 1,
|
||||
node_filler = "main:dirt",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "main:dirt",
|
||||
depth_riverbed = 2,
|
||||
--node_dungeon = "default:cobble",
|
||||
--node_dungeon_alt = "default:mossycobble",
|
||||
--node_dungeon_stair = "stairs:stair_cobble",
|
||||
y_max = 31000,
|
||||
y_min = 6,
|
||||
heat_point = 50,
|
||||
humidity_point = 35,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_biome({
|
||||
name = "sandDunes",
|
||||
node_top = "main:sand",
|
||||
depth_top = 1,
|
||||
node_filler = "main:sand",
|
||||
depth_filler = 2,
|
||||
node_riverbed = "main:sand",
|
||||
depth_riverbed = 2,
|
||||
--node_dungeon = "default:cobble",
|
||||
--node_dungeon_alt = "default:mossycobble",
|
||||
--node_dungeon_stair = "stairs:stair_cobble",
|
||||
vertical_blend = 1,
|
||||
y_max = 5,
|
||||
y_min = 4,
|
||||
heat_point = 50,
|
||||
humidity_point = 35,
|
||||
})
|
||||
name = "sandDunes",
|
||||
node_top = "main:sand",
|
||||
depth_top = 1,
|
||||
node_filler = "main:sand",
|
||||
depth_filler = 2,
|
||||
node_riverbed = "main:sand",
|
||||
depth_riverbed = 2,
|
||||
--node_dungeon = "default:cobble",
|
||||
--node_dungeon_alt = "default:mossycobble",
|
||||
--node_dungeon_stair = "stairs:stair_cobble",
|
||||
vertical_blend = 1,
|
||||
y_max = 5,
|
||||
y_min = 4,
|
||||
heat_point = 50,
|
||||
humidity_point = 35,
|
||||
})
|
||||
|
||||
minetest.register_biome({
|
||||
name = "beach",
|
||||
node_top = "main:sand",
|
||||
depth_top = 1,
|
||||
node_filler = "main:sand",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "main:sand",
|
||||
depth_riverbed = 2,
|
||||
node_cave_liquid = "main:water",
|
||||
--node_dungeon = "main:cobble",
|
||||
--node_dungeon_alt = "default:mossycobble",
|
||||
--node_dungeon_stair = "stairs:stair_cobble",
|
||||
y_max = 3,
|
||||
y_min = -255,
|
||||
heat_point = 50,
|
||||
humidity_point = 35,
|
||||
})
|
||||
|
||||
|
||||
name = "beach",
|
||||
node_top = "main:sand",
|
||||
depth_top = 1,
|
||||
node_filler = "main:sand",
|
||||
depth_filler = 3,
|
||||
node_riverbed = "main:sand",
|
||||
depth_riverbed = 2,
|
||||
node_cave_liquid = "main:water",
|
||||
--node_dungeon = "main:cobble",
|
||||
--node_dungeon_alt = "default:mossycobble",
|
||||
--node_dungeon_stair = "stairs:stair_cobble",
|
||||
y_max = 3,
|
||||
y_min = -255,
|
||||
heat_point = 50,
|
||||
humidity_point = 35,
|
||||
})
|
||||
|
||||
|
||||
print("Initializing Decorations!")
|
||||
|
||||
minetest.register_decoration({
|
||||
name = "main:tree",
|
||||
deco_type = "schematic",
|
||||
place_on = {"main:grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0.024,
|
||||
scale = 0.015,
|
||||
spread = {x = 250, y = 250, z = 250},
|
||||
seed = 2,
|
||||
octaves = 3,
|
||||
persist = 0.66
|
||||
},
|
||||
biomes = {"grassland"},
|
||||
y_max = 31000,
|
||||
y_min = 0,
|
||||
schematic = treeSchematic,
|
||||
flags = "place_center_x, place_center_z",
|
||||
rotation = "random",
|
||||
})
|
||||
name = "main:tree",
|
||||
deco_type = "schematic",
|
||||
place_on = {"main:grass"},
|
||||
sidelen = 16,
|
||||
noise_params = {
|
||||
offset = 0.024,
|
||||
scale = 0.015,
|
||||
spread = {x = 250, y = 250, z = 250},
|
||||
seed = 2,
|
||||
octaves = 3,
|
||||
persist = 0.66
|
||||
},
|
||||
biomes = {"grassland"},
|
||||
y_max = 31000,
|
||||
y_min = 0,
|
||||
schematic = treeSchematic,
|
||||
flags = "place_center_x, place_center_z",
|
||||
rotation = "random",
|
||||
})
|
||||
|
@ -4,32 +4,32 @@ print("Initializing nodes")
|
||||
local ores = {"coal","iron","gold","diamond"}
|
||||
local tool = {"main:woodpick","main:stonepick","main:ironpick","main:goldpick","main:diamondpick"}
|
||||
for id,ore in pairs(ores) do
|
||||
local tool_required = {}
|
||||
for i = id,5 do
|
||||
table.insert(tool_required, tool[i])
|
||||
end
|
||||
local tool_required = {}
|
||||
for i = id,5 do
|
||||
table.insert(tool_required, tool[i])
|
||||
end
|
||||
|
||||
local drops = {"main:"..ore.."ore"}
|
||||
if ore == "diamond" then drops = {"main:diamond"} elseif ore == "coal" then drops = {"main:coal"} end
|
||||
|
||||
|
||||
minetest.register_node("main:"..ore.."ore", {
|
||||
description = ore:gsub("^%l", string.upper).." Ore",
|
||||
tiles = {"stone.png^"..ore.."ore.png"},
|
||||
groups = {stone = id, hard = id, pickaxe = 1, hand = 4,pathable = 1},
|
||||
sounds = main.stoneSound(),
|
||||
--light_source = 14,--debugging ore spawn
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
rarity = 0,
|
||||
tools = tool_required,
|
||||
items = drops,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
local drops = {"main:"..ore.."ore"}
|
||||
if ore == "diamond" then drops = {"main:diamond"} elseif ore == "coal" then drops = {"main:coal"} end
|
||||
|
||||
|
||||
minetest.register_node("main:"..ore.."ore", {
|
||||
description = ore:gsub("^%l", string.upper).." Ore",
|
||||
tiles = {"stone.png^"..ore.."ore.png"},
|
||||
groups = {stone = id, hard = id, pickaxe = 1, hand = 4,pathable = 1},
|
||||
sounds = main.stoneSound(),
|
||||
--light_source = 14,--debugging ore spawn
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
rarity = 0,
|
||||
tools = tool_required,
|
||||
items = drops,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_node("main:stone", {
|
||||
@ -38,16 +38,16 @@ minetest.register_node("main:stone", {
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1},
|
||||
sounds = main.stoneSound(),
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
rarity = 0,
|
||||
tools = tool,
|
||||
items = {"main:cobble"},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
rarity = 0,
|
||||
tools = tool,
|
||||
items = {"main:cobble"},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("main:cobble", {
|
||||
description = "Cobblestone",
|
||||
@ -55,15 +55,15 @@ minetest.register_node("main:cobble", {
|
||||
groups = {stone = 2, hard = 1, pickaxe = 2, hand = 4,pathable = 1},
|
||||
sounds = main.stoneSound(),
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
rarity = 0,
|
||||
tools = tool,
|
||||
items = {"main:cobble"},
|
||||
},
|
||||
},
|
||||
},
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
rarity = 0,
|
||||
tools = tool,
|
||||
items = {"main:cobble"},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("main:dirt", {
|
||||
@ -96,30 +96,30 @@ minetest.register_node("main:tree", {
|
||||
sounds = main.woodSound(),
|
||||
--set metadata so treecapitator doesn't destroy houses
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.above
|
||||
minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("placed", "true")
|
||||
return(itemstack)
|
||||
end,
|
||||
--treecapitator - move treecapitator into own file using override
|
||||
on_dig = function(pos, node, digger)
|
||||
|
||||
--check if wielding axe?
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not meta:contains("placed") then
|
||||
--remove tree
|
||||
for y = -6,6 do
|
||||
--print(y)
|
||||
if minetest.get_node(vector.new(pos.x,pos.y+y,pos.z)).name == "main:tree" then
|
||||
minetest.node_dig(vector.new(pos.x,pos.y+y,pos.z), node, digger)
|
||||
end
|
||||
end
|
||||
else
|
||||
minetest.node_dig(pos, node, digger)
|
||||
end
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("placed", "true")
|
||||
return(itemstack)
|
||||
end,
|
||||
--treecapitator - move treecapitator into own file using override
|
||||
on_dig = function(pos, node, digger)
|
||||
|
||||
--check if wielding axe?
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
if not meta:contains("placed") then
|
||||
--remove tree
|
||||
for y = -6,6 do
|
||||
--print(y)
|
||||
if minetest.get_node(vector.new(pos.x,pos.y+y,pos.z)).name == "main:tree" then
|
||||
minetest.node_dig(vector.new(pos.x,pos.y+y,pos.z), node, digger)
|
||||
end
|
||||
end
|
||||
else
|
||||
minetest.node_dig(pos, node, digger)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("main:wood", {
|
||||
@ -132,299 +132,299 @@ minetest.register_node("main:wood", {
|
||||
minetest.register_node("main:leaves", {
|
||||
description = "Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
tiles = {"leaves.png"},
|
||||
groups = {leaves = 1, plant = 1, axe = 1, hand = 0, leafdecay = 1},
|
||||
sounds = main.grassSound(),
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
rarity = 10,
|
||||
items = {"main:sapling"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
tools = {"main:shears"},
|
||||
rarity = 2,
|
||||
items = {"main:leaves"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
tools = {"main:shears"},
|
||||
rarity = 2,
|
||||
items = {"main:stick"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
tools = {"main:shears"},
|
||||
rarity = 6,
|
||||
items = {"main:apple"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
},
|
||||
max_items = 1,
|
||||
items= {
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
rarity = 10,
|
||||
items = {"main:sapling"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
tools = {"main:shears"},
|
||||
rarity = 2,
|
||||
items = {"main:leaves"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
tools = {"main:shears"},
|
||||
rarity = 2,
|
||||
items = {"main:stick"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
{
|
||||
-- Only drop if using a tool whose name is identical to one
|
||||
-- of these.
|
||||
tools = {"main:shears"},
|
||||
rarity = 6,
|
||||
items = {"main:apple"},
|
||||
-- Whether all items in the dropped item list inherit the
|
||||
-- hardware coloring palette color from the dug node.
|
||||
-- Default is 'false'.
|
||||
--inherit_color = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("main:water", {
|
||||
description = "Water Source",
|
||||
drawtype = "liquid",
|
||||
waving = 3,
|
||||
tiles = {
|
||||
{
|
||||
name = "waterSource.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "waterSource.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
alpha = 191,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "source",
|
||||
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,pathable = 1},
|
||||
--sounds = default.node_sound_water_defaults(),
|
||||
description = "Water Source",
|
||||
drawtype = "liquid",
|
||||
waving = 3,
|
||||
tiles = {
|
||||
{
|
||||
name = "waterSource.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "waterSource.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 2.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
alpha = 191,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "source",
|
||||
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,pathable = 1},
|
||||
--sounds = default.node_sound_water_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("main:waterflow", {
|
||||
description = "Water Flow",
|
||||
drawtype = "flowingliquid",
|
||||
waving = 3,
|
||||
tiles = {"water.png"},
|
||||
special_tiles = {
|
||||
{
|
||||
name = "waterFlow.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 0.8,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "waterFlow.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 0.8,
|
||||
},
|
||||
},
|
||||
},
|
||||
alpha = 191,
|
||||
paramtype = "light",
|
||||
paramtype2 = "flowingliquid",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "flowing",
|
||||
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,pathable = 1},
|
||||
--sounds = default.node_sound_water_defaults(),
|
||||
description = "Water Flow",
|
||||
drawtype = "flowingliquid",
|
||||
waving = 3,
|
||||
tiles = {"water.png"},
|
||||
special_tiles = {
|
||||
{
|
||||
name = "waterFlow.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 0.8,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "waterFlow.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 0.8,
|
||||
},
|
||||
},
|
||||
},
|
||||
alpha = 191,
|
||||
paramtype = "light",
|
||||
paramtype2 = "flowingliquid",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "flowing",
|
||||
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,pathable = 1},
|
||||
--sounds = default.node_sound_water_defaults(),
|
||||
})
|
||||
|
||||
--[[
|
||||
|
||||
minetest.register_node("default:lava_source", {
|
||||
description = S("Lava Source"),
|
||||
drawtype = "liquid",
|
||||
tiles = {
|
||||
{
|
||||
name = "default_lava_source_animated.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "default_lava_source_animated.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
paramtype = "light",
|
||||
light_source = default.LIGHT_MAX - 1,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "source",
|
||||
liquid_alternative_flowing = "default:lava_flowing",
|
||||
liquid_alternative_source = "default:lava_source",
|
||||
liquid_viscosity = 7,
|
||||
liquid_renewable = false,
|
||||
damage_per_second = 4 * 2,
|
||||
post_effect_color = {a = 191, r = 255, g = 64, b = 0},
|
||||
groups = {lava = 3, liquid = 2, igniter = 1},
|
||||
description = S("Lava Source"),
|
||||
drawtype = "liquid",
|
||||
tiles = {
|
||||
{
|
||||
name = "default_lava_source_animated.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "default_lava_source_animated.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.0,
|
||||
},
|
||||
},
|
||||
},
|
||||
paramtype = "light",
|
||||
light_source = default.LIGHT_MAX - 1,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "source",
|
||||
liquid_alternative_flowing = "default:lava_flowing",
|
||||
liquid_alternative_source = "default:lava_source",
|
||||
liquid_viscosity = 7,
|
||||
liquid_renewable = false,
|
||||
damage_per_second = 4 * 2,
|
||||
post_effect_color = {a = 191, r = 255, g = 64, b = 0},
|
||||
groups = {lava = 3, liquid = 2, igniter = 1},
|
||||
})
|
||||
|
||||
minetest.register_node("default:lava_flowing", {
|
||||
description = S("Flowing Lava"),
|
||||
drawtype = "flowingliquid",
|
||||
tiles = {"default_lava.png"},
|
||||
special_tiles = {
|
||||
{
|
||||
name = "default_lava_flowing_animated.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "default_lava_flowing_animated.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3,
|
||||
},
|
||||
},
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "flowingliquid",
|
||||
light_source = default.LIGHT_MAX - 1,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "flowing",
|
||||
liquid_alternative_flowing = "default:lava_flowing",
|
||||
liquid_alternative_source = "default:lava_source",
|
||||
liquid_viscosity = 7,
|
||||
liquid_renewable = false,
|
||||
damage_per_second = 4 * 2,
|
||||
post_effect_color = {a = 191, r = 255, g = 64, b = 0},
|
||||
groups = {lava = 3, liquid = 2, igniter = 1,
|
||||
not_in_creative_inventory = 1},
|
||||
description = S("Flowing Lava"),
|
||||
drawtype = "flowingliquid",
|
||||
tiles = {"default_lava.png"},
|
||||
special_tiles = {
|
||||
{
|
||||
name = "default_lava_flowing_animated.png",
|
||||
backface_culling = false,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "default_lava_flowing_animated.png",
|
||||
backface_culling = true,
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 3.3,
|
||||
},
|
||||
},
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "flowingliquid",
|
||||
light_source = default.LIGHT_MAX - 1,
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
is_ground_content = false,
|
||||
drop = "",
|
||||
drowning = 1,
|
||||
liquidtype = "flowing",
|
||||
liquid_alternative_flowing = "default:lava_flowing",
|
||||
liquid_alternative_source = "default:lava_source",
|
||||
liquid_viscosity = 7,
|
||||
liquid_renewable = false,
|
||||
damage_per_second = 4 * 2,
|
||||
post_effect_color = {a = 191, r = 255, g = 64, b = 0},
|
||||
groups = {lava = 3, liquid = 2, igniter = 1,
|
||||
not_in_creative_inventory = 1},
|
||||
})
|
||||
|
||||
]]--
|
||||
|
||||
minetest.register_node("main:ladder", {
|
||||
description = "Ladder",
|
||||
drawtype = "signlike",
|
||||
tiles = {"ladder.png"},
|
||||
inventory_image = "ladder.png",
|
||||
wield_image = "ladder.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
is_ground_content = false,
|
||||
node_placement_prediction = "",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
--wall_top = = <default>
|
||||
--wall_bottom = = <default>
|
||||
--wall_side = = <default>
|
||||
},
|
||||
groups = {wood = 2, flammable = 2, attached_node=1},
|
||||
sounds = main.woodSound(),
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
--copy from torch
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
description = "Ladder",
|
||||
drawtype = "signlike",
|
||||
tiles = {"ladder.png"},
|
||||
inventory_image = "ladder.png",
|
||||
wield_image = "ladder.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
climbable = true,
|
||||
is_ground_content = false,
|
||||
node_placement_prediction = "",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
--wall_top = = <default>
|
||||
--wall_bottom = = <default>
|
||||
--wall_side = = <default>
|
||||
},
|
||||
groups = {wood = 2, flammable = 2, attached_node=1},
|
||||
sounds = main.woodSound(),
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
--copy from torch
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
if wdir > 1 then
|
||||
retval = fakestack:set_name("main:ladder")
|
||||
else
|
||||
return itemstack
|
||||
end
|
||||
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
|
||||
if retval then
|
||||
minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
|
||||
print(itemstack, retval)
|
||||
itemstack:set_name("main:ladder")
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
if wdir > 1 then
|
||||
retval = fakestack:set_name("main:ladder")
|
||||
else
|
||||
return itemstack
|
||||
end
|
||||
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
|
||||
if retval then
|
||||
minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
|
||||
print(itemstack, retval)
|
||||
itemstack:set_name("main:ladder")
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
@ -2,47 +2,47 @@
|
||||
depth = initial level found
|
||||
]]--
|
||||
|
||||
|
||||
|
||||
-- Dirt
|
||||
--[[
|
||||
minetest.register_ore({
|
||||
ore_type = "blob",
|
||||
ore = "main:dirt",
|
||||
wherein = {"main:stone"},
|
||||
clust_scarcity = 16 * 16 * 16,
|
||||
clust_size = 5,
|
||||
y_max = 31000,
|
||||
y_min = -31,
|
||||
noise_threshold = 0.0,
|
||||
noise_params = {
|
||||
offset = 0.5,
|
||||
scale = 0.2,
|
||||
spread = {x = 5, y = 5, z = 5},
|
||||
seed = 17676,
|
||||
octaves = 1,
|
||||
persist = 0.0
|
||||
},
|
||||
ore_type = "blob",
|
||||
ore = "main:dirt",
|
||||
wherein = {"main:stone"},
|
||||
clust_scarcity = 16 * 16 * 16,
|
||||
clust_size = 5,
|
||||
y_max = 31000,
|
||||
y_min = -31,
|
||||
noise_threshold = 0.0,
|
||||
noise_params = {
|
||||
offset = 0.5,
|
||||
scale = 0.2,
|
||||
spread = {x = 5, y = 5, z = 5},
|
||||
seed = 17676,
|
||||
octaves = 1,
|
||||
persist = 0.0
|
||||
},
|
||||
})
|
||||
|
||||
-- Gravel
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "blob",
|
||||
ore = "main:gravel",
|
||||
wherein = {"main:stone"},
|
||||
clust_scarcity = 16 * 16 * 16,
|
||||
clust_size = 5,
|
||||
y_max = 31000,
|
||||
y_min = -31000,
|
||||
noise_threshold = 0.0,
|
||||
noise_params = {
|
||||
offset = 0.5,
|
||||
scale = 0.2,
|
||||
spread = {x = 5, y = 5, z = 5},
|
||||
seed = 766,
|
||||
octaves = 1,
|
||||
persist = 0.0
|
||||
},
|
||||
ore_type = "blob",
|
||||
ore = "main:gravel",
|
||||
wherein = {"main:stone"},
|
||||
clust_scarcity = 16 * 16 * 16,
|
||||
clust_size = 5,
|
||||
y_max = 31000,
|
||||
y_min = -31000,
|
||||
noise_threshold = 0.0,
|
||||
noise_params = {
|
||||
offset = 0.5,
|
||||
scale = 0.2,
|
||||
spread = {x = 5, y = 5, z = 5},
|
||||
seed = 766,
|
||||
octaves = 1,
|
||||
persist = 0.0
|
||||
},
|
||||
})
|
||||
]]--
|
||||
-- Scatter ores
|
||||
@ -50,186 +50,186 @@ minetest.register_ore({
|
||||
-- Coal
|
||||
for i = 1,3 do
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:coalore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 8 * 8 * 8,
|
||||
clust_num_ores = 9,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
ore_type = "scatter",
|
||||
ore = "main:coalore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 8 * 8 * 8,
|
||||
clust_num_ores = 9,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:coalore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 8 * 8 * 8,
|
||||
clust_num_ores = 8,
|
||||
clust_size = 3,
|
||||
y_max = 64,
|
||||
y_min = -127,
|
||||
ore_type = "scatter",
|
||||
ore = "main:coalore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 8 * 8 * 8,
|
||||
clust_num_ores = 8,
|
||||
clust_size = 3,
|
||||
y_max = 64,
|
||||
y_min = -127,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:coalore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 12 * 12 * 12,
|
||||
clust_num_ores = 30,
|
||||
clust_size = 5,
|
||||
y_max = -128,
|
||||
y_min = -31000,
|
||||
ore_type = "scatter",
|
||||
ore = "main:coalore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 12 * 12 * 12,
|
||||
clust_num_ores = 30,
|
||||
clust_size = 5,
|
||||
y_max = -128,
|
||||
y_min = -31000,
|
||||
})
|
||||
|
||||
-- Iron
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:ironore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 9 * 9 * 9,
|
||||
clust_num_ores = 12,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
ore_type = "scatter",
|
||||
ore = "main:ironore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 9 * 9 * 9,
|
||||
clust_num_ores = 12,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:ironore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 7 * 7 * 7,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = 64,
|
||||
y_min = -127,
|
||||
ore_type = "scatter",
|
||||
ore = "main:ironore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 7 * 7 * 7,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = 64,
|
||||
y_min = -127,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:ironore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 7 * 7 * 7,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = -128,
|
||||
y_min = -255,
|
||||
ore_type = "scatter",
|
||||
ore = "main:ironore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 7 * 7 * 7,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = -128,
|
||||
y_min = -255,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:ironore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 12 * 12 * 12,
|
||||
clust_num_ores = 29,
|
||||
clust_size = 5,
|
||||
y_max = -256,
|
||||
y_min = -31000,
|
||||
ore_type = "scatter",
|
||||
ore = "main:ironore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 12 * 12 * 12,
|
||||
clust_num_ores = 29,
|
||||
clust_size = 5,
|
||||
y_max = -256,
|
||||
y_min = -31000,
|
||||
})
|
||||
|
||||
-- Gold
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:goldore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 13 * 13 * 13,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
ore_type = "scatter",
|
||||
ore = "main:goldore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 13 * 13 * 13,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:goldore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
y_max = -256,
|
||||
y_min = -511,
|
||||
ore_type = "scatter",
|
||||
ore = "main:goldore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
y_max = -256,
|
||||
y_min = -511,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:goldore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 13 * 13 * 13,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = -512,
|
||||
y_min = -31000,
|
||||
ore_type = "scatter",
|
||||
ore = "main:goldore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 13 * 13 * 13,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = -512,
|
||||
y_min = -31000,
|
||||
})
|
||||
|
||||
-- Mese crystal
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 14 * 14 * 14,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 14 * 14 * 14,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 18 * 18 * 18,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
y_max = -512,
|
||||
y_min = -1023,
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 18 * 18 * 18,
|
||||
clust_num_ores = 3,
|
||||
clust_size = 2,
|
||||
y_max = -512,
|
||||
y_min = -1023,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 14 * 14 * 14,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = -1024,
|
||||
y_min = -31000,
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 14 * 14 * 14,
|
||||
clust_num_ores = 5,
|
||||
clust_size = 3,
|
||||
y_max = -1024,
|
||||
y_min = -31000,
|
||||
})
|
||||
|
||||
-- Diamond
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_max = 31000,
|
||||
y_min = 1025,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 17 * 17 * 17,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_max = -1024,
|
||||
y_min = -2047,
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 17 * 17 * 17,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_max = -1024,
|
||||
y_min = -2047,
|
||||
})
|
||||
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_max = -2048,
|
||||
y_min = -31000,
|
||||
ore_type = "scatter",
|
||||
ore = "main:diamondore",
|
||||
wherein = "main:stone",
|
||||
clust_scarcity = 15 * 15 * 15,
|
||||
clust_num_ores = 4,
|
||||
clust_size = 3,
|
||||
y_max = -2048,
|
||||
y_min = -31000,
|
||||
})
|
||||
end
|
||||
|
@ -1,71 +1,71 @@
|
||||
--saplings
|
||||
minetest.register_node("main:sapling", {
|
||||
description = "Sapling",
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
tiles = {"sapling.png"},
|
||||
groups = {leaves = 1, plant = 1, axe = 1, hand = 0,instant=1, sapling=1, attached_node=1},
|
||||
sounds = main.grassSound(),
|
||||
drop = "main:sapling",
|
||||
node_placement_prediction = "",
|
||||
selection_box = {
|
||||
description = "Sapling",
|
||||
drawtype = "plantlike",
|
||||
waving = 1,
|
||||
walkable = false,
|
||||
climbable = false,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
tiles = {"sapling.png"},
|
||||
groups = {leaves = 1, plant = 1, axe = 1, hand = 0,instant=1, sapling=1, attached_node=1},
|
||||
sounds = main.grassSound(),
|
||||
drop = "main:sapling",
|
||||
node_placement_prediction = "",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
if minetest.get_node_group(minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name, "soil") > 0 and minetest.get_node(pointed_thing.above).name == "air" then
|
||||
minetest.set_node(pointed_thing.above, {name="main:sapling"})
|
||||
minetest.sound_play("leaves",{pos=pointed_thing.above})
|
||||
itemstack:take_item(1)
|
||||
--print(minetest.get_node(pointed_thing.above).param1)
|
||||
return(itemstack)
|
||||
end
|
||||
end,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
if minetest.get_node_group(minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name, "soil") > 0 and minetest.get_node(pointed_thing.above).name == "air" then
|
||||
minetest.set_node(pointed_thing.above, {name="main:sapling"})
|
||||
minetest.sound_play("leaves",{pos=pointed_thing.above})
|
||||
itemstack:take_item(1)
|
||||
--print(minetest.get_node(pointed_thing.above).param1)
|
||||
return(itemstack)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--make sapling grow
|
||||
local function sapling_grow(pos)
|
||||
if minetest.get_node_light(pos, nil) < 10 then
|
||||
--print("failed to grow at "..dump(pos))
|
||||
return
|
||||
end
|
||||
--print("growing at "..dump(pos))
|
||||
if minetest.get_node_group(minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name, "soil") > 0 then
|
||||
local good_to_grow = true
|
||||
--check if room to grow (leaves or air)
|
||||
for i = 1,4 do
|
||||
local node_name = minetest.get_node(vector.new(pos.x,pos.y+i,pos.z)).name
|
||||
if node_name ~= "air" and node_name ~= "main:leaves" then
|
||||
good_to_grow = false
|
||||
end
|
||||
end
|
||||
if good_to_grow == true then
|
||||
minetest.set_node(pos,{name="main:tree"})
|
||||
minetest.place_schematic(pos, treeSchematic,"0",nil,false,"place_center_x, place_center_z")
|
||||
--override leaves
|
||||
for i = 1,4 do
|
||||
minetest.set_node(vector.new(pos.x,pos.y+i,pos.z),{name="main:tree"})
|
||||
end
|
||||
end
|
||||
end
|
||||
if minetest.get_node_light(pos, nil) < 10 then
|
||||
--print("failed to grow at "..dump(pos))
|
||||
return
|
||||
end
|
||||
--print("growing at "..dump(pos))
|
||||
if minetest.get_node_group(minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name, "soil") > 0 then
|
||||
local good_to_grow = true
|
||||
--check if room to grow (leaves or air)
|
||||
for i = 1,4 do
|
||||
local node_name = minetest.get_node(vector.new(pos.x,pos.y+i,pos.z)).name
|
||||
if node_name ~= "air" and node_name ~= "main:leaves" then
|
||||
good_to_grow = false
|
||||
end
|
||||
end
|
||||
if good_to_grow == true then
|
||||
minetest.set_node(pos,{name="main:tree"})
|
||||
minetest.place_schematic(pos, treeSchematic,"0",nil,false,"place_center_x, place_center_z")
|
||||
--override leaves
|
||||
for i = 1,4 do
|
||||
minetest.set_node(vector.new(pos.x,pos.y+i,pos.z),{name="main:tree"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--growing abm for sapling
|
||||
minetest.register_abm({
|
||||
label = "Tree Grow",
|
||||
nodenames = {"group:sapling"},
|
||||
neighbors = {"group:soil"},
|
||||
interval = 3,
|
||||
chance = 2000,
|
||||
action = function(pos)
|
||||
sapling_grow(pos)
|
||||
end,
|
||||
label = "Tree Grow",
|
||||
nodenames = {"group:sapling"},
|
||||
neighbors = {"group:soil"},
|
||||
interval = 3,
|
||||
chance = 2000,
|
||||
action = function(pos)
|
||||
sapling_grow(pos)
|
||||
end,
|
||||
})
|
||||
|
@ -6,28 +6,28 @@ front -> back
|
||||
]]--
|
||||
|
||||
treeSchematic = {
|
||||
size = {x = 3, y = 6, z = 3},
|
||||
data = {
|
||||
-- The side of the bush, with the air on top
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "main:leaves"}, {name = "main:leaves"}, {name = "main:leaves"}, -- lower layer
|
||||
{name = "main:leaves"}, {name = "main:leaves"}, {name = "main:leaves"}, -- middle layer
|
||||
{name = "air"}, {name = "air"}, {name = "air"}, -- top layer
|
||||
-- The center of the bush, with stem at the base and a pointy leave 2 nodes above
|
||||
{name = "air"}, {name = "main:tree"}, {name = "air"},
|
||||
{name = "air"}, {name = "main:tree"}, {name = "air"},
|
||||
{name = "air"}, {name = "main:tree"}, {name = "air"},
|
||||
{name = "main:leaves"}, {name = "main:tree"}, {name = "main:leaves"}, -- lower layer
|
||||
{name = "main:leaves"}, {name = "main:tree"}, {name = "main:leaves"}, -- middle layer
|
||||
{name = "air"}, {name = "main:leaves"}, {name = "air"}, -- top layer
|
||||
-- The other side of the bush, same as first side
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "main:leaves"}, {name = "main:leaves"}, {name = "main:leaves"}, -- lower layer
|
||||
{name = "main:leaves"}, {name = "main:leaves"}, {name = "main:leaves"}, -- middle layer
|
||||
{name = "air"}, {name = "air"}, {name = "air"}, -- top layer
|
||||
}
|
||||
}
|
||||
size = {x = 3, y = 6, z = 3},
|
||||
data = {
|
||||
-- The side of the bush, with the air on top
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "main:leaves"}, {name = "main:leaves"}, {name = "main:leaves"}, -- lower layer
|
||||
{name = "main:leaves"}, {name = "main:leaves"}, {name = "main:leaves"}, -- middle layer
|
||||
{name = "air"}, {name = "air"}, {name = "air"}, -- top layer
|
||||
-- The center of the bush, with stem at the base and a pointy leave 2 nodes above
|
||||
{name = "air"}, {name = "main:tree"}, {name = "air"},
|
||||
{name = "air"}, {name = "main:tree"}, {name = "air"},
|
||||
{name = "air"}, {name = "main:tree"}, {name = "air"},
|
||||
{name = "main:leaves"}, {name = "main:tree"}, {name = "main:leaves"}, -- lower layer
|
||||
{name = "main:leaves"}, {name = "main:tree"}, {name = "main:leaves"}, -- middle layer
|
||||
{name = "air"}, {name = "main:leaves"}, {name = "air"}, -- top layer
|
||||
-- The other side of the bush, same as first side
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "air"}, {name = "air"}, {name = "air"},
|
||||
{name = "main:leaves"}, {name = "main:leaves"}, {name = "main:leaves"}, -- lower layer
|
||||
{name = "main:leaves"}, {name = "main:leaves"}, {name = "main:leaves"}, -- middle layer
|
||||
{name = "air"}, {name = "air"}, {name = "air"}, -- top layer
|
||||
}
|
||||
}
|
||||
|
@ -12,20 +12,20 @@ print("Changing liquid update to ")
|
||||
|
||||
--make stack max 1000 for everything
|
||||
minetest.register_on_mods_loaded(function()
|
||||
for name,_ in pairs(minetest.registered_nodes) do
|
||||
minetest.override_item(name, {
|
||||
stack_max = 1000,
|
||||
})
|
||||
end
|
||||
for name,_ in pairs(minetest.registered_craftitems) do
|
||||
minetest.override_item(name, {
|
||||
stack_max = 1000,
|
||||
})
|
||||
end
|
||||
for name,_ in pairs(minetest.registered_nodes) do
|
||||
minetest.override_item(name, {
|
||||
stack_max = 1000,
|
||||
})
|
||||
end
|
||||
for name,_ in pairs(minetest.registered_craftitems) do
|
||||
minetest.override_item(name, {
|
||||
stack_max = 1000,
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
print("Max stack set to 1000")
|
||||
|
||||
--minetest.register_globalstep(function(dtime)
|
||||
-- print(settings:get("dedicated_server_step"))
|
||||
-- print(settings:get("dedicated_server_step"))
|
||||
--end)
|
||||
|
@ -1,71 +1,71 @@
|
||||
function main.stoneSound(table)
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "stone",gain=0.2}
|
||||
table.footstep = table.footstep or
|
||||
{name = "stone", gain = 0.1}
|
||||
table.dug = table.dug or
|
||||
{name = "stone", gain = 1.0}
|
||||
table.placing = table.placing or
|
||||
{name = "stone", gain = 1.0}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "stone",gain=0.2}
|
||||
table.footstep = table.footstep or
|
||||
{name = "stone", gain = 0.1}
|
||||
table.dug = table.dug or
|
||||
{name = "stone", gain = 1.0}
|
||||
table.placing = table.placing or
|
||||
{name = "stone", gain = 1.0}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function main.woodSound(table)
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "wood",gain=0.3}
|
||||
table.footstep = table.footstep or
|
||||
{name = "wood", gain = 0.2}
|
||||
table.dug = table.dug or
|
||||
{name = "wood", gain = 1.0}
|
||||
table.placing = table.placing or
|
||||
{name = "wood", gain = 1.0}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "wood",gain=0.3}
|
||||
table.footstep = table.footstep or
|
||||
{name = "wood", gain = 0.2}
|
||||
table.dug = table.dug or
|
||||
{name = "wood", gain = 1.0}
|
||||
table.placing = table.placing or
|
||||
{name = "wood", gain = 1.0}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
|
||||
function main.sandSound(table)
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "sand",gain=0.09}
|
||||
table.footstep = table.footstep or
|
||||
{name = "sand", gain = 0.07}
|
||||
table.dug = table.dug or
|
||||
{name = "sand", gain = 0.09}
|
||||
table.placing = table.placing or
|
||||
{name = "sand", gain = 0.09}
|
||||
table.fall = table.fall or
|
||||
{name = "sand", gain = 0.01}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "sand",gain=0.09}
|
||||
table.footstep = table.footstep or
|
||||
{name = "sand", gain = 0.07}
|
||||
table.dug = table.dug or
|
||||
{name = "sand", gain = 0.09}
|
||||
table.placing = table.placing or
|
||||
{name = "sand", gain = 0.09}
|
||||
table.fall = table.fall or
|
||||
{name = "sand", gain = 0.01}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
||||
function main.grassSound(table)
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "leaves",gain=0.3}
|
||||
table.footstep = table.footstep or
|
||||
{name = "leaves", gain = 0.2}
|
||||
table.dug = table.dug or
|
||||
{name = "leaves", gain = 1.0}
|
||||
table.placing = table.placing or
|
||||
{name = "leaves", gain = 0.5}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "leaves",gain=0.3}
|
||||
table.footstep = table.footstep or
|
||||
{name = "leaves", gain = 0.2}
|
||||
table.dug = table.dug or
|
||||
{name = "leaves", gain = 1.0}
|
||||
table.placing = table.placing or
|
||||
{name = "leaves", gain = 0.5}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
function main.dirtSound(table)
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "dirt",gain=0.5}
|
||||
table.footstep = table.footstep or
|
||||
{name = "dirt", gain = 0.3}
|
||||
table.dug = table.dug or
|
||||
{name = "dirt", gain = 1.0}
|
||||
table.placing = table.placing or
|
||||
{name = "dirt", gain = 0.5}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
table = table or {}
|
||||
table.dig = table.dig or
|
||||
{name = "dirt",gain=0.5}
|
||||
table.footstep = table.footstep or
|
||||
{name = "dirt", gain = 0.3}
|
||||
table.dug = table.dug or
|
||||
{name = "dirt", gain = 1.0}
|
||||
table.placing = table.placing or
|
||||
{name = "dirt", gain = 0.5}
|
||||
--default.node_sound_defaults(table)
|
||||
return table
|
||||
end
|
||||
|
@ -4,59 +4,62 @@ local group = {[1]="dirt",[2]="wood",[3]="stone"}
|
||||
local material = {"wood","stone","iron","gold","diamond"}
|
||||
|
||||
for level,material in pairs(material) do
|
||||
for id,tool in pairs(tool) do
|
||||
for id,tool in pairs(tool) do
|
||||
|
||||
--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/2)*5, maxlevel=level},
|
||||
sand = {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/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/2)*5, maxlevel=level},}
|
||||
end
|
||||
minetest.register_tool("main:"..material..tool, {
|
||||
description = material:gsub("^%l", string.upper).." "..tool:gsub("^%l", string.upper),
|
||||
inventory_image = material..tool..".png",
|
||||
tool_capabilities = {
|
||||
--full_punch_interval = 1.2,
|
||||
--max_drop_level=0,
|
||||
groupcaps=groupcaps2,
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
|
||||
groups = {flammable = 2, tool=1 }
|
||||
})
|
||||
end
|
||||
--add swords
|
||||
minetest.register_tool("main:"..material.."sword", {
|
||||
description = material:gsub("^%l", string.upper).." Sword",
|
||||
inventory_image = material.."sword.png",
|
||||
tool_capabilities = {
|
||||
--full_punch_interval = 1.2,
|
||||
--max_drop_level=0,
|
||||
groupcaps={leaves = {times={[4]=0.7,[3]=0.7,[2]=0.7,[1]=0.7}, uses=level*20, maxlevel=4},},
|
||||
damage_groups = {fleshy=level},
|
||||
},
|
||||
sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
|
||||
groups = {weapon=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/2)*5, maxlevel=level},
|
||||
sand = {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/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/2)*5, maxlevel=level},}
|
||||
end
|
||||
minetest.register_tool("main:"..material..tool, {
|
||||
description = material:gsub("^%l", string.upper).." "..tool:gsub("^%l", string.upper),
|
||||
inventory_image = material..tool..".png",
|
||||
tool_capabilities = {
|
||||
--full_punch_interval = 1.2,
|
||||
--max_drop_level=0,
|
||||
groupcaps=groupcaps2,
|
||||
damage_groups = {fleshy=1},
|
||||
},
|
||||
sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
|
||||
groups = {flammable = 2, tool=1 },
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
|
||||
end,
|
||||
})
|
||||
end
|
||||
--add swords
|
||||
minetest.register_tool("main:"..material.."sword", {
|
||||
description = material:gsub("^%l", string.upper).." Sword",
|
||||
inventory_image = material.."sword.png",
|
||||
tool_capabilities = {
|
||||
--full_punch_interval = 1.2,
|
||||
--max_drop_level=0,
|
||||
groupcaps={leaves = {times={[4]=0.7,[3]=0.7,[2]=0.7,[1]=0.7}, uses=level*20, maxlevel=4},},
|
||||
damage_groups = {fleshy=level},
|
||||
},
|
||||
sound = {breaks = {name="tool_break",gain=0.4}}, -- change this
|
||||
groups = {weapon=1 }
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_tool("main:shears", {
|
||||
description = "Shears",
|
||||
inventory_image = "shears.png",
|
||||
tool_capabilities = {
|
||||
--full_punch_interval = 1.2,
|
||||
--max_drop_level=0,
|
||||
groupcaps={leaves = {times={[4]=0.2,[3]=0.2,[2]=0.2,[1]=0.2}, uses=300, maxlevel=4},},
|
||||
--damage_groups = {fleshy=2},
|
||||
},
|
||||
sound = {breaks = "default_tool_breaks"}, -- change this
|
||||
groups = {shears = 1}
|
||||
})
|
||||
description = "Shears",
|
||||
inventory_image = "shears.png",
|
||||
tool_capabilities = {
|
||||
--full_punch_interval = 1.2,
|
||||
--max_drop_level=0,
|
||||
groupcaps={leaves = {times={[4]=0.2,[3]=0.2,[2]=0.2,[1]=0.2}, uses=300, maxlevel=4},},
|
||||
--damage_groups = {fleshy=2},
|
||||
},
|
||||
sound = {breaks = "default_tool_breaks"}, -- change this
|
||||
groups = {shears = 1}
|
||||
})
|
||||
|
@ -4,460 +4,460 @@ dofile(path.."/rail.lua")
|
||||
|
||||
--get if rail
|
||||
local function rail(pos)
|
||||
return(minetest.get_node_group(minetest.get_node(pos).name,"rail")>0)
|
||||
return(minetest.get_node_group(minetest.get_node(pos).name,"rail")>0)
|
||||
end
|
||||
|
||||
--check if on rail
|
||||
local function on_rail(self,pos)
|
||||
if not rail(pos) and not self.slope then
|
||||
self.axis = nil
|
||||
return(false)
|
||||
else
|
||||
return(true)
|
||||
end
|
||||
if not rail(pos) and not self.slope then
|
||||
self.axis = nil
|
||||
return(false)
|
||||
else
|
||||
return(true)
|
||||
end
|
||||
end
|
||||
|
||||
--set physical state
|
||||
local function physical(self,pos)
|
||||
if on_rail(self,pos) then
|
||||
self.object:set_properties({physical = false})
|
||||
self.object:setacceleration(vector.new(0,0,0))
|
||||
elseif not self.slope then
|
||||
self.object:set_properties({physical = true})
|
||||
self.object:setacceleration(vector.new(0,-9.81,0))
|
||||
end
|
||||
if on_rail(self,pos) then
|
||||
self.object:set_properties({physical = false})
|
||||
self.object:setacceleration(vector.new(0,0,0))
|
||||
elseif not self.slope then
|
||||
self.object:set_properties({physical = true})
|
||||
self.object:setacceleration(vector.new(0,-9.81,0))
|
||||
end
|
||||
end
|
||||
|
||||
--get if node in minecarts direction
|
||||
local function node_ahead(self,pos)
|
||||
local vel = self.object:getvelocity()
|
||||
local dir = vector.normalize(vel)
|
||||
return(rail(vector.add(pos,dir)))
|
||||
local vel = self.object:getvelocity()
|
||||
local dir = vector.normalize(vel)
|
||||
return(rail(vector.add(pos,dir)))
|
||||
end
|
||||
|
||||
--get current axis (prefers x)
|
||||
local function axis(pos)
|
||||
if rail(pos) then
|
||||
if rail(vector.new(pos.x-1,pos.y,pos.z)) or rail(vector.new(pos.x+1,pos.y,pos.z)) then return("x") end
|
||||
if rail(vector.new(pos.x,pos.y,pos.z-1)) or rail(vector.new(pos.x,pos.y,pos.z+1)) then return("z") end
|
||||
end
|
||||
if rail(pos) then
|
||||
if rail(vector.new(pos.x-1,pos.y,pos.z)) or rail(vector.new(pos.x+1,pos.y,pos.z)) then return("x") end
|
||||
if rail(vector.new(pos.x,pos.y,pos.z-1)) or rail(vector.new(pos.x,pos.y,pos.z+1)) then return("z") end
|
||||
end
|
||||
end
|
||||
|
||||
--snap object to rail
|
||||
local function snap_rail(self,pos)
|
||||
local slopy = self.slope
|
||||
if not slopy then print("the slope is nil") else
|
||||
print("the slope is ".. slopy)
|
||||
end
|
||||
local railpos = vector.floor(vector.add(pos, 0.5))
|
||||
local vel = self.object:getvelocity()
|
||||
if self.axis == "x" and pos.x ~= railpos.x then
|
||||
self.object:moveto(vector.new(pos.x,railpos.y,railpos.z))
|
||||
self.object:setvelocity(vector.new(vel.x,0,0))
|
||||
print("snapped to x")
|
||||
return
|
||||
end
|
||||
if self.axis == "z" and pos.z ~= railpos.z then
|
||||
self.object:moveto(vector.new(railpos.x,railpos.y,pos.z))
|
||||
self.object:setvelocity(vector.new(0,0,vel.z))
|
||||
print("snapped to z")
|
||||
return
|
||||
end
|
||||
local slopy = self.slope
|
||||
if not slopy then print("the slope is nil") else
|
||||
print("the slope is ".. slopy)
|
||||
end
|
||||
local railpos = vector.floor(vector.add(pos, 0.5))
|
||||
local vel = self.object:getvelocity()
|
||||
if self.axis == "x" and pos.x ~= railpos.x then
|
||||
self.object:moveto(vector.new(pos.x,railpos.y,railpos.z))
|
||||
self.object:setvelocity(vector.new(vel.x,0,0))
|
||||
print("snapped to x")
|
||||
return
|
||||
end
|
||||
if self.axis == "z" and pos.z ~= railpos.z then
|
||||
self.object:moveto(vector.new(railpos.x,railpos.y,pos.z))
|
||||
self.object:setvelocity(vector.new(0,0,vel.z))
|
||||
print("snapped to z")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--check if entering new position
|
||||
local function newnode(self,pos)
|
||||
local pos = vector.floor(vector.add(pos,0.5))
|
||||
|
||||
pos.y = 0
|
||||
|
||||
local equals = false
|
||||
|
||||
|
||||
if self.oldpos then
|
||||
equals = vector.equals(pos,self.oldpos)
|
||||
end
|
||||
|
||||
self.oldpos = pos
|
||||
return(not equals)
|
||||
local pos = vector.floor(vector.add(pos,0.5))
|
||||
|
||||
pos.y = 0
|
||||
|
||||
local equals = false
|
||||
|
||||
|
||||
if self.oldpos then
|
||||
equals = vector.equals(pos,self.oldpos)
|
||||
end
|
||||
|
||||
self.oldpos = pos
|
||||
return(not equals)
|
||||
end
|
||||
|
||||
--check if past center - used for turning
|
||||
local function pastcenter(self,pos)
|
||||
|
||||
local center = vector.floor(vector.add(pos,0.5))
|
||||
center.y = 0
|
||||
local pos2d = vector.new(pos.x,0,pos.z)
|
||||
|
||||
local vel = self.object:getvelocity()
|
||||
local dir = vector.normalize(vel)
|
||||
dir.y = 0
|
||||
local checker = vector.round(vector.normalize(vector.subtract(pos2d,center)))
|
||||
checker.y = 0
|
||||
local past = vector.equals(checker, dir)
|
||||
return(past)
|
||||
|
||||
local center = vector.floor(vector.add(pos,0.5))
|
||||
center.y = 0
|
||||
local pos2d = vector.new(pos.x,0,pos.z)
|
||||
|
||||
local vel = self.object:getvelocity()
|
||||
local dir = vector.normalize(vel)
|
||||
dir.y = 0
|
||||
local checker = vector.round(vector.normalize(vector.subtract(pos2d,center)))
|
||||
checker.y = 0
|
||||
local past = vector.equals(checker, dir)
|
||||
return(past)
|
||||
end
|
||||
|
||||
--check if node ahead
|
||||
local function node_forward(self,pos)
|
||||
local vel = self.object:getvelocity()
|
||||
local dir = vector.normalize(vel)
|
||||
return(rail(vector.add(pos,dir)))
|
||||
local vel = self.object:getvelocity()
|
||||
local dir = vector.normalize(vel)
|
||||
return(rail(vector.add(pos,dir)))
|
||||
end
|
||||
|
||||
--check if node above or below
|
||||
local function check_hill(self,pos)
|
||||
local vel = self.object:getvelocity()
|
||||
local dirup = vector.normalize(vel)
|
||||
|
||||
dirup.y = dirup.y + 1
|
||||
|
||||
print(dump(dirup))
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = 5,
|
||||
time = 0,
|
||||
minpos = vector.add(pos,dirup),
|
||||
maxpos = vector.add(pos,dirup),
|
||||
minvel = vector.new(0,0,0),
|
||||
maxvel = vector.new(0,0,0),
|
||||
minacc = {x=0, y=0, z=0},
|
||||
maxacc = {x=0, y=0, z=0},
|
||||
minexptime = 5,
|
||||
maxexptime = 5,
|
||||
minsize = 1,
|
||||
maxsize = 1,
|
||||
attached = player,
|
||||
collisiondetection = true,
|
||||
vertical = false,
|
||||
texture = "treecapitator.png"
|
||||
})
|
||||
|
||||
local dirdown = vector.new(0,-0.5,0)
|
||||
|
||||
if rail(vector.add(pos,dirup)) then
|
||||
self.slope = "up"
|
||||
return("up")
|
||||
elseif rail(vector.add(pos,dirdown)) then
|
||||
self.slope = "down"
|
||||
return("down")
|
||||
else
|
||||
self.slope = nil
|
||||
return(nil)
|
||||
end
|
||||
local vel = self.object:getvelocity()
|
||||
local dirup = vector.normalize(vel)
|
||||
|
||||
dirup.y = dirup.y + 1
|
||||
|
||||
print(dump(dirup))
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = 5,
|
||||
time = 0,
|
||||
minpos = vector.add(pos,dirup),
|
||||
maxpos = vector.add(pos,dirup),
|
||||
minvel = vector.new(0,0,0),
|
||||
maxvel = vector.new(0,0,0),
|
||||
minacc = {x=0, y=0, z=0},
|
||||
maxacc = {x=0, y=0, z=0},
|
||||
minexptime = 5,
|
||||
maxexptime = 5,
|
||||
minsize = 1,
|
||||
maxsize = 1,
|
||||
attached = player,
|
||||
collisiondetection = true,
|
||||
vertical = false,
|
||||
texture = "treecapitator.png"
|
||||
})
|
||||
|
||||
local dirdown = vector.new(0,-0.5,0)
|
||||
|
||||
if rail(vector.add(pos,dirup)) then
|
||||
self.slope = "up"
|
||||
return("up")
|
||||
elseif rail(vector.add(pos,dirdown)) then
|
||||
self.slope = "down"
|
||||
return("down")
|
||||
else
|
||||
self.slope = nil
|
||||
return(nil)
|
||||
end
|
||||
end
|
||||
|
||||
local function gravity(self,pos)
|
||||
|
||||
if self.slope == up then
|
||||
local vel = vector.multiply(self.object:getvelocity(), 0.95)
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
if self.slope == up then
|
||||
local vel = vector.multiply(self.object:getvelocity(), 1.05)
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
|
||||
if self.slope == up then
|
||||
local vel = vector.multiply(self.object:getvelocity(), 0.95)
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
if self.slope == up then
|
||||
local vel = vector.multiply(self.object:getvelocity(), 1.05)
|
||||
self.object:set_velocity(vel)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--make the minecart go up and down hills
|
||||
local function navigate_hill(self)
|
||||
if self.slope then
|
||||
local vel = self.object:getvelocity()
|
||||
if self.slope == "up" then
|
||||
|
||||
local yvel = 0
|
||||
if self.axis == "x" then
|
||||
yvel = math.abs(vel.x)*1.1
|
||||
end
|
||||
if self.axis == "z" then
|
||||
yvel = math.abs(vel.z)*1.1
|
||||
end
|
||||
self.object:setvelocity(vector.new(vel.x,yvel,vel.z))
|
||||
elseif self.slope == "down" then
|
||||
|
||||
local yvel = 0
|
||||
if self.axis == "x" then
|
||||
yvel = math.abs(vel.x)*-1
|
||||
end
|
||||
if self.axis == "z" then
|
||||
yvel = math.abs(vel.z)*-1
|
||||
end
|
||||
|
||||
self.object:setvelocity(vector.new(vel.x,yvel,vel.z))
|
||||
end
|
||||
end
|
||||
if self.slope then
|
||||
local vel = self.object:getvelocity()
|
||||
if self.slope == "up" then
|
||||
|
||||
local yvel = 0
|
||||
if self.axis == "x" then
|
||||
yvel = math.abs(vel.x)*1.1
|
||||
end
|
||||
if self.axis == "z" then
|
||||
yvel = math.abs(vel.z)*1.1
|
||||
end
|
||||
self.object:setvelocity(vector.new(vel.x,yvel,vel.z))
|
||||
elseif self.slope == "down" then
|
||||
|
||||
local yvel = 0
|
||||
if self.axis == "x" then
|
||||
yvel = math.abs(vel.x)*-1
|
||||
end
|
||||
if self.axis == "z" then
|
||||
yvel = math.abs(vel.z)*-1
|
||||
end
|
||||
|
||||
self.object:setvelocity(vector.new(vel.x,yvel,vel.z))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--swap axis and speed 90 degrees
|
||||
local function turn_check(self,pos)
|
||||
local axis = self.axis
|
||||
local vel = self.object:getvelocity()
|
||||
vel.x = math.abs(vel.x)
|
||||
vel.y = math.abs(vel.y)
|
||||
vel.z = math.abs(vel.z)
|
||||
|
||||
if axis == "x" then
|
||||
if rail(vector.new(pos.x,pos.y,pos.z-1)) then
|
||||
print("-x")
|
||||
self.object:setvelocity(vector.new(0,0,vel.x*-1))
|
||||
self.axis = "z"
|
||||
snap_rail(self,pos)
|
||||
self.turn_timer = 0
|
||||
return
|
||||
elseif rail(vector.new(pos.x,pos.y,pos.z+1)) then
|
||||
print("+x")
|
||||
self.object:setvelocity(vector.new(0,0,vel.x))
|
||||
self.axis = "z"
|
||||
snap_rail(self,pos)
|
||||
self.turn_timer = 0
|
||||
return
|
||||
end
|
||||
end
|
||||
if axis == "z" then
|
||||
if rail(vector.new(pos.x-1,pos.y,pos.z)) then
|
||||
print("-z")
|
||||
self.object:setvelocity(vector.new(vel.z*-1,0,0))
|
||||
self.axis = "x"
|
||||
snap_rail(self,pos)
|
||||
self.turn_timer = 0
|
||||
return
|
||||
elseif rail(vector.new(pos.x+1,pos.y,pos.z)) then
|
||||
print("+z")
|
||||
self.object:setvelocity(vector.new(vel.z,0,0))
|
||||
self.axis = "x"
|
||||
snap_rail(self,pos)
|
||||
self.turn_timer = 0
|
||||
return
|
||||
end
|
||||
end
|
||||
local axis = self.axis
|
||||
local vel = self.object:getvelocity()
|
||||
vel.x = math.abs(vel.x)
|
||||
vel.y = math.abs(vel.y)
|
||||
vel.z = math.abs(vel.z)
|
||||
|
||||
if axis == "x" then
|
||||
if rail(vector.new(pos.x,pos.y,pos.z-1)) then
|
||||
print("-x")
|
||||
self.object:setvelocity(vector.new(0,0,vel.x*-1))
|
||||
self.axis = "z"
|
||||
snap_rail(self,pos)
|
||||
self.turn_timer = 0
|
||||
return
|
||||
elseif rail(vector.new(pos.x,pos.y,pos.z+1)) then
|
||||
print("+x")
|
||||
self.object:setvelocity(vector.new(0,0,vel.x))
|
||||
self.axis = "z"
|
||||
snap_rail(self,pos)
|
||||
self.turn_timer = 0
|
||||
return
|
||||
end
|
||||
end
|
||||
if axis == "z" then
|
||||
if rail(vector.new(pos.x-1,pos.y,pos.z)) then
|
||||
print("-z")
|
||||
self.object:setvelocity(vector.new(vel.z*-1,0,0))
|
||||
self.axis = "x"
|
||||
snap_rail(self,pos)
|
||||
self.turn_timer = 0
|
||||
return
|
||||
elseif rail(vector.new(pos.x+1,pos.y,pos.z)) then
|
||||
print("+z")
|
||||
self.object:setvelocity(vector.new(vel.z,0,0))
|
||||
self.axis = "x"
|
||||
snap_rail(self,pos)
|
||||
self.turn_timer = 0
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
--try to turn
|
||||
local function turn(self,pos)
|
||||
if pastcenter(self,pos) then
|
||||
if not node_forward(self,pos) and self.axis then
|
||||
turn_check(self,pos)
|
||||
end
|
||||
end
|
||||
if pastcenter(self,pos) then
|
||||
if not node_forward(self,pos) and self.axis then
|
||||
turn_check(self,pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--the main mechanics of the minecart
|
||||
local function minecart_brain(self,dtime)
|
||||
if self.turn_timer < 5 then
|
||||
self.turn_timer = self.turn_timer + dtime
|
||||
end
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y - 0.5
|
||||
if self.turn_timer < 5 then
|
||||
self.turn_timer = self.turn_timer + dtime
|
||||
end
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y - 0.5
|
||||
|
||||
|
||||
if not self.axis then
|
||||
self.axis = axis(pos)
|
||||
end
|
||||
|
||||
if newnode(self,pos) then
|
||||
snap_rail(self,pos)
|
||||
end
|
||||
--check_hill(self,pos)
|
||||
--navigate_hill(self)
|
||||
|
||||
if not self.axis then
|
||||
self.axis = axis(pos)
|
||||
end
|
||||
|
||||
if newnode(self,pos) then
|
||||
snap_rail(self,pos)
|
||||
end
|
||||
--check_hill(self,pos)
|
||||
--navigate_hill(self)
|
||||
|
||||
|
||||
turn(self,pos)
|
||||
|
||||
on_rail(self,pos)
|
||||
physical(self,pos)
|
||||
--print(self.axis)
|
||||
|
||||
--check if falling and then fall at the same speed to go down
|
||||
|
||||
turn(self,pos)
|
||||
|
||||
on_rail(self,pos)
|
||||
physical(self,pos)
|
||||
--print(self.axis)
|
||||
|
||||
--check if falling and then fall at the same speed to go down
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_entity("minecart:minecart", {
|
||||
initial_properties = {
|
||||
physical = true, -- otherwise going uphill breaks
|
||||
collisionbox = {-0.4, -0.5, -0.4, 0.4, 0.45, 0.4},--{-0.5, -0.4, -0.5, 0.5, 0.25, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "minecart.obj",
|
||||
visual_size = {x=1, y=1},
|
||||
textures = {"minecart.png"},
|
||||
automatic_face_movement_dir = 90.0,
|
||||
automatic_face_movement_max_rotation_per_sec = 600,
|
||||
},
|
||||
initial_properties = {
|
||||
physical = true, -- otherwise going uphill breaks
|
||||
collisionbox = {-0.4, -0.5, -0.4, 0.4, 0.45, 0.4},--{-0.5, -0.4, -0.5, 0.5, 0.25, 0.5},
|
||||
visual = "mesh",
|
||||
mesh = "minecart.obj",
|
||||
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,
|
||||
punched = false,
|
||||
speed = 0,
|
||||
turn_timer = 0,
|
||||
incline = nil,
|
||||
turn_timer = 5,
|
||||
rider = nil,
|
||||
punched = false,
|
||||
speed = 0,
|
||||
turn_timer = 0,
|
||||
incline = nil,
|
||||
turn_timer = 5,
|
||||
|
||||
on_rightclick = function(self,clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
local player_name = clicker:get_player_name()
|
||||
|
||||
if self.rider and player_name == self.rider then
|
||||
self.rider = nil
|
||||
--carts:manage_attachment(clicker, nil)
|
||||
elseif not self.rider then
|
||||
self.rider = player_name
|
||||
clicker:set_attach(self.object, "", {x=0, y=-4.5, z=0}, {x=0, y=0, z=0})
|
||||
--player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
||||
--carts:manage_attachment(clicker, self.object)
|
||||
on_rightclick = function(self,clicker)
|
||||
if not clicker or not clicker:is_player() then
|
||||
return
|
||||
end
|
||||
local player_name = clicker:get_player_name()
|
||||
|
||||
if self.rider and player_name == self.rider then
|
||||
self.rider = nil
|
||||
--carts:manage_attachment(clicker, nil)
|
||||
elseif not self.rider then
|
||||
self.rider = player_name
|
||||
clicker:set_attach(self.object, "", {x=0, y=-4.5, z=0}, {x=0, y=0, z=0})
|
||||
--player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
||||
--carts:manage_attachment(clicker, self.object)
|
||||
|
||||
-- player_api does not update the animation
|
||||
-- when the player is attached, reset to default animation
|
||||
|
||||
--player_api.set_animation(clicker, "stand")
|
||||
end
|
||||
end,
|
||||
|
||||
on_activate = function(self,staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
if string.sub(staticdata, 1, string.len("return")) ~= "return" then
|
||||
return
|
||||
end
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if type(data) ~= "table" then
|
||||
return
|
||||
end
|
||||
self.railtype = data.railtype
|
||||
if data.old_dir then
|
||||
self.old_dir = data.old_dir
|
||||
end
|
||||
end,
|
||||
-- player_api does not update the animation
|
||||
-- when the player is attached, reset to default animation
|
||||
|
||||
--player_api.set_animation(clicker, "stand")
|
||||
end
|
||||
end,
|
||||
|
||||
on_activate = function(self,staticdata, dtime_s)
|
||||
self.object:set_armor_groups({immortal=1})
|
||||
if string.sub(staticdata, 1, string.len("return")) ~= "return" then
|
||||
return
|
||||
end
|
||||
local data = minetest.deserialize(staticdata)
|
||||
if type(data) ~= "table" then
|
||||
return
|
||||
end
|
||||
self.railtype = data.railtype
|
||||
if data.old_dir then
|
||||
self.old_dir = data.old_dir
|
||||
end
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
})
|
||||
end,
|
||||
|
||||
on_punch = function(self,puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
||||
local obj = minetest.add_item(self.object:getpos(), "minecart:minecart")
|
||||
self.object:remove()
|
||||
end,
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
})
|
||||
end,
|
||||
|
||||
on_punch = function(self,puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
||||
local obj = minetest.add_item(self.object:getpos(), "minecart:minecart")
|
||||
self.object:remove()
|
||||
end,
|
||||
|
||||
--repel from players on track "push"
|
||||
push = function(self)
|
||||
if self.turn_timer > 0.3 then
|
||||
local pos = self.object:getpos()
|
||||
local radius = 1.2
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, radius)) do
|
||||
if object:is_player() and object:get_player_name() ~= self.rider then
|
||||
local player_pos = object:getpos()
|
||||
pos.y = 0
|
||||
player_pos.y = 0
|
||||
|
||||
local currentvel = self.object:getvelocity()
|
||||
local vel = vector.subtract(pos, player_pos)
|
||||
vel = vector.normalize(vel)
|
||||
local distance = vector.distance(pos,player_pos)
|
||||
distance = (radius-distance)*20
|
||||
vel = vector.multiply(vel,distance)
|
||||
local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z)
|
||||
|
||||
--note : set a maximum velocity that can be added to the cart to limit extreme glitches
|
||||
|
||||
if self.axis == "x" then
|
||||
self.object:add_velocity(vector.new(acceleration.x,0,0))
|
||||
elseif self.axis == "z" then
|
||||
self.object:add_velocity(vector.new(0,0,acceleration.z))
|
||||
else
|
||||
self.object:add_velocity(acceleration)
|
||||
end
|
||||
|
||||
--acceleration = vector.multiply(acceleration, -0.5)
|
||||
--object:add_player_velocity(acceleration)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
--repel from players on track "push"
|
||||
push = function(self)
|
||||
if self.turn_timer > 0.3 then
|
||||
local pos = self.object:getpos()
|
||||
local radius = 1.2
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, radius)) do
|
||||
if object:is_player() and object:get_player_name() ~= self.rider then
|
||||
local player_pos = object:getpos()
|
||||
pos.y = 0
|
||||
player_pos.y = 0
|
||||
|
||||
local currentvel = self.object:getvelocity()
|
||||
local vel = vector.subtract(pos, player_pos)
|
||||
vel = vector.normalize(vel)
|
||||
local distance = vector.distance(pos,player_pos)
|
||||
distance = (radius-distance)*20
|
||||
vel = vector.multiply(vel,distance)
|
||||
local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z)
|
||||
|
||||
--note : set a maximum velocity that can be added to the cart to limit extreme glitches
|
||||
|
||||
if self.axis == "x" then
|
||||
self.object:add_velocity(vector.new(acceleration.x,0,0))
|
||||
elseif self.axis == "z" then
|
||||
self.object:add_velocity(vector.new(0,0,acceleration.z))
|
||||
else
|
||||
self.object:add_velocity(acceleration)
|
||||
end
|
||||
|
||||
--acceleration = vector.multiply(acceleration, -0.5)
|
||||
--object:add_player_velocity(acceleration)
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
--slows the minecart down
|
||||
slowdown = function(self)
|
||||
if not self.moving == true then
|
||||
local vel = self.object:getvelocity()
|
||||
local deceleration = vector.multiply(vel, -0.01)
|
||||
self.object:add_velocity(deceleration)
|
||||
end
|
||||
end,
|
||||
--slows the minecart down
|
||||
slowdown = function(self)
|
||||
if not self.moving == true then
|
||||
local vel = self.object:getvelocity()
|
||||
local deceleration = vector.multiply(vel, -0.01)
|
||||
self.object:add_velocity(deceleration)
|
||||
end
|
||||
end,
|
||||
|
||||
--mechanics to follow rails
|
||||
ride_rail = function(self,dtime)
|
||||
minecart_brain(self,dtime)
|
||||
end,
|
||||
--mechanics to follow rails
|
||||
ride_rail = function(self,dtime)
|
||||
minecart_brain(self,dtime)
|
||||
end,
|
||||
|
||||
on_step = function(self,dtime)
|
||||
self.push(self)
|
||||
self.slowdown(self)
|
||||
self.ride_rail(self,dtime)
|
||||
end,
|
||||
|
||||
on_step = function(self,dtime)
|
||||
self.push(self)
|
||||
self.slowdown(self)
|
||||
self.ride_rail(self,dtime)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_craftitem("minecart:minecart", {
|
||||
description = "Minecart",
|
||||
inventory_image = "minecartitem.png",
|
||||
wield_image = "minecartitem.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "rail")>0 then
|
||||
minetest.add_entity(pointed_thing.under, "minecart:minecart")
|
||||
else
|
||||
return
|
||||
end
|
||||
description = "Minecart",
|
||||
inventory_image = "minecartitem.png",
|
||||
wield_image = "minecartitem.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "rail")>0 then
|
||||
minetest.add_entity(pointed_thing.under, "minecart:minecart")
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
itemstack:take_item()
|
||||
itemstack:take_item()
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "minecart:minecart",
|
||||
recipe = {
|
||||
{"main:iron", "", "main:iron"},
|
||||
{"main:iron", "main:iron", "main:iron"},
|
||||
},
|
||||
output = "minecart:minecart",
|
||||
recipe = {
|
||||
{"main:iron", "", "main:iron"},
|
||||
{"main:iron", "main:iron", "main:iron"},
|
||||
},
|
||||
})
|
||||
|
@ -1,40 +1,40 @@
|
||||
minetest.register_node("minecart:rail",{
|
||||
description = "Rail",
|
||||
wield_image = "rail.png",
|
||||
tiles = {
|
||||
"rail.png", "railcurve.png",
|
||||
"railt.png", "railcross.png"
|
||||
},
|
||||
drawtype = "raillike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
node_placement_prediction = "",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
if minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name].walkable and minetest.get_node(pointed_thing.above).name == "air" 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,
|
||||
groups={instant=1,rail=1},
|
||||
description = "Rail",
|
||||
wield_image = "rail.png",
|
||||
tiles = {
|
||||
"rail.png", "railcurve.png",
|
||||
"railt.png", "railcross.png"
|
||||
},
|
||||
drawtype = "raillike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
node_placement_prediction = "",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
if minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name].walkable and minetest.get_node(pointed_thing.above).name == "air" 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,
|
||||
groups={instant=1,rail=1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "minecart:rail 32",
|
||||
recipe = {
|
||||
{"main:iron","","main:iron"},
|
||||
{"main:iron","main:stick","main:iron"},
|
||||
{"main:iron","","main:iron"}
|
||||
}
|
||||
output = "minecart:rail 32",
|
||||
recipe = {
|
||||
{"main:iron","","main:iron"},
|
||||
{"main:iron","main:stick","main:iron"},
|
||||
{"main:iron","","main:iron"}
|
||||
}
|
||||
})
|
||||
|
@ -10,122 +10,122 @@ dofile(path.."/items.lua")
|
||||
--these are helpers to create entities
|
||||
|
||||
minetest.register_entity("mob:pig", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.37, -0.01, -0.37, 0.37, 0.865, 0.37},
|
||||
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 = 600,
|
||||
},
|
||||
hp = 5,
|
||||
mob = true,
|
||||
hostile = false,
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.37, -0.01, -0.37, 0.37, 0.865, 0.37},
|
||||
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 = 600,
|
||||
},
|
||||
hp = 5,
|
||||
mob = true,
|
||||
hostile = false,
|
||||
|
||||
|
||||
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
|
||||
self.object:set_animation({x=0,y=40}, 20, 0, true)
|
||||
self.object:set_hp(self.hp)
|
||||
self.direction = vector.new(math.random()*math.random(-1,1),0,math.random()*math.random(-1,1))
|
||||
end,
|
||||
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
|
||||
local hurt = tool_capabilities.damage_groups.fleshy
|
||||
if not hurt then
|
||||
hurt = 1
|
||||
end
|
||||
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")
|
||||
end,
|
||||
|
||||
--repel from players
|
||||
push = function(self)
|
||||
local pos = self.object:getpos()
|
||||
local radius = 1
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, radius)) do
|
||||
if object:is_player() or object:get_luaentity().mob == true then
|
||||
local player_pos = object:getpos()
|
||||
pos.y = 0
|
||||
player_pos.y = 0
|
||||
|
||||
local currentvel = self.object:getvelocity()
|
||||
local vel = vector.subtract(pos, player_pos)
|
||||
vel = vector.normalize(vel)
|
||||
local distance = vector.distance(pos,player_pos)
|
||||
distance = (radius-distance)*10
|
||||
vel = vector.multiply(vel,distance)
|
||||
local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z)
|
||||
|
||||
|
||||
self.object:add_velocity(acceleration)
|
||||
|
||||
acceleration = vector.multiply(acceleration, -0.5)
|
||||
object:add_player_velocity(acceleration)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
timer = 0,
|
||||
|
||||
--This makes the mob walk at a certain speed and jump
|
||||
move = function(self,dtime)
|
||||
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
|
||||
self.object:set_animation({x=0,y=40}, 20, 0, true)
|
||||
self.object:set_hp(self.hp)
|
||||
self.direction = vector.new(math.random()*math.random(-1,1),0,math.random()*math.random(-1,1))
|
||||
end,
|
||||
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
|
||||
local hurt = tool_capabilities.damage_groups.fleshy
|
||||
if not hurt then
|
||||
hurt = 1
|
||||
end
|
||||
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")
|
||||
end,
|
||||
|
||||
--repel from players
|
||||
push = function(self)
|
||||
local pos = self.object:getpos()
|
||||
local radius = 1
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, radius)) do
|
||||
if object:is_player() or object:get_luaentity().mob == true then
|
||||
local player_pos = object:getpos()
|
||||
pos.y = 0
|
||||
player_pos.y = 0
|
||||
|
||||
local currentvel = self.object:getvelocity()
|
||||
local vel = vector.subtract(pos, player_pos)
|
||||
vel = vector.normalize(vel)
|
||||
local distance = vector.distance(pos,player_pos)
|
||||
distance = (radius-distance)*10
|
||||
vel = vector.multiply(vel,distance)
|
||||
local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z)
|
||||
|
||||
|
||||
self.object:add_velocity(acceleration)
|
||||
|
||||
acceleration = vector.multiply(acceleration, -0.5)
|
||||
object:add_player_velocity(acceleration)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
timer = 0,
|
||||
|
||||
--This makes the mob walk at a certain speed and jump
|
||||
move = function(self,dtime)
|
||||
self.timer = self.timer - dtime
|
||||
if self.timer <= 0 then
|
||||
self.timer = math.random(1,3)
|
||||
@ -152,33 +152,33 @@ minetest.register_entity("mob:pig", {
|
||||
self.object:add_velocity(vector.new(0,5,0))
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
end,
|
||||
|
||||
|
||||
--makes the mob swim
|
||||
swim = function(self)
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y + 0.7
|
||||
local node = minetest.get_node(pos).name
|
||||
local vel = self.object:getvelocity()
|
||||
local goal = 3
|
||||
local acceleration = vector.new(0,goal-vel.y,0)
|
||||
self.swimming = false
|
||||
|
||||
if node == "main:water" or node =="main:waterflow" 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.object:getvelocity())
|
||||
self.object:set_animation_frame_speed(distance*20)
|
||||
end,
|
||||
--makes the mob swim
|
||||
swim = function(self)
|
||||
local pos = self.object:getpos()
|
||||
pos.y = pos.y + 0.7
|
||||
local node = minetest.get_node(pos).name
|
||||
local vel = self.object:getvelocity()
|
||||
local goal = 3
|
||||
local acceleration = vector.new(0,goal-vel.y,0)
|
||||
self.swimming = false
|
||||
|
||||
if node == "main:water" or node =="main:waterflow" 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.object:getvelocity())
|
||||
self.object:set_animation_frame_speed(distance*20)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
on_step = function(self, dtime)
|
||||
self.move(self,dtime)
|
||||
self.set_animation(self)
|
||||
end,
|
||||
self.set_animation(self)
|
||||
end,
|
||||
})
|
||||
|
@ -1,19 +1,19 @@
|
||||
--items
|
||||
minetest.register_craftitem("mob:raw_porkchop", {
|
||||
description = "Raw Porkchop",
|
||||
inventory_image = "raw_porkchop.png",
|
||||
health = 2,
|
||||
description = "Raw Porkchop",
|
||||
inventory_image = "raw_porkchop.png",
|
||||
health = 2,
|
||||
})
|
||||
minetest.register_craftitem("mob:cooked_porkchop", {
|
||||
description = "Cooked Porkchop",
|
||||
inventory_image = "cooked_porkchop.png",
|
||||
health = 4,
|
||||
description = "Cooked Porkchop",
|
||||
inventory_image = "cooked_porkchop.png",
|
||||
health = 4,
|
||||
})
|
||||
|
||||
--cooking
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "mob:cooked_porkchop",
|
||||
recipe = "mob:raw_porkchop",
|
||||
cooktime = 3,
|
||||
type = "cooking",
|
||||
output = "mob:cooked_porkchop",
|
||||
recipe = "mob:raw_porkchop",
|
||||
cooktime = 3,
|
||||
})
|
||||
|
@ -12,49 +12,49 @@ local outer = 128
|
||||
local spawn = true
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if spawn then
|
||||
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
|
||||
if spawn then
|
||||
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
|
||||
end)
|
||||
|
@ -7,178 +7,178 @@ sneaking --set eye offset
|
||||
crafter_version = 0.03
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
--add in info
|
||||
player:hud_set_flags({minimap=true})
|
||||
player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0,y=0},
|
||||
text = "Crafter Alpha "..crafter_version,
|
||||
number = 000000,
|
||||
alignment = {x=1,y=1},
|
||||
offset = {x=2, y=2},
|
||||
})
|
||||
player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0,y=0},
|
||||
text = "Crafter Alpha "..crafter_version,
|
||||
number = 0xffffff,
|
||||
alignment = {x=1,y=1},
|
||||
offset = {x=0, y=0},
|
||||
})
|
||||
--add in info
|
||||
player:hud_set_flags({minimap=true})
|
||||
player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0,y=0},
|
||||
text = "Crafter Alpha "..crafter_version,
|
||||
number = 000000,
|
||||
alignment = {x=1,y=1},
|
||||
offset = {x=2, y=2},
|
||||
})
|
||||
player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0,y=0},
|
||||
text = "Crafter Alpha "..crafter_version,
|
||||
number = 0xffffff,
|
||||
alignment = {x=1,y=1},
|
||||
offset = {x=0, y=0},
|
||||
})
|
||||
end)
|
||||
|
||||
--hurt sound
|
||||
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||
if hp_change < 0 then
|
||||
minetest.sound_play("hurt", {object=player, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100})
|
||||
end
|
||||
if hp_change < 0 then
|
||||
minetest.sound_play("hurt", {object=player, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100})
|
||||
end
|
||||
end)
|
||||
|
||||
--throw all items on death
|
||||
minetest.register_on_dieplayer(function(player, reason)
|
||||
local pos = player:getpos()
|
||||
local inv = player:get_inventory()
|
||||
|
||||
for i = 1,inv:get_size("main") do
|
||||
local stack = inv:get_stack("main", i)
|
||||
local name = stack:get_name()
|
||||
local count = stack:get_count()
|
||||
if name ~= "" then
|
||||
local obj = minetest.add_item(pos, name.." "..count)
|
||||
obj:setvelocity(vector.new(math.random(-3,3),math.random(4,8),math.random(-3,3)))
|
||||
inv:set_stack("main", i, ItemStack(""))
|
||||
end
|
||||
end
|
||||
for i = 1,inv:get_size("craft") do
|
||||
|
||||
end
|
||||
|
||||
local pos = player:getpos()
|
||||
local inv = player:get_inventory()
|
||||
|
||||
for i = 1,inv:get_size("main") do
|
||||
local stack = inv:get_stack("main", i)
|
||||
local name = stack:get_name()
|
||||
local count = stack:get_count()
|
||||
if name ~= "" then
|
||||
local obj = minetest.add_item(pos, name.." "..count)
|
||||
obj:setvelocity(vector.new(math.random(-3,3),math.random(4,8),math.random(-3,3)))
|
||||
inv:set_stack("main", i, ItemStack(""))
|
||||
end
|
||||
end
|
||||
for i = 1,inv:get_size("craft") do
|
||||
|
||||
end
|
||||
|
||||
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
--collection
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local run = player:get_player_control().aux1
|
||||
local walk = player:get_player_control().up
|
||||
local sneak = player:get_player_control().sneak
|
||||
|
||||
if run and walk and not sneak then
|
||||
--[[ I'll impliment this in later
|
||||
local meta = player:get_meta()
|
||||
|
||||
local run_time = meta:get_float("running_timer")
|
||||
|
||||
if not run_time then
|
||||
run_time = 0
|
||||
end
|
||||
|
||||
if run_time >= 0.1 then
|
||||
--take breath away
|
||||
local breath = player:get_breath()
|
||||
breath = breath - 1
|
||||
player:set_breath(breath)
|
||||
run_time = 0
|
||||
print(breath)
|
||||
end
|
||||
|
||||
meta:set_float("running_timer", run_time + dtime)
|
||||
|
||||
]]--
|
||||
|
||||
local fov = player:get_fov()
|
||||
if fov == 0 then
|
||||
fov = 1
|
||||
end
|
||||
|
||||
if fov < 1.2 then
|
||||
player:set_fov(fov + dtime, true)
|
||||
elseif fov > 1.2 then
|
||||
--collection
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local run = player:get_player_control().aux1
|
||||
local walk = player:get_player_control().up
|
||||
local sneak = player:get_player_control().sneak
|
||||
|
||||
if run and walk and not sneak then
|
||||
--[[ I'll impliment this in later
|
||||
local meta = player:get_meta()
|
||||
|
||||
local run_time = meta:get_float("running_timer")
|
||||
|
||||
if not run_time then
|
||||
run_time = 0
|
||||
end
|
||||
|
||||
if run_time >= 0.1 then
|
||||
--take breath away
|
||||
local breath = player:get_breath()
|
||||
breath = breath - 1
|
||||
player:set_breath(breath)
|
||||
run_time = 0
|
||||
print(breath)
|
||||
end
|
||||
|
||||
meta:set_float("running_timer", run_time + dtime)
|
||||
|
||||
]]--
|
||||
|
||||
local fov = player:get_fov()
|
||||
if fov == 0 then
|
||||
fov = 1
|
||||
end
|
||||
|
||||
if fov < 1.2 then
|
||||
player:set_fov(fov + dtime, true)
|
||||
elseif fov > 1.2 then
|
||||
player:set_fov(1.2, true)
|
||||
end
|
||||
|
||||
player:set_physics_override({speed=1.5})
|
||||
else
|
||||
local meta = player:get_meta()
|
||||
local fov = player:get_fov()
|
||||
if fov > 1 then
|
||||
player:set_fov(fov - dtime, true)
|
||||
elseif fov < 1 then
|
||||
end
|
||||
|
||||
player:set_physics_override({speed=1.5})
|
||||
else
|
||||
local meta = player:get_meta()
|
||||
local fov = player:get_fov()
|
||||
if fov > 1 then
|
||||
player:set_fov(fov - dtime, true)
|
||||
elseif fov < 1 then
|
||||
player:set_fov(1, true)
|
||||
end
|
||||
|
||||
player:set_physics_override({speed=1})
|
||||
--meta:set_float("running_timer", 0)
|
||||
end
|
||||
|
||||
if sneak then
|
||||
player:set_eye_offset({x=0,y=-1,z=0},{x=0,y=-1,z=0})
|
||||
else
|
||||
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
player:set_physics_override({speed=1})
|
||||
--meta:set_float("running_timer", 0)
|
||||
end
|
||||
|
||||
if sneak then
|
||||
player:set_eye_offset({x=0,y=-1,z=0},{x=0,y=-1,z=0})
|
||||
else
|
||||
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
--collection
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
if player:get_player_control().RMB then
|
||||
local health = player:get_wielded_item():get_definition().health
|
||||
if health then
|
||||
local meta = player:get_meta()
|
||||
local eating = meta:get_float("eating")
|
||||
|
||||
if meta:get_int("eating_ps") == 0 then
|
||||
local ps = minetest.add_particlespawner({
|
||||
amount = 100,
|
||||
time = 0,
|
||||
minpos = {x=0, y=-1.5, z=0.5},
|
||||
maxpos = {x=0, y=1.7, z=0.5},
|
||||
minvel = vector.new(-0.5,0,-0.5),
|
||||
maxvel = vector.new(0.5,0,0.5),
|
||||
minacc = {x=0, y=-9.81, z=1},
|
||||
maxacc = {x=0, y=-9.81, z=1},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1.5,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
attached = player,
|
||||
collisiondetection = true,
|
||||
vertical = false,
|
||||
texture = "treecapitator.png"
|
||||
})
|
||||
meta:set_int("eating_ps", ps)
|
||||
end
|
||||
|
||||
if eating + dtime >= 2 then
|
||||
local stack = player:get_wielded_item()
|
||||
stack:take_item(1)
|
||||
player:set_wielded_item(stack)
|
||||
player:set_hp(player:get_hp() + health)
|
||||
eating = 0
|
||||
minetest.sound_play("eat", {
|
||||
object = player,
|
||||
gain = 1.0, -- default
|
||||
max_hear_distance = 32, -- default, uses an euclidean metric
|
||||
pitch = math.random(70,100)/100,
|
||||
})
|
||||
end
|
||||
meta:set_float("eating", eating + dtime)
|
||||
else
|
||||
local meta = player:get_meta()
|
||||
meta:set_float("eating", 0)
|
||||
minetest.delete_particlespawner(meta:get_int("eating_ps"))
|
||||
meta:set_int("eating_ps", 0)
|
||||
|
||||
end
|
||||
else
|
||||
local meta = player:get_meta()
|
||||
meta:set_float("eating", 0)
|
||||
minetest.delete_particlespawner(meta:get_int("eating_ps"))
|
||||
meta:set_int("eating_ps", 0)
|
||||
end
|
||||
|
||||
end
|
||||
--collection
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
if player:get_player_control().RMB then
|
||||
local health = player:get_wielded_item():get_definition().health
|
||||
if health then
|
||||
local meta = player:get_meta()
|
||||
local eating = meta:get_float("eating")
|
||||
|
||||
if meta:get_int("eating_ps") == 0 then
|
||||
local ps = minetest.add_particlespawner({
|
||||
amount = 100,
|
||||
time = 0,
|
||||
minpos = {x=0, y=-1.5, z=0.5},
|
||||
maxpos = {x=0, y=1.7, z=0.5},
|
||||
minvel = vector.new(-0.5,0,-0.5),
|
||||
maxvel = vector.new(0.5,0,0.5),
|
||||
minacc = {x=0, y=-9.81, z=1},
|
||||
maxacc = {x=0, y=-9.81, z=1},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1.5,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
attached = player,
|
||||
collisiondetection = true,
|
||||
vertical = false,
|
||||
texture = "treecapitator.png"
|
||||
})
|
||||
meta:set_int("eating_ps", ps)
|
||||
end
|
||||
|
||||
if eating + dtime >= 2 then
|
||||
local stack = player:get_wielded_item()
|
||||
stack:take_item(1)
|
||||
player:set_wielded_item(stack)
|
||||
player:set_hp(player:get_hp() + health)
|
||||
eating = 0
|
||||
minetest.sound_play("eat", {
|
||||
object = player,
|
||||
gain = 1.0, -- default
|
||||
max_hear_distance = 32, -- default, uses an euclidean metric
|
||||
pitch = math.random(70,100)/100,
|
||||
})
|
||||
end
|
||||
meta:set_float("eating", eating + dtime)
|
||||
else
|
||||
local meta = player:get_meta()
|
||||
meta:set_float("eating", 0)
|
||||
minetest.delete_particlespawner(meta:get_int("eating_ps"))
|
||||
meta:set_int("eating_ps", 0)
|
||||
|
||||
end
|
||||
else
|
||||
local meta = player:get_meta()
|
||||
meta:set_float("eating", 0)
|
||||
minetest.delete_particlespawner(meta:get_int("eating_ps"))
|
||||
meta:set_int("eating_ps", 0)
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@ -215,9 +215,9 @@ local dump_craft = function(player)
|
||||
local obj = minetest.add_item(pos, item)
|
||||
if obj then
|
||||
local x=math.random(-2,2)*math.random()
|
||||
local y=math.random(2,5)
|
||||
local z=math.random(-2,2)*math.random()
|
||||
obj:setvelocity({x=x, y=y, z=z})
|
||||
local y=math.random(2,5)
|
||||
local z=math.random(-2,2)*math.random()
|
||||
obj:setvelocity({x=x, y=y, z=z})
|
||||
end
|
||||
inv:set_stack("craft", i, nil)
|
||||
end
|
||||
|
@ -26,112 +26,112 @@ redstone = {}
|
||||
|
||||
--3d plane direct neighbor
|
||||
function redstone.update(pos,oldnode)
|
||||
local old_max_level = minetest.registered_nodes[minetest.get_node(pos).name].power
|
||||
--recover old info
|
||||
if not old_max_level then
|
||||
old_max_level = minetest.registered_nodes[oldnode.name].power
|
||||
end
|
||||
local old_max_level = minetest.registered_nodes[minetest.get_node(pos).name].power
|
||||
--recover old info
|
||||
if not old_max_level then
|
||||
old_max_level = minetest.registered_nodes[oldnode.name].power
|
||||
end
|
||||
|
||||
local max_level = 0
|
||||
for x = -1,1 do
|
||||
for y = -1,1 do
|
||||
for z = -1,1 do
|
||||
if math.abs(x)+math.abs(y)+math.abs(z) == 1 then
|
||||
local pos2 = vector.add(pos,vector.new(x,y,z))
|
||||
local level2 = minetest.registered_nodes[minetest.get_node(pos2).name].power
|
||||
if level2 and level2 > max_level then
|
||||
max_level = level2 - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local max_level = 0
|
||||
for x = -1,1 do
|
||||
for y = -1,1 do
|
||||
for z = -1,1 do
|
||||
if math.abs(x)+math.abs(y)+math.abs(z) == 1 then
|
||||
local pos2 = vector.add(pos,vector.new(x,y,z))
|
||||
local level2 = minetest.registered_nodes[minetest.get_node(pos2).name].power
|
||||
if level2 and level2 > max_level then
|
||||
max_level = level2 - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--print(max_level)
|
||||
if old_max_level and old_max_level > max_level then
|
||||
max_level = 0
|
||||
end
|
||||
--change to dust
|
||||
if minetest.get_node_group(minetest.get_node(pos).name, "redstone_dust") > 0 then
|
||||
minetest.set_node(pos, {name="redstone:dust_"..max_level})
|
||||
elseif minetest.get_node_group(minetest.get_node(pos).name, "redstone_wire") > 0 then
|
||||
minetest.set_node(pos, {name="redstone:wire_"..max_level})
|
||||
end
|
||||
--print(max_level)
|
||||
if old_max_level and old_max_level > max_level then
|
||||
max_level = 0
|
||||
end
|
||||
--change to dust
|
||||
if minetest.get_node_group(minetest.get_node(pos).name, "redstone_dust") > 0 then
|
||||
minetest.set_node(pos, {name="redstone:dust_"..max_level})
|
||||
elseif minetest.get_node_group(minetest.get_node(pos).name, "redstone_wire") > 0 then
|
||||
minetest.set_node(pos, {name="redstone:wire_"..max_level})
|
||||
end
|
||||
|
||||
for x = -1,1 do
|
||||
for y = -1,1 do
|
||||
for z = -1,1 do
|
||||
if math.abs(x)+math.abs(y)+math.abs(z) == 1 then
|
||||
local pos2 = vector.add(pos,vector.new(x,y,z))
|
||||
local level2 = minetest.registered_nodes[minetest.get_node(pos2).name].power
|
||||
if level2 and (level2 < max_level or level2 < old_max_level) then
|
||||
redstone.update(pos2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for x = -1,1 do
|
||||
for y = -1,1 do
|
||||
for z = -1,1 do
|
||||
if math.abs(x)+math.abs(y)+math.abs(z) == 1 then
|
||||
local pos2 = vector.add(pos,vector.new(x,y,z))
|
||||
local level2 = minetest.registered_nodes[minetest.get_node(pos2).name].power
|
||||
if level2 and (level2 < max_level or level2 < old_max_level) then
|
||||
redstone.update(pos2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
minetest.register_craftitem("redstone:dust", {
|
||||
description = "Redstone Dust",
|
||||
inventory_image = "redstone_dust_item.png",
|
||||
wield_image = "redstone_dust_item.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
liquids_pointable = false,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
if minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name].walkable and minetest.get_node(pointed_thing.above).name == "air" then
|
||||
minetest.add_node(pointed_thing.above, {name="redstone:dust_0"})
|
||||
itemstack:take_item(1)
|
||||
--print(minetest.get_node(pointed_thing.above).param1)
|
||||
minetest.after(0,function(pointed_thing)
|
||||
redstone.update(pos)
|
||||
end,pointed_thing)
|
||||
return(itemstack)
|
||||
end
|
||||
end,
|
||||
description = "Redstone Dust",
|
||||
inventory_image = "redstone_dust_item.png",
|
||||
wield_image = "redstone_dust_item.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
liquids_pointable = false,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pointed_thing.type == "node" then
|
||||
return
|
||||
end
|
||||
local pos = pointed_thing.above
|
||||
if minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name].walkable and minetest.get_node(pointed_thing.above).name == "air" then
|
||||
minetest.add_node(pointed_thing.above, {name="redstone:dust_0"})
|
||||
itemstack:take_item(1)
|
||||
--print(minetest.get_node(pointed_thing.above).param1)
|
||||
minetest.after(0,function(pointed_thing)
|
||||
redstone.update(pos)
|
||||
end,pointed_thing)
|
||||
return(itemstack)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
--8 power levels 8 being the highest
|
||||
local color = 0
|
||||
for i = 0,8 do
|
||||
local coloring = math.floor(color)
|
||||
minetest.register_node("redstone:dust_"..i,{
|
||||
description = "Redstone Dust",
|
||||
wield_image = "redstone_dust_item.png",
|
||||
tiles = {
|
||||
"redstone_dust_main.png^[colorize:red:"..coloring, "redstone_turn.png^[colorize:red:"..coloring,
|
||||
"redstone_t.png^[colorize:red:"..coloring, "redstone_cross.png^[colorize:red:"..coloring
|
||||
},
|
||||
power=i,
|
||||
drawtype = "raillike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
node_placement_prediction = "",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||
},
|
||||
groups={instant=1,attached=1,redstone_dust=1,redstone=1},
|
||||
drop="redstone:dust",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
minetest.node_dig(pos, node, digger)
|
||||
redstone.update(pos,node)
|
||||
end,
|
||||
connects_to = {"group:redstone"},
|
||||
})
|
||||
color= color +31.875
|
||||
local coloring = math.floor(color)
|
||||
minetest.register_node("redstone:dust_"..i,{
|
||||
description = "Redstone Dust",
|
||||
wield_image = "redstone_dust_item.png",
|
||||
tiles = {
|
||||
"redstone_dust_main.png^[colorize:red:"..coloring, "redstone_turn.png^[colorize:red:"..coloring,
|
||||
"redstone_t.png^[colorize:red:"..coloring, "redstone_cross.png^[colorize:red:"..coloring
|
||||
},
|
||||
power=i,
|
||||
drawtype = "raillike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
node_placement_prediction = "",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||||
},
|
||||
groups={instant=1,attached=1,redstone_dust=1,redstone=1},
|
||||
drop="redstone:dust",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
minetest.node_dig(pos, node, digger)
|
||||
redstone.update(pos,node)
|
||||
end,
|
||||
connects_to = {"group:redstone"},
|
||||
})
|
||||
color= color +31.875
|
||||
end
|
||||
|
||||
|
@ -1,202 +1,202 @@
|
||||
--get point where particle spawner is added
|
||||
local function get_offset(wdir)
|
||||
local z = 0
|
||||
local x = 0
|
||||
if wdir == 4 then
|
||||
z = 0.25
|
||||
elseif wdir == 2 then
|
||||
x = 0.25
|
||||
elseif wdir == 5 then
|
||||
z = -0.25
|
||||
elseif wdir == 3 then
|
||||
x = -0.25
|
||||
end
|
||||
return {x = x, y = 0.27, z = z}
|
||||
local z = 0
|
||||
local x = 0
|
||||
if wdir == 4 then
|
||||
z = 0.25
|
||||
elseif wdir == 2 then
|
||||
x = 0.25
|
||||
elseif wdir == 5 then
|
||||
z = -0.25
|
||||
elseif wdir == 3 then
|
||||
x = -0.25
|
||||
end
|
||||
return {x = x, y = 0.27, z = z}
|
||||
end
|
||||
|
||||
--remove smoke and fire
|
||||
local function delete_ps(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.delete_particlespawner(meta:get_int("psf"))
|
||||
minetest.delete_particlespawner(meta:get_int("pss"))
|
||||
local meta = minetest.get_meta(pos)
|
||||
minetest.delete_particlespawner(meta:get_int("psf"))
|
||||
minetest.delete_particlespawner(meta:get_int("pss"))
|
||||
end
|
||||
|
||||
--add in smoke and fire
|
||||
local function create_ps(pos)
|
||||
local dir = get_offset(minetest.get_node(pos).param2)
|
||||
local ppos = vector.add(dir,pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local psf = minetest.add_particlespawner({
|
||||
amount = 2,
|
||||
time = 0,
|
||||
minpos = ppos,
|
||||
maxpos = ppos,
|
||||
minvel = vector.new(0,0,0),
|
||||
maxvel = vector.new(0,0,0),
|
||||
minacc = {x=0, y=0, z=0},
|
||||
maxacc = {x=0, y=0, z=0},
|
||||
minexptime = 1,
|
||||
maxexptime = 1,
|
||||
minsize = 3,
|
||||
maxsize = 3,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "redstone_torch_animated.png",
|
||||
animation = {type = "vertical_frames",
|
||||
local dir = get_offset(minetest.get_node(pos).param2)
|
||||
local ppos = vector.add(dir,pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local psf = minetest.add_particlespawner({
|
||||
amount = 2,
|
||||
time = 0,
|
||||
minpos = ppos,
|
||||
maxpos = ppos,
|
||||
minvel = vector.new(0,0,0),
|
||||
maxvel = vector.new(0,0,0),
|
||||
minacc = {x=0, y=0, z=0},
|
||||
maxacc = {x=0, y=0, z=0},
|
||||
minexptime = 1,
|
||||
maxexptime = 1,
|
||||
minsize = 3,
|
||||
maxsize = 3,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "redstone_torch_animated.png",
|
||||
animation = {type = "vertical_frames",
|
||||
|
||||
aspect_w = 16,
|
||||
-- Width of a frame in pixels
|
||||
aspect_w = 16,
|
||||
-- Width of a frame in pixels
|
||||
|
||||
aspect_h = 16,
|
||||
-- Height of a frame in pixels
|
||||
aspect_h = 16,
|
||||
-- Height of a frame in pixels
|
||||
|
||||
length = 0.2,
|
||||
-- Full loop length
|
||||
},
|
||||
})
|
||||
local pss = minetest.add_particlespawner({
|
||||
amount = 2,
|
||||
time = 0,
|
||||
minpos = ppos,
|
||||
maxpos = ppos,
|
||||
minvel = vector.new(-0.1,0.1,-0.1),
|
||||
maxvel = vector.new(0.1,0.3,0.1),
|
||||
minacc = vector.new(0,0,0),
|
||||
maxacc = vector.new(0,0,0),
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "smoke.png",
|
||||
})
|
||||
meta:set_int("psf", psf)
|
||||
meta:set_int("pss", pss)
|
||||
length = 0.2,
|
||||
-- Full loop length
|
||||
},
|
||||
})
|
||||
local pss = minetest.add_particlespawner({
|
||||
amount = 2,
|
||||
time = 0,
|
||||
minpos = ppos,
|
||||
maxpos = ppos,
|
||||
minvel = vector.new(-0.1,0.1,-0.1),
|
||||
maxvel = vector.new(0.1,0.3,0.1),
|
||||
minacc = vector.new(0,0,0),
|
||||
maxacc = vector.new(0,0,0),
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "smoke.png",
|
||||
})
|
||||
meta:set_int("psf", psf)
|
||||
meta:set_int("pss", pss)
|
||||
end
|
||||
|
||||
--reload smoke and flame on load
|
||||
--[[
|
||||
minetest.register_lbm({
|
||||
name = "redstone:torch",
|
||||
nodenames = {"redstone:torch_floor","redstone:torch_wall"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
create_ps(pos)
|
||||
end,
|
||||
name = "redstone:torch",
|
||||
nodenames = {"redstone:torch_floor","redstone:torch_wall"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
create_ps(pos)
|
||||
end,
|
||||
})
|
||||
]]--
|
||||
-- Item definitions
|
||||
minetest.register_craftitem("redstone:torch", {
|
||||
description = "Redstone Torch",
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
liquids_pointable = false,
|
||||
power = 9,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
description = "Redstone Torch",
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
liquids_pointable = false,
|
||||
power = 9,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
if wdir < 1 then
|
||||
return itemstack
|
||||
elseif wdir == 1 then
|
||||
retval = fakestack:set_name("redstone:torch_floor")
|
||||
else
|
||||
retval = fakestack:set_name("redstone:torch_wall")
|
||||
end
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
itemstack:set_name("redstone:torch")
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
if wdir < 1 then
|
||||
return itemstack
|
||||
elseif wdir == 1 then
|
||||
retval = fakestack:set_name("redstone:torch_floor")
|
||||
else
|
||||
retval = fakestack:set_name("redstone:torch_wall")
|
||||
end
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
itemstack:set_name("redstone:torch")
|
||||
|
||||
if retval then
|
||||
minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
if retval then
|
||||
minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("redstone:torch_floor", {
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 2/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_floor.obj",
|
||||
tiles = {"redstone_torch.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "none",
|
||||
power = 9,
|
||||
sunlight_propagates = true,
|
||||
drop = "redstone:torch",
|
||||
walkable = false,
|
||||
light_source = 13,
|
||||
groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,connect_to_raillike=1},
|
||||
legacy_wallmounted = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
--create_ps(pos)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
redstone.update(pos,oldnode)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
--delete_ps(pos)
|
||||
end,
|
||||
sounds = main.woodSound(),
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 2/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_floor.obj",
|
||||
tiles = {"redstone_torch.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "none",
|
||||
power = 9,
|
||||
sunlight_propagates = true,
|
||||
drop = "redstone:torch",
|
||||
walkable = false,
|
||||
light_source = 13,
|
||||
groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,connect_to_raillike=1},
|
||||
legacy_wallmounted = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
--create_ps(pos)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
redstone.update(pos,oldnode)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
--delete_ps(pos)
|
||||
end,
|
||||
sounds = main.woodSound(),
|
||||
})
|
||||
|
||||
minetest.register_node("redstone:torch_wall", {
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_wall.obj",
|
||||
tiles = {"redstone_torch.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 13,
|
||||
power = 9,
|
||||
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,connect_to_raillike=1},
|
||||
drop = "redstone:torch",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
|
||||
wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
|
||||
wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
--create_ps(pos)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
--redstone.update(pos,oldnode)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
delete_ps(pos)
|
||||
end,
|
||||
sounds = main.woodSound(),
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_wall.obj",
|
||||
tiles = {"redstone_torch.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 13,
|
||||
power = 9,
|
||||
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,connect_to_raillike=1},
|
||||
drop = "redstone:torch",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
|
||||
wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
|
||||
wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
--create_ps(pos)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
--redstone.update(pos,oldnode)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
delete_ps(pos)
|
||||
end,
|
||||
sounds = main.woodSound(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "redstone:torch 4",
|
||||
recipe = {
|
||||
{"redstone:dust"},
|
||||
{"main:stick"}
|
||||
}
|
||||
output = "redstone:torch 4",
|
||||
recipe = {
|
||||
{"redstone:dust"},
|
||||
{"main:stick"}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -212,128 +212,128 @@ minetest.register_craft({
|
||||
|
||||
|
||||
minetest.register_craftitem("redstone:blink_torch", {
|
||||
description = "Redstone Blink Torch",
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
liquids_pointable = false,
|
||||
power = 8,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
description = "Redstone Blink Torch",
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
liquids_pointable = false,
|
||||
power = 8,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
if wdir < 1 then
|
||||
return itemstack
|
||||
elseif wdir == 1 then
|
||||
retval = fakestack:set_name("redstone:blink_torch_floor_1")
|
||||
else
|
||||
retval = fakestack:set_name("redstone:blink_torch_wall_1")
|
||||
end
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
itemstack:set_name("redstone:blink_torch")
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
if wdir < 1 then
|
||||
return itemstack
|
||||
elseif wdir == 1 then
|
||||
retval = fakestack:set_name("redstone:blink_torch_floor_1")
|
||||
else
|
||||
retval = fakestack:set_name("redstone:blink_torch_wall_1")
|
||||
end
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
itemstack:set_name("redstone:blink_torch")
|
||||
|
||||
if retval then
|
||||
minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
if retval then
|
||||
minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
for i = 0,1 do
|
||||
local coloring = 160*(1-i)
|
||||
-- BLINK TORCH
|
||||
local coloring = 160*(1-i)
|
||||
-- BLINK TORCH
|
||||
|
||||
minetest.register_node("redstone:blink_torch_floor_"..i, {
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 2/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_floor.obj",
|
||||
tiles = {"redstone_torch.png^[colorize:black:"..coloring},
|
||||
paramtype = "light",
|
||||
paramtype2 = "none",
|
||||
power = 8*i,
|
||||
sunlight_propagates = true,
|
||||
drop = "redstone:torch",
|
||||
walkable = false,
|
||||
light_source = i*13,
|
||||
groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,connect_to_raillike=1,blinker_torch = 1},
|
||||
legacy_wallmounted = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
redstone.update(pos,oldnode)
|
||||
end,
|
||||
sounds = main.woodSound(),
|
||||
})
|
||||
minetest.register_node("redstone:blink_torch_floor_"..i, {
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 2/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_floor.obj",
|
||||
tiles = {"redstone_torch.png^[colorize:black:"..coloring},
|
||||
paramtype = "light",
|
||||
paramtype2 = "none",
|
||||
power = 8*i,
|
||||
sunlight_propagates = true,
|
||||
drop = "redstone:torch",
|
||||
walkable = false,
|
||||
light_source = i*13,
|
||||
groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,connect_to_raillike=1,blinker_torch = 1},
|
||||
legacy_wallmounted = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
redstone.update(pos,oldnode)
|
||||
end,
|
||||
sounds = main.woodSound(),
|
||||
})
|
||||
|
||||
minetest.register_node("redstone:blink_torch_wall_"..i, {
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_wall.obj",
|
||||
tiles = {"redstone_torch.png^[colorize:black:"..coloring},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 13*i,
|
||||
power = 8*i,
|
||||
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,connect_to_raillike=1,blinker_torch = 1},
|
||||
drop = "redstone:torch",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
|
||||
wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
|
||||
wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
redstone.update(pos,oldnode)
|
||||
end,
|
||||
sounds = main.woodSound(),
|
||||
})
|
||||
minetest.register_node("redstone:blink_torch_wall_"..i, {
|
||||
inventory_image = "redstone_torch.png",
|
||||
wield_image = "redstone_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_wall.obj",
|
||||
tiles = {"redstone_torch.png^[colorize:black:"..coloring},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 13*i,
|
||||
power = 8*i,
|
||||
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,connect_to_raillike=1,blinker_torch = 1},
|
||||
drop = "redstone:torch",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
|
||||
wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
|
||||
wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
redstone.update(pos)
|
||||
end,
|
||||
after_destruct = function(pos, oldnode)
|
||||
redstone.update(pos,oldnode)
|
||||
end,
|
||||
sounds = main.woodSound(),
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
|
||||
minetest.register_abm{
|
||||
label = "Torch Blink",
|
||||
label = "Torch Blink",
|
||||
nodenames = {"group:blinker_torch"},
|
||||
--neighbors = {"group:redstone"},
|
||||
interval = 0.4,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
--minetest.set_node(pos,{name=node.name:sub(1, -2)..0})
|
||||
--minetest.set_node(pos,{name=node.name:sub(1, -2)..0})
|
||||
--redstone.update(pos)
|
||||
print("tests")
|
||||
local inversion = math.abs(tonumber(node.name:sub(#node.name, #node.name))-1) --never do this
|
||||
minetest.set_node(pos,{name=node.name:sub(1, #node.name-1)..inversion})
|
||||
redstone.update(pos)
|
||||
print("tests")
|
||||
local inversion = math.abs(tonumber(node.name:sub(#node.name, #node.name))-1) --never do this
|
||||
minetest.set_node(pos,{name=node.name:sub(1, #node.name-1)..inversion})
|
||||
redstone.update(pos)
|
||||
end,
|
||||
}
|
||||
minetest.register_craft({
|
||||
output = "redstone:blink_torch 4",
|
||||
recipe = {
|
||||
{"redstone:dust"},
|
||||
{"redstone:dust"},
|
||||
{"main:stick"}
|
||||
}
|
||||
output = "redstone:blink_torch 4",
|
||||
recipe = {
|
||||
{"redstone:dust"},
|
||||
{"redstone:dust"},
|
||||
{"main:stick"}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -1,58 +1,58 @@
|
||||
--8 power levels 8 being the highest
|
||||
local color = 0
|
||||
for i = 0,8 do
|
||||
local coloring = math.floor(color)
|
||||
local coloring = math.floor(color)
|
||||
|
||||
minetest.register_node("redstone:wire_"..i,{
|
||||
description = "Redstone Wire",
|
||||
--wield_image = "redstone_wire.png^[colorize:red:"..coloring,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
power = i,
|
||||
--paramtype2 = "wallmounted",
|
||||
walkable = false,
|
||||
node_box = {
|
||||
type = "connected",
|
||||
--{xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
minetest.register_node("redstone:wire_"..i,{
|
||||
description = "Redstone Wire",
|
||||
--wield_image = "redstone_wire.png^[colorize:red:"..coloring,
|
||||
paramtype = "light",
|
||||
drawtype = "nodebox",
|
||||
power = i,
|
||||
--paramtype2 = "wallmounted",
|
||||
walkable = false,
|
||||
node_box = {
|
||||
type = "connected",
|
||||
--{xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
|
||||
fixed = {-1/16, -1/2, -1/16, 1/16, -7/16, 1/16},
|
||||
|
||||
disconnected_sides = {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
|
||||
fixed = {-1/16, -1/2, -1/16, 1/16, -7/16, 1/16},
|
||||
|
||||
disconnected_sides = {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
|
||||
|
||||
connect_top = {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
|
||||
-- connect_bottom =
|
||||
connect_front = {-1/16, -1/2, -1/2, 1/16, -7/16, 1/16},
|
||||
connect_left = {-1/2, -1/2, -1/16, 1/16, -7/16, 1/16},
|
||||
connect_back = {-1/16, -1/2, -1/16, 1/16, -7/16, 1/2},
|
||||
connect_right = {-1/16, -1/2, -1/16, 1/2, -7/16, 1/16},
|
||||
},
|
||||
collision_box = {
|
||||
type = "connected",
|
||||
--{xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
connect_top = {-1/16, -1/2, -1/16, 1/16, 1/2, 1/16},
|
||||
-- connect_bottom =
|
||||
connect_front = {-1/16, -1/2, -1/2, 1/16, -7/16, 1/16},
|
||||
connect_left = {-1/2, -1/2, -1/16, 1/16, -7/16, 1/16},
|
||||
connect_back = {-1/16, -1/2, -1/16, 1/16, -7/16, 1/2},
|
||||
connect_right = {-1/16, -1/2, -1/16, 1/2, -7/16, 1/16},
|
||||
},
|
||||
collision_box = {
|
||||
type = "connected",
|
||||
--{xmin, ymin, zmin, xmax, ymax, zmax}
|
||||
|
||||
fixed = {-1/16, -1/2, -1/16, 1/16, -7/16, 1/16},
|
||||
-- connect_top =
|
||||
-- connect_bottom =
|
||||
connect_front = {-1/16, -1/2, -1/2, 1/16, -7/16, 1/16},
|
||||
connect_left = {-1/2, -1/2, -1/16, 1/16, -7/16, 1/16},
|
||||
connect_back = {-1/16, -1/2, -1/16, 1/16, -7/16, 1/2},
|
||||
connect_right = {-1/16, -1/2, -1/16, 1/2, -7/16, 1/16},
|
||||
},
|
||||
connects_to = {"group:redstone"},
|
||||
inventory_image = fence_texture,
|
||||
wield_image = fence_texture,
|
||||
tiles = {"redstone_wire.png^[colorize:red:"..coloring},
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {redstone =1, instant=1,redstone=1,redstone_wire=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
redstone.update(pointed_thing.above)
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
minetest.node_dig(pos, node, digger)
|
||||
redstone.update(pos,node)
|
||||
end,
|
||||
})
|
||||
color= color +31.875
|
||||
fixed = {-1/16, -1/2, -1/16, 1/16, -7/16, 1/16},
|
||||
-- connect_top =
|
||||
-- connect_bottom =
|
||||
connect_front = {-1/16, -1/2, -1/2, 1/16, -7/16, 1/16},
|
||||
connect_left = {-1/2, -1/2, -1/16, 1/16, -7/16, 1/16},
|
||||
connect_back = {-1/16, -1/2, -1/16, 1/16, -7/16, 1/2},
|
||||
connect_right = {-1/16, -1/2, -1/16, 1/2, -7/16, 1/16},
|
||||
},
|
||||
connects_to = {"group:redstone"},
|
||||
inventory_image = fence_texture,
|
||||
wield_image = fence_texture,
|
||||
tiles = {"redstone_wire.png^[colorize:red:"..coloring},
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {redstone =1, instant=1,redstone=1,redstone_wire=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
redstone.update(pointed_thing.above)
|
||||
end,
|
||||
on_dig = function(pos, node, digger)
|
||||
minetest.node_dig(pos, node, digger)
|
||||
redstone.update(pos,node)
|
||||
end,
|
||||
})
|
||||
color= color +31.875
|
||||
end
|
||||
|
1670
mods/sign/api.lua
1670
mods/sign/api.lua
File diff suppressed because it is too large
Load Diff
@ -1,265 +1,265 @@
|
||||
-- encoding borrowed from signs_lib fork at https://github.com/lord-server/lord
|
||||
|
||||
local ansi_decode = {
|
||||
[128] = "\208\130",
|
||||
[129] = "\208\131",
|
||||
[130] = "\226\128\154",
|
||||
[131] = "\209\147",
|
||||
[132] = "\226\128\158",
|
||||
[133] = "\226\128\166",
|
||||
[134] = "\226\128\160",
|
||||
[135] = "\226\128\161",
|
||||
[136] = "\226\130\172",
|
||||
[137] = "\226\128\176",
|
||||
[138] = "\208\137",
|
||||
[139] = "\226\128\185",
|
||||
[140] = "\208\138",
|
||||
[141] = "\208\140",
|
||||
[142] = "\208\139",
|
||||
[143] = "\208\143",
|
||||
[144] = "\209\146",
|
||||
[145] = "\226\128\152",
|
||||
[146] = "\226\128\153",
|
||||
[147] = "\226\128\156",
|
||||
[148] = "\226\128\157",
|
||||
[149] = "\226\128\162",
|
||||
[150] = "\226\128\147",
|
||||
[151] = "\226\128\148",
|
||||
[152] = "\194\152",
|
||||
[153] = "\226\132\162",
|
||||
[154] = "\209\153",
|
||||
[155] = "\226\128\186",
|
||||
[156] = "\209\154",
|
||||
[157] = "\209\156",
|
||||
[158] = "\209\155",
|
||||
[159] = "\209\159",
|
||||
[160] = "\194\160",
|
||||
[161] = "\209\142",
|
||||
[162] = "\209\158",
|
||||
[163] = "\208\136",
|
||||
[164] = "\194\164",
|
||||
[165] = "\210\144",
|
||||
[166] = "\194\166",
|
||||
[167] = "\194\167",
|
||||
[168] = "\208\129",
|
||||
[169] = "\194\169",
|
||||
[170] = "\208\132",
|
||||
[171] = "\194\171",
|
||||
[172] = "\194\172",
|
||||
[173] = "\194\173",
|
||||
[174] = "\194\174",
|
||||
[175] = "\208\135",
|
||||
[176] = "\194\176",
|
||||
[177] = "\194\177",
|
||||
[178] = "\208\134",
|
||||
[179] = "\209\150",
|
||||
[180] = "\210\145",
|
||||
[181] = "\194\181",
|
||||
[182] = "\194\182",
|
||||
[183] = "\194\183",
|
||||
[184] = "\209\145",
|
||||
[185] = "\226\132\150",
|
||||
[186] = "\209\148",
|
||||
[187] = "\194\187",
|
||||
[188] = "\209\152",
|
||||
[189] = "\208\133",
|
||||
[190] = "\209\149",
|
||||
[191] = "\209\151"
|
||||
[128] = "\208\130",
|
||||
[129] = "\208\131",
|
||||
[130] = "\226\128\154",
|
||||
[131] = "\209\147",
|
||||
[132] = "\226\128\158",
|
||||
[133] = "\226\128\166",
|
||||
[134] = "\226\128\160",
|
||||
[135] = "\226\128\161",
|
||||
[136] = "\226\130\172",
|
||||
[137] = "\226\128\176",
|
||||
[138] = "\208\137",
|
||||
[139] = "\226\128\185",
|
||||
[140] = "\208\138",
|
||||
[141] = "\208\140",
|
||||
[142] = "\208\139",
|
||||
[143] = "\208\143",
|
||||
[144] = "\209\146",
|
||||
[145] = "\226\128\152",
|
||||
[146] = "\226\128\153",
|
||||
[147] = "\226\128\156",
|
||||
[148] = "\226\128\157",
|
||||
[149] = "\226\128\162",
|
||||
[150] = "\226\128\147",
|
||||
[151] = "\226\128\148",
|
||||
[152] = "\194\152",
|
||||
[153] = "\226\132\162",
|
||||
[154] = "\209\153",
|
||||
[155] = "\226\128\186",
|
||||
[156] = "\209\154",
|
||||
[157] = "\209\156",
|
||||
[158] = "\209\155",
|
||||
[159] = "\209\159",
|
||||
[160] = "\194\160",
|
||||
[161] = "\209\142",
|
||||
[162] = "\209\158",
|
||||
[163] = "\208\136",
|
||||
[164] = "\194\164",
|
||||
[165] = "\210\144",
|
||||
[166] = "\194\166",
|
||||
[167] = "\194\167",
|
||||
[168] = "\208\129",
|
||||
[169] = "\194\169",
|
||||
[170] = "\208\132",
|
||||
[171] = "\194\171",
|
||||
[172] = "\194\172",
|
||||
[173] = "\194\173",
|
||||
[174] = "\194\174",
|
||||
[175] = "\208\135",
|
||||
[176] = "\194\176",
|
||||
[177] = "\194\177",
|
||||
[178] = "\208\134",
|
||||
[179] = "\209\150",
|
||||
[180] = "\210\145",
|
||||
[181] = "\194\181",
|
||||
[182] = "\194\182",
|
||||
[183] = "\194\183",
|
||||
[184] = "\209\145",
|
||||
[185] = "\226\132\150",
|
||||
[186] = "\209\148",
|
||||
[187] = "\194\187",
|
||||
[188] = "\209\152",
|
||||
[189] = "\208\133",
|
||||
[190] = "\209\149",
|
||||
[191] = "\209\151"
|
||||
}
|
||||
local utf8_decode = {
|
||||
[128] = {
|
||||
[147] = "\150",
|
||||
[148] = "\151",
|
||||
[152] = "\145",
|
||||
[153] = "\146",
|
||||
[154] = "\130",
|
||||
[156] = "\147",
|
||||
[157] = "\148",
|
||||
[158] = "\132",
|
||||
[160] = "\134",
|
||||
[161] = "\135",
|
||||
[162] = "\149",
|
||||
[166] = "\133",
|
||||
[176] = "\137",
|
||||
[185] = "\139",
|
||||
[186] = "\155"
|
||||
},
|
||||
[130] = {[172] = "\136"},
|
||||
[132] = {[150] = "\185", [162] = "\153"},
|
||||
[194] = {
|
||||
[152] = "\152",
|
||||
[160] = "\160",
|
||||
[164] = "\164",
|
||||
[166] = "\166",
|
||||
[167] = "\167",
|
||||
[169] = "\169",
|
||||
[171] = "\171",
|
||||
[172] = "\172",
|
||||
[173] = "\173",
|
||||
[174] = "\174",
|
||||
[176] = "\176",
|
||||
[177] = "\177",
|
||||
[181] = "\181",
|
||||
[182] = "\182",
|
||||
[183] = "\183",
|
||||
[187] = "\187"
|
||||
},
|
||||
[208] = {
|
||||
[129] = "\168",
|
||||
[130] = "\128",
|
||||
[131] = "\129",
|
||||
[132] = "\170",
|
||||
[133] = "\189",
|
||||
[134] = "\178",
|
||||
[135] = "\175",
|
||||
[136] = "\163",
|
||||
[137] = "\138",
|
||||
[138] = "\140",
|
||||
[139] = "\142",
|
||||
[140] = "\141",
|
||||
[143] = "\143",
|
||||
[144] = "\192",
|
||||
[145] = "\193",
|
||||
[146] = "\194",
|
||||
[147] = "\195",
|
||||
[148] = "\196",
|
||||
[149] = "\197",
|
||||
[150] = "\198",
|
||||
[151] = "\199",
|
||||
[152] = "\200",
|
||||
[153] = "\201",
|
||||
[154] = "\202",
|
||||
[155] = "\203",
|
||||
[156] = "\204",
|
||||
[157] = "\205",
|
||||
[158] = "\206",
|
||||
[159] = "\207",
|
||||
[160] = "\208",
|
||||
[161] = "\209",
|
||||
[162] = "\210",
|
||||
[163] = "\211",
|
||||
[164] = "\212",
|
||||
[165] = "\213",
|
||||
[166] = "\214",
|
||||
[167] = "\215",
|
||||
[168] = "\216",
|
||||
[169] = "\217",
|
||||
[170] = "\218",
|
||||
[171] = "\219",
|
||||
[172] = "\220",
|
||||
[173] = "\221",
|
||||
[174] = "\222",
|
||||
[175] = "\223",
|
||||
[176] = "\224",
|
||||
[177] = "\225",
|
||||
[178] = "\226",
|
||||
[179] = "\227",
|
||||
[180] = "\228",
|
||||
[181] = "\229",
|
||||
[182] = "\230",
|
||||
[183] = "\231",
|
||||
[184] = "\232",
|
||||
[185] = "\233",
|
||||
[186] = "\234",
|
||||
[187] = "\235",
|
||||
[188] = "\236",
|
||||
[189] = "\237",
|
||||
[190] = "\238",
|
||||
[191] = "\239"
|
||||
},
|
||||
[209] = {
|
||||
[128] = "\240",
|
||||
[129] = "\241",
|
||||
[130] = "\242",
|
||||
[131] = "\243",
|
||||
[132] = "\244",
|
||||
[133] = "\245",
|
||||
[134] = "\246",
|
||||
[135] = "\247",
|
||||
[136] = "\248",
|
||||
[137] = "\249",
|
||||
[138] = "\250",
|
||||
[139] = "\251",
|
||||
[140] = "\252",
|
||||
[141] = "\253",
|
||||
[142] = "\254",
|
||||
[143] = "\255",
|
||||
[144] = "\161",
|
||||
[145] = "\184",
|
||||
[146] = "\144",
|
||||
[147] = "\131",
|
||||
[148] = "\186",
|
||||
[149] = "\190",
|
||||
[150] = "\179",
|
||||
[151] = "\191",
|
||||
[152] = "\188",
|
||||
[153] = "\154",
|
||||
[154] = "\156",
|
||||
[155] = "\158",
|
||||
[156] = "\157",
|
||||
[158] = "\162",
|
||||
[159] = "\159"
|
||||
},
|
||||
[210] = {[144] = "\165", [145] = "\180"}
|
||||
[128] = {
|
||||
[147] = "\150",
|
||||
[148] = "\151",
|
||||
[152] = "\145",
|
||||
[153] = "\146",
|
||||
[154] = "\130",
|
||||
[156] = "\147",
|
||||
[157] = "\148",
|
||||
[158] = "\132",
|
||||
[160] = "\134",
|
||||
[161] = "\135",
|
||||
[162] = "\149",
|
||||
[166] = "\133",
|
||||
[176] = "\137",
|
||||
[185] = "\139",
|
||||
[186] = "\155"
|
||||
},
|
||||
[130] = {[172] = "\136"},
|
||||
[132] = {[150] = "\185", [162] = "\153"},
|
||||
[194] = {
|
||||
[152] = "\152",
|
||||
[160] = "\160",
|
||||
[164] = "\164",
|
||||
[166] = "\166",
|
||||
[167] = "\167",
|
||||
[169] = "\169",
|
||||
[171] = "\171",
|
||||
[172] = "\172",
|
||||
[173] = "\173",
|
||||
[174] = "\174",
|
||||
[176] = "\176",
|
||||
[177] = "\177",
|
||||
[181] = "\181",
|
||||
[182] = "\182",
|
||||
[183] = "\183",
|
||||
[187] = "\187"
|
||||
},
|
||||
[208] = {
|
||||
[129] = "\168",
|
||||
[130] = "\128",
|
||||
[131] = "\129",
|
||||
[132] = "\170",
|
||||
[133] = "\189",
|
||||
[134] = "\178",
|
||||
[135] = "\175",
|
||||
[136] = "\163",
|
||||
[137] = "\138",
|
||||
[138] = "\140",
|
||||
[139] = "\142",
|
||||
[140] = "\141",
|
||||
[143] = "\143",
|
||||
[144] = "\192",
|
||||
[145] = "\193",
|
||||
[146] = "\194",
|
||||
[147] = "\195",
|
||||
[148] = "\196",
|
||||
[149] = "\197",
|
||||
[150] = "\198",
|
||||
[151] = "\199",
|
||||
[152] = "\200",
|
||||
[153] = "\201",
|
||||
[154] = "\202",
|
||||
[155] = "\203",
|
||||
[156] = "\204",
|
||||
[157] = "\205",
|
||||
[158] = "\206",
|
||||
[159] = "\207",
|
||||
[160] = "\208",
|
||||
[161] = "\209",
|
||||
[162] = "\210",
|
||||
[163] = "\211",
|
||||
[164] = "\212",
|
||||
[165] = "\213",
|
||||
[166] = "\214",
|
||||
[167] = "\215",
|
||||
[168] = "\216",
|
||||
[169] = "\217",
|
||||
[170] = "\218",
|
||||
[171] = "\219",
|
||||
[172] = "\220",
|
||||
[173] = "\221",
|
||||
[174] = "\222",
|
||||
[175] = "\223",
|
||||
[176] = "\224",
|
||||
[177] = "\225",
|
||||
[178] = "\226",
|
||||
[179] = "\227",
|
||||
[180] = "\228",
|
||||
[181] = "\229",
|
||||
[182] = "\230",
|
||||
[183] = "\231",
|
||||
[184] = "\232",
|
||||
[185] = "\233",
|
||||
[186] = "\234",
|
||||
[187] = "\235",
|
||||
[188] = "\236",
|
||||
[189] = "\237",
|
||||
[190] = "\238",
|
||||
[191] = "\239"
|
||||
},
|
||||
[209] = {
|
||||
[128] = "\240",
|
||||
[129] = "\241",
|
||||
[130] = "\242",
|
||||
[131] = "\243",
|
||||
[132] = "\244",
|
||||
[133] = "\245",
|
||||
[134] = "\246",
|
||||
[135] = "\247",
|
||||
[136] = "\248",
|
||||
[137] = "\249",
|
||||
[138] = "\250",
|
||||
[139] = "\251",
|
||||
[140] = "\252",
|
||||
[141] = "\253",
|
||||
[142] = "\254",
|
||||
[143] = "\255",
|
||||
[144] = "\161",
|
||||
[145] = "\184",
|
||||
[146] = "\144",
|
||||
[147] = "\131",
|
||||
[148] = "\186",
|
||||
[149] = "\190",
|
||||
[150] = "\179",
|
||||
[151] = "\191",
|
||||
[152] = "\188",
|
||||
[153] = "\154",
|
||||
[154] = "\156",
|
||||
[155] = "\158",
|
||||
[156] = "\157",
|
||||
[158] = "\162",
|
||||
[159] = "\159"
|
||||
},
|
||||
[210] = {[144] = "\165", [145] = "\180"}
|
||||
}
|
||||
|
||||
local nmdc = {
|
||||
[36] = "$",
|
||||
[124] = "|"
|
||||
[36] = "$",
|
||||
[124] = "|"
|
||||
}
|
||||
|
||||
function AnsiToUtf8(s)
|
||||
local r, b = ""
|
||||
for i = 1, s and s:len() or 0 do
|
||||
b = s:byte(i)
|
||||
if b < 128 then
|
||||
r = r .. string.char(b)
|
||||
else
|
||||
if b > 239 then
|
||||
r = r .. "\209" .. string.char(b - 112)
|
||||
elseif b > 191 then
|
||||
r = r .. "\208" .. string.char(b - 48)
|
||||
elseif ansi_decode[b] then
|
||||
r = r .. ansi_decode[b]
|
||||
else
|
||||
r = r .. "_"
|
||||
end
|
||||
end
|
||||
end
|
||||
return r
|
||||
local r, b = ""
|
||||
for i = 1, s and s:len() or 0 do
|
||||
b = s:byte(i)
|
||||
if b < 128 then
|
||||
r = r .. string.char(b)
|
||||
else
|
||||
if b > 239 then
|
||||
r = r .. "\209" .. string.char(b - 112)
|
||||
elseif b > 191 then
|
||||
r = r .. "\208" .. string.char(b - 48)
|
||||
elseif ansi_decode[b] then
|
||||
r = r .. ansi_decode[b]
|
||||
else
|
||||
r = r .. "_"
|
||||
end
|
||||
end
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
function Utf8ToAnsi(s)
|
||||
local a, j, r, b = 0, 0, ""
|
||||
for i = 1, s and s:len() or 0 do
|
||||
b = s:byte(i)
|
||||
if b < 128 then
|
||||
if nmdc[b] then
|
||||
r = r .. nmdc[b]
|
||||
else
|
||||
r = r .. string.char(b)
|
||||
end
|
||||
elseif a == 2 then
|
||||
a, j = a - 1, b
|
||||
elseif a == 1 then
|
||||
--if j == nil or b == nil then return r end
|
||||
--print(j)
|
||||
--print(b)
|
||||
--local ansi = utf8_decode[j]
|
||||
--if ansi == nil then return r end
|
||||
--if ansi[b] == nil then return r end
|
||||
if utf8_decode[j] then
|
||||
if utf8_decode[j][b] then
|
||||
a, r = a - 1, r .. utf8_decode[j][b]
|
||||
end
|
||||
end
|
||||
elseif b == 226 then
|
||||
a = 2
|
||||
elseif b == 194 or b == 208 or b == 209 or b == 210 then
|
||||
j, a = b, 1
|
||||
else
|
||||
r = r .. "_"
|
||||
end
|
||||
end
|
||||
return r
|
||||
local a, j, r, b = 0, 0, ""
|
||||
for i = 1, s and s:len() or 0 do
|
||||
b = s:byte(i)
|
||||
if b < 128 then
|
||||
if nmdc[b] then
|
||||
r = r .. nmdc[b]
|
||||
else
|
||||
r = r .. string.char(b)
|
||||
end
|
||||
elseif a == 2 then
|
||||
a, j = a - 1, b
|
||||
elseif a == 1 then
|
||||
--if j == nil or b == nil then return r end
|
||||
--print(j)
|
||||
--print(b)
|
||||
--local ansi = utf8_decode[j]
|
||||
--if ansi == nil then return r end
|
||||
--if ansi[b] == nil then return r end
|
||||
if utf8_decode[j] then
|
||||
if utf8_decode[j][b] then
|
||||
a, r = a - 1, r .. utf8_decode[j][b]
|
||||
end
|
||||
end
|
||||
elseif b == 226 then
|
||||
a = 2
|
||||
elseif b == 194 or b == 208 or b == 209 or b == 210 then
|
||||
j, a = b, 1
|
||||
else
|
||||
r = r .. "_"
|
||||
end
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
@ -6,40 +6,40 @@
|
||||
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
|
||||
|
||||
local function format(str, ...)
|
||||
local args = { ... }
|
||||
local function repl(escape, open, num, close)
|
||||
if escape == "" then
|
||||
local replacement = tostring(args[tonumber(num)])
|
||||
if open == "" then
|
||||
replacement = replacement..close
|
||||
end
|
||||
return replacement
|
||||
else
|
||||
return "@"..open..num..close
|
||||
end
|
||||
end
|
||||
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||
local args = { ... }
|
||||
local function repl(escape, open, num, close)
|
||||
if escape == "" then
|
||||
local replacement = tostring(args[tonumber(num)])
|
||||
if open == "" then
|
||||
replacement = replacement..close
|
||||
end
|
||||
return replacement
|
||||
else
|
||||
return "@"..open..num..close
|
||||
end
|
||||
end
|
||||
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||
end
|
||||
|
||||
local gettext, ngettext
|
||||
if minetest.get_modpath("intllib") then
|
||||
if intllib.make_gettext_pair then
|
||||
-- New method using gettext.
|
||||
gettext, ngettext = intllib.make_gettext_pair()
|
||||
else
|
||||
-- Old method using text files.
|
||||
gettext = intllib.Getter()
|
||||
end
|
||||
if intllib.make_gettext_pair then
|
||||
-- New method using gettext.
|
||||
gettext, ngettext = intllib.make_gettext_pair()
|
||||
else
|
||||
-- Old method using text files.
|
||||
gettext = intllib.Getter()
|
||||
end
|
||||
end
|
||||
|
||||
-- Fill in missing functions.
|
||||
|
||||
gettext = gettext or function(msgid, ...)
|
||||
return format(msgid, ...)
|
||||
return format(msgid, ...)
|
||||
end
|
||||
|
||||
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
|
||||
return format(n==1 and msgid or msgid_plural, ...)
|
||||
return format(n==1 and msgid or msgid_plural, ...)
|
||||
end
|
||||
|
||||
return gettext, ngettext
|
||||
|
@ -1,29 +1,29 @@
|
||||
-- Definitions for standard minetest_game wooden and steel wall signs
|
||||
|
||||
signs_lib.register_sign("sign:sign", {
|
||||
description = "Sign",
|
||||
inventory_image = "signs_lib_sign_wall_wooden_inv.png",
|
||||
tiles = {
|
||||
"signs_lib_sign_wall_wooden.png",
|
||||
"signs_lib_sign_wall_wooden_edges.png",
|
||||
-- items 3 - 5 are not set, so signs_lib will use its standard pole
|
||||
-- mount, hanging, and yard sign stick textures.
|
||||
},
|
||||
entity_info = "standard",
|
||||
allow_hanging = true,
|
||||
allow_widefont = true,
|
||||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true
|
||||
description = "Sign",
|
||||
inventory_image = "signs_lib_sign_wall_wooden_inv.png",
|
||||
tiles = {
|
||||
"signs_lib_sign_wall_wooden.png",
|
||||
"signs_lib_sign_wall_wooden_edges.png",
|
||||
-- items 3 - 5 are not set, so signs_lib will use its standard pole
|
||||
-- mount, hanging, and yard sign stick textures.
|
||||
},
|
||||
entity_info = "standard",
|
||||
allow_hanging = true,
|
||||
allow_widefont = true,
|
||||
allow_onpole = true,
|
||||
allow_onpole_horizontal = true,
|
||||
allow_yard = true
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "sign:sign 3",
|
||||
recipe = {
|
||||
{"main:wood","main:wood","main:wood"},
|
||||
{"main:wood","main:wood","main:wood"},
|
||||
{"","main:stick",""}
|
||||
}
|
||||
output = "sign:sign 3",
|
||||
recipe = {
|
||||
{"main:wood","main:wood","main:wood"},
|
||||
{"main:wood","main:wood","main:wood"},
|
||||
{"","main:stick",""}
|
||||
}
|
||||
})
|
||||
|
||||
--[[
|
||||
|
@ -1,234 +1,234 @@
|
||||
--here is where tnt is defined
|
||||
|
||||
local function tnt(pos,range)
|
||||
local pos = vector.floor(vector.add(pos,0.5))
|
||||
|
||||
--throw players and items
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, range)) do
|
||||
if object:is_player() then
|
||||
local ppos = object:getpos()
|
||||
local power = (range - vector.distance(pos,ppos))*2
|
||||
local distance = vector.subtract(ppos,pos)
|
||||
local force = vector.multiply(distance,power)
|
||||
object:add_player_velocity(force)
|
||||
elseif object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||
local ppos = object:getpos()
|
||||
local power = (range - vector.distance(pos,ppos))*2
|
||||
local distance = vector.subtract(pos,ppos)
|
||||
local force = vector.multiply(distance,power)
|
||||
object:setvelocity(force)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local min = vector.add(pos,range)
|
||||
local max = vector.subtract(pos,range)
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local emin, emax = vm:read_from_map(min,max)
|
||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
local air = minetest.get_content_id("air")
|
||||
local content_id = minetest.get_name_from_content_id
|
||||
|
||||
local pos2 = vector.new(0,0,0)
|
||||
|
||||
for x=-range, range do
|
||||
for y=-range, range do
|
||||
for z=-range, range do
|
||||
if vector.distance(pos2, vector.new(x,y,z)) <= range then
|
||||
local p_pos = area:index(pos.x+x,pos.y+y,pos.z+z)
|
||||
local n = content_id(data[p_pos])
|
||||
if n == "tnt:tnt" then
|
||||
--print("adding tnt")
|
||||
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})
|
||||
elseif n ~= "air" and n ~= "ignore" then
|
||||
if math.random()>0.99 then
|
||||
local item = minetest.get_node_drops(n, "main:diamondpick")[1]
|
||||
minetest.add_item(vector.new(pos.x+x,pos.y+y,pos.z+z), item)
|
||||
end
|
||||
end
|
||||
|
||||
data[p_pos] = air
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
|
||||
minetest.sound_play("tnt_explode", {pos = pos, gain = 1.0, max_hear_distance = range*range*range})
|
||||
|
||||
--stop client from lagging
|
||||
local particle = range
|
||||
if particle > 15 then
|
||||
particle = 15
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = particle*particle*particle,
|
||||
time = 0.001,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = vector.new(-range,-range,-range),
|
||||
maxvel = vector.new(range,range,range),
|
||||
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 pos = vector.floor(vector.add(pos,0.5))
|
||||
|
||||
--throw players and items
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, range)) do
|
||||
if object:is_player() then
|
||||
local ppos = object:getpos()
|
||||
local power = (range - vector.distance(pos,ppos))*2
|
||||
local distance = vector.subtract(ppos,pos)
|
||||
local force = vector.multiply(distance,power)
|
||||
object:add_player_velocity(force)
|
||||
elseif object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||
local ppos = object:getpos()
|
||||
local power = (range - vector.distance(pos,ppos))*2
|
||||
local distance = vector.subtract(pos,ppos)
|
||||
local force = vector.multiply(distance,power)
|
||||
object:setvelocity(force)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local min = vector.add(pos,range)
|
||||
local max = vector.subtract(pos,range)
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local emin, emax = vm:read_from_map(min,max)
|
||||
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
|
||||
local data = vm:get_data()
|
||||
|
||||
local air = minetest.get_content_id("air")
|
||||
local content_id = minetest.get_name_from_content_id
|
||||
|
||||
local pos2 = vector.new(0,0,0)
|
||||
|
||||
for x=-range, range do
|
||||
for y=-range, range do
|
||||
for z=-range, range do
|
||||
if vector.distance(pos2, vector.new(x,y,z)) <= range then
|
||||
local p_pos = area:index(pos.x+x,pos.y+y,pos.z+z)
|
||||
local n = content_id(data[p_pos])
|
||||
if n == "tnt:tnt" then
|
||||
--print("adding tnt")
|
||||
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})
|
||||
elseif n ~= "air" and n ~= "ignore" then
|
||||
if math.random()>0.99 then
|
||||
local item = minetest.get_node_drops(n, "main:diamondpick")[1]
|
||||
minetest.add_item(vector.new(pos.x+x,pos.y+y,pos.z+z), item)
|
||||
end
|
||||
end
|
||||
|
||||
data[p_pos] = air
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
vm:update_map()
|
||||
|
||||
minetest.sound_play("tnt_explode", {pos = pos, gain = 1.0, max_hear_distance = range*range*range})
|
||||
|
||||
--stop client from lagging
|
||||
local particle = range
|
||||
if particle > 15 then
|
||||
particle = 15
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = particle*particle*particle,
|
||||
time = 0.001,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = vector.new(-range,-range,-range),
|
||||
maxvel = vector.new(range,range,range),
|
||||
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",
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
minetest.register_entity("tnt:tnt", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "cube",
|
||||
visual_size = {x = 1, y = 1},
|
||||
textures = {"tnt_top.png", "tnt_bottom.png",
|
||||
"tnt_side.png", "tnt_side.png",
|
||||
"tnt_side.png", "tnt_side.png"},
|
||||
is_visible = true,
|
||||
pointable = true,
|
||||
},
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "cube",
|
||||
visual_size = {x = 1, y = 1},
|
||||
textures = {"tnt_top.png", "tnt_bottom.png",
|
||||
"tnt_side.png", "tnt_side.png",
|
||||
"tnt_side.png", "tnt_side.png"},
|
||||
is_visible = true,
|
||||
pointable = true,
|
||||
},
|
||||
|
||||
timer = 5,
|
||||
range = 7,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
range = self.range,
|
||||
timer = self.timer,
|
||||
})
|
||||
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.timer = data.timer
|
||||
end
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = 50,
|
||||
time = 0,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = vector.new(-0.5,1,-0.5),
|
||||
maxvel = vector.new(0.5,5,0.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",
|
||||
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_item(self.object:getpos(), "tnt:tnt")
|
||||
self.object:remove()
|
||||
end,
|
||||
timer = 5,
|
||||
range = 7,
|
||||
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
range = self.range,
|
||||
timer = self.timer,
|
||||
})
|
||||
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.timer = data.timer
|
||||
end
|
||||
end
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = 50,
|
||||
time = 0,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = vector.new(-0.5,1,-0.5),
|
||||
maxvel = vector.new(0.5,5,0.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",
|
||||
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_item(self.object:getpos(), "tnt:tnt")
|
||||
self.object:remove()
|
||||
end,
|
||||
|
||||
sound_played = false,
|
||||
on_step = function(self, dtime)
|
||||
self.timer = self.timer - dtime
|
||||
local vel = self.object:getvelocity()
|
||||
vel = vector.multiply(vel,-0.05)
|
||||
self.object:add_velocity(vector.new(vel.x,0,vel.z))
|
||||
|
||||
if self.timer <= 0 then
|
||||
local pos = self.object:getpos()
|
||||
if not self.range then
|
||||
self.range = 7
|
||||
end
|
||||
tnt(pos,self.range)
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
sound_played = false,
|
||||
on_step = function(self, dtime)
|
||||
self.timer = self.timer - dtime
|
||||
local vel = self.object:getvelocity()
|
||||
vel = vector.multiply(vel,-0.05)
|
||||
self.object:add_velocity(vector.new(vel.x,0,vel.z))
|
||||
|
||||
if self.timer <= 0 then
|
||||
local pos = self.object:getpos()
|
||||
if not self.range then
|
||||
self.range = 7
|
||||
end
|
||||
tnt(pos,self.range)
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("tnt:tnt", {
|
||||
description = "Cobblestone",
|
||||
tiles = {"tnt_top.png", "tnt_bottom.png",
|
||||
"tnt_side.png", "tnt_side.png",
|
||||
"tnt_side.png", "tnt_side.png"},
|
||||
"tnt_side.png", "tnt_side.png",
|
||||
"tnt_side.png", "tnt_side.png"},
|
||||
groups = {stone = 2, hard = 1, pickaxe = 2, hand = 4},
|
||||
sounds = main.stoneSound(),
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
local obj = minetest.add_entity(pos,"tnt:tnt")
|
||||
local range = 7
|
||||
obj:get_luaentity().range = range
|
||||
minetest.remove_node(pos)
|
||||
local obj = minetest.add_entity(pos,"tnt:tnt")
|
||||
local range = 7
|
||||
obj:get_luaentity().range = range
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:uranium_tnt", {
|
||||
description = "Cobblestone",
|
||||
tiles = {"tnt_top.png^[colorize:green:100", "tnt_bottom.png^[colorize:green:100",
|
||||
"tnt_side.png^[colorize:green:100", "tnt_side.png^[colorize:green:100",
|
||||
"tnt_side.png^[colorize:green:100", "tnt_side.png^[colorize:green:100"},
|
||||
"tnt_side.png^[colorize:green:100", "tnt_side.png^[colorize:green:100",
|
||||
"tnt_side.png^[colorize:green:100", "tnt_side.png^[colorize:green:100"},
|
||||
groups = {stone = 2, hard = 1, pickaxe = 2, hand = 4},
|
||||
sounds = main.stoneSound(),
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
local obj = minetest.add_entity(pos,"tnt:tnt")
|
||||
local range = 145
|
||||
obj:get_luaentity().range = range
|
||||
minetest.remove_node(pos)
|
||||
local obj = minetest.add_entity(pos,"tnt:tnt")
|
||||
local range = 145
|
||||
obj:get_luaentity().range = range
|
||||
minetest.remove_node(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("tnt:uh_oh", {
|
||||
description = "Cobblestone",
|
||||
tiles = {"tnt_top.png", "tnt_bottom.png",
|
||||
"tnt_side.png", "tnt_side.png",
|
||||
"tnt_side.png", "tnt_side.png"},
|
||||
"tnt_side.png", "tnt_side.png",
|
||||
"tnt_side.png", "tnt_side.png"},
|
||||
groups = {stone = 2, hard = 1, pickaxe = 2, hand = 4},
|
||||
sounds = main.stoneSound(),
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
local range = 10
|
||||
for x=-range, range do
|
||||
for y=-range, range do
|
||||
for z=-range, range do
|
||||
minetest.add_node(vector.new(pos.x+x,pos.y+y,pos.z+z),{name="tnt:tnt"})
|
||||
end
|
||||
end
|
||||
end
|
||||
local range = 10
|
||||
for x=-range, range do
|
||||
for y=-range, range do
|
||||
for z=-range, range do
|
||||
minetest.add_node(vector.new(pos.x+x,pos.y+y,pos.z+z),{name="tnt:tnt"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "tnt:tnt",
|
||||
recipe = {
|
||||
{"main:wood", "main:wood", "main:wood"},
|
||||
{"main:wood", "main:coal", "main:wood"},
|
||||
{"main:wood", "main:wood", "main:wood"},
|
||||
},
|
||||
output = "tnt:tnt",
|
||||
recipe = {
|
||||
{"main:wood", "main:wood", "main:wood"},
|
||||
{"main:wood", "main:coal", "main:wood"},
|
||||
{"main:wood", "main:wood", "main:wood"},
|
||||
},
|
||||
})
|
||||
|
@ -3,183 +3,183 @@ local check_radius = 10
|
||||
|
||||
--get point where particle spawner is added
|
||||
local function get_offset(wdir)
|
||||
local z = 0
|
||||
local x = 0
|
||||
if wdir == 4 then
|
||||
z = 0.25
|
||||
elseif wdir == 2 then
|
||||
x = 0.25
|
||||
elseif wdir == 5 then
|
||||
z = -0.25
|
||||
elseif wdir == 3 then
|
||||
x = -0.25
|
||||
end
|
||||
return {x = x, y = 0.27, z = z}
|
||||
local z = 0
|
||||
local x = 0
|
||||
if wdir == 4 then
|
||||
z = 0.25
|
||||
elseif wdir == 2 then
|
||||
x = 0.25
|
||||
elseif wdir == 5 then
|
||||
z = -0.25
|
||||
elseif wdir == 3 then
|
||||
x = -0.25
|
||||
end
|
||||
return {x = x, y = 0.27, z = z}
|
||||
end
|
||||
--add in smoke and fire
|
||||
local function create_ps(pos)
|
||||
print("test")
|
||||
local dir = get_offset(minetest.get_node(pos).param2)
|
||||
local ppos = vector.add(dir,pos)
|
||||
minetest.add_particle({
|
||||
pos = ppos,
|
||||
velocity = vector.new(0,0,0),
|
||||
acceleration = vector.new(0,0,0),
|
||||
expirationtime = particle_time*3,
|
||||
size = 3,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "torch_animated.png",
|
||||
animation = {type = "vertical_frames",
|
||||
print("test")
|
||||
local dir = get_offset(minetest.get_node(pos).param2)
|
||||
local ppos = vector.add(dir,pos)
|
||||
minetest.add_particle({
|
||||
pos = ppos,
|
||||
velocity = vector.new(0,0,0),
|
||||
acceleration = vector.new(0,0,0),
|
||||
expirationtime = particle_time*3,
|
||||
size = 3,
|
||||
collisiondetection = false,
|
||||
vertical = true,
|
||||
texture = "torch_animated.png",
|
||||
animation = {type = "vertical_frames",
|
||||
|
||||
aspect_w = 16,
|
||||
-- Width of a frame in pixels
|
||||
aspect_w = 16,
|
||||
-- Width of a frame in pixels
|
||||
|
||||
aspect_h = 16,
|
||||
-- Height of a frame in pixels
|
||||
aspect_h = 16,
|
||||
-- Height of a frame in pixels
|
||||
|
||||
length = 0.2,
|
||||
-- Full loop length
|
||||
},
|
||||
})
|
||||
--[[
|
||||
minetest.add_particlespawner({
|
||||
amount = particle_time*6,
|
||||
time = particle_time*2,
|
||||
minpos = ppos,
|
||||
maxpos = ppos,
|
||||
minvel = vector.new(-0.1,0.1,-0.1),
|
||||
maxvel = vector.new(0.1,0.3,0.1),
|
||||
minacc = vector.new(0,0,0),
|
||||
maxacc = vector.new(0,0,0),
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "smoke.png",
|
||||
})
|
||||
]]--
|
||||
length = 0.2,
|
||||
-- Full loop length
|
||||
},
|
||||
})
|
||||
--[[
|
||||
minetest.add_particlespawner({
|
||||
amount = particle_time*6,
|
||||
time = particle_time*2,
|
||||
minpos = ppos,
|
||||
maxpos = ppos,
|
||||
minvel = vector.new(-0.1,0.1,-0.1),
|
||||
maxvel = vector.new(0.1,0.3,0.1),
|
||||
minacc = vector.new(0,0,0),
|
||||
maxacc = vector.new(0,0,0),
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "smoke.png",
|
||||
})
|
||||
]]--
|
||||
end
|
||||
|
||||
|
||||
--reload smoke and flame on load
|
||||
--[[
|
||||
minetest.register_abm({
|
||||
label = "Torch Particle",
|
||||
nodenames = {"group:torch"},
|
||||
neighbors = {"air"},
|
||||
interval = particle_time,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local found_player = false
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, check_radius)) do
|
||||
local pos2 = object:getpos()
|
||||
if object:is_player() then
|
||||
found_player = true
|
||||
end
|
||||
end
|
||||
if found_player == true then
|
||||
create_ps(pos)
|
||||
end
|
||||
end,
|
||||
label = "Torch Particle",
|
||||
nodenames = {"group:torch"},
|
||||
neighbors = {"air"},
|
||||
interval = particle_time,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local found_player = false
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, check_radius)) do
|
||||
local pos2 = object:getpos()
|
||||
if object:is_player() then
|
||||
found_player = true
|
||||
end
|
||||
end
|
||||
if found_player == true then
|
||||
create_ps(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
]]--
|
||||
|
||||
-- Item definitions
|
||||
minetest.register_craftitem("torch:torch", {
|
||||
description = "Torch",
|
||||
inventory_image = "torches_torch.png",
|
||||
wield_image = "torches_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
liquids_pointable = false,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
description = "Torch",
|
||||
inventory_image = "torches_torch.png",
|
||||
wield_image = "torches_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
liquids_pointable = false,
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
|
||||
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
if wdir < 1 then
|
||||
return itemstack
|
||||
elseif wdir == 1 then
|
||||
retval = fakestack:set_name("torch:floor")
|
||||
else
|
||||
retval = fakestack:set_name("torch:wall")
|
||||
end
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
itemstack:set_name("torch:torch")
|
||||
local fakestack = itemstack
|
||||
local retval = false
|
||||
if wdir < 1 then
|
||||
return itemstack
|
||||
elseif wdir == 1 then
|
||||
retval = fakestack:set_name("torch:floor")
|
||||
else
|
||||
retval = fakestack:set_name("torch:wall")
|
||||
end
|
||||
if not retval then
|
||||
return itemstack
|
||||
end
|
||||
itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
|
||||
itemstack:set_name("torch:torch")
|
||||
|
||||
if retval then
|
||||
minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
if retval then
|
||||
minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("torch:floor", {
|
||||
inventory_image = "default_torch.png",
|
||||
wield_image = "torches_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 2/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_floor.obj",
|
||||
tiles = {"torches_torch.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "none",
|
||||
sunlight_propagates = true,
|
||||
drop = "torch:torch",
|
||||
walkable = false,
|
||||
light_source = 13,
|
||||
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
|
||||
legacy_wallmounted = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
|
||||
},
|
||||
sounds = main.woodSound(),
|
||||
inventory_image = "default_torch.png",
|
||||
wield_image = "torches_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 2/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_floor.obj",
|
||||
tiles = {"torches_torch.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "none",
|
||||
sunlight_propagates = true,
|
||||
drop = "torch:torch",
|
||||
walkable = false,
|
||||
light_source = 13,
|
||||
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
|
||||
legacy_wallmounted = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
|
||||
},
|
||||
sounds = main.woodSound(),
|
||||
})
|
||||
|
||||
minetest.register_node("torch:wall", {
|
||||
inventory_image = "default_torch.png",
|
||||
wield_image = "torches_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_wall.obj",
|
||||
tiles = {"torches_torch.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 13,
|
||||
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
|
||||
drop = "torch:torch",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
|
||||
wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
|
||||
wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
|
||||
},
|
||||
sounds = main.woodSound(),
|
||||
inventory_image = "default_torch.png",
|
||||
wield_image = "torches_torch.png",
|
||||
wield_scale = {x = 1, y = 1, z = 1 + 1/16},
|
||||
drawtype = "mesh",
|
||||
mesh = "torch_wall.obj",
|
||||
tiles = {"torches_torch.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
light_source = 13,
|
||||
groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
|
||||
drop = "torch:torch",
|
||||
selection_box = {
|
||||
type = "wallmounted",
|
||||
wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
|
||||
wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
|
||||
wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
|
||||
},
|
||||
sounds = main.woodSound(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "torch:torch 4",
|
||||
recipe = {
|
||||
{"main:coal"},
|
||||
{"main:stick"}
|
||||
}
|
||||
output = "torch:torch 4",
|
||||
recipe = {
|
||||
{"main:coal"},
|
||||
{"main:stick"}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "torch:torch 4",
|
||||
recipe = {
|
||||
{"main:charcoal"},
|
||||
{"main:stick"}
|
||||
}
|
||||
output = "torch:torch 4",
|
||||
recipe = {
|
||||
{"main:charcoal"},
|
||||
{"main:stick"}
|
||||
}
|
||||
})
|
||||
|
@ -4,90 +4,90 @@ local dropper = {"main:leaves","main:stick","main:apple"}
|
||||
|
||||
-- Leafdecay
|
||||
local function leafdecay_after_destruct(pos, oldnode, def)
|
||||
for _, v in pairs(minetest.find_nodes_in_area(vector.subtract(pos, def.radius),
|
||||
vector.add(pos, def.radius), def.leaves)) do
|
||||
local node = minetest.get_node(v)
|
||||
local timer = minetest.get_node_timer(v)
|
||||
if node.param2 ~= 1 and not timer:is_started() then
|
||||
timer:start((math.random()+math.random())*math.random())
|
||||
end
|
||||
end
|
||||
for _, v in pairs(minetest.find_nodes_in_area(vector.subtract(pos, def.radius),
|
||||
vector.add(pos, def.radius), def.leaves)) do
|
||||
local node = minetest.get_node(v)
|
||||
local timer = minetest.get_node_timer(v)
|
||||
if node.param2 ~= 1 and not timer:is_started() then
|
||||
timer:start((math.random()+math.random())*math.random())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function leafdecay_on_timer(pos, def)
|
||||
if minetest.find_node_near(pos, def.radius, def.trunks) then
|
||||
return false
|
||||
end
|
||||
if minetest.find_node_near(pos, def.radius, def.trunks) then
|
||||
return false
|
||||
end
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
local drops = minetest.get_node_drops(node.name)
|
||||
for _, item in ipairs(drops) do
|
||||
local is_leaf
|
||||
for _, v in pairs(def.leaves) do
|
||||
if v == item then
|
||||
is_leaf = true
|
||||
end
|
||||
end
|
||||
if minetest.get_item_group(item, "leafdecay_drop") ~= 0 or
|
||||
not is_leaf then
|
||||
minetest.add_item({
|
||||
x = pos.x - 0.5 + math.random(),
|
||||
y = pos.y - 0.5 + math.random(),
|
||||
z = pos.z - 0.5 + math.random(),
|
||||
}, item)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.remove_node(pos)
|
||||
minetest.check_for_falling(pos)
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = 10,
|
||||
time = 0.0001,
|
||||
minpos = {x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5},
|
||||
maxpos = {x=pos.x+0.5, y=pos.y+0.5, z=pos.z+0.5},
|
||||
minvel = vector.new(-0.5,0,-0.5),
|
||||
maxvel = vector.new(0.5,0,0.5),
|
||||
minacc = {x=0, y=-9.81, z=0},
|
||||
maxacc = {x=0, y=-9.81, z=0},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1.5,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = true,
|
||||
vertical = false,
|
||||
texture = "treecapitator.png"
|
||||
})
|
||||
minetest.sound_play("leaves", {pos=pos, gain = 0.2, max_hear_distance = 60,pitch = math.random(70,100)/100})
|
||||
--random drops
|
||||
if math.random() > 0.75 then
|
||||
local obj = minetest.add_item(pos,dropper[math.random(1,3)])
|
||||
end
|
||||
local node = minetest.get_node(pos)
|
||||
local drops = minetest.get_node_drops(node.name)
|
||||
for _, item in ipairs(drops) do
|
||||
local is_leaf
|
||||
for _, v in pairs(def.leaves) do
|
||||
if v == item then
|
||||
is_leaf = true
|
||||
end
|
||||
end
|
||||
if minetest.get_item_group(item, "leafdecay_drop") ~= 0 or
|
||||
not is_leaf then
|
||||
minetest.add_item({
|
||||
x = pos.x - 0.5 + math.random(),
|
||||
y = pos.y - 0.5 + math.random(),
|
||||
z = pos.z - 0.5 + math.random(),
|
||||
}, item)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.remove_node(pos)
|
||||
minetest.check_for_falling(pos)
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = 10,
|
||||
time = 0.0001,
|
||||
minpos = {x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5},
|
||||
maxpos = {x=pos.x+0.5, y=pos.y+0.5, z=pos.z+0.5},
|
||||
minvel = vector.new(-0.5,0,-0.5),
|
||||
maxvel = vector.new(0.5,0,0.5),
|
||||
minacc = {x=0, y=-9.81, z=0},
|
||||
maxacc = {x=0, y=-9.81, z=0},
|
||||
minexptime = 0.5,
|
||||
maxexptime = 1.5,
|
||||
minsize = 1,
|
||||
maxsize = 2,
|
||||
collisiondetection = true,
|
||||
vertical = false,
|
||||
texture = "treecapitator.png"
|
||||
})
|
||||
minetest.sound_play("leaves", {pos=pos, gain = 0.2, max_hear_distance = 60,pitch = math.random(70,100)/100})
|
||||
--random drops
|
||||
if math.random() > 0.75 then
|
||||
local obj = minetest.add_item(pos,dropper[math.random(1,3)])
|
||||
end
|
||||
end
|
||||
|
||||
function treecaptitator.register_leafdecay(def)
|
||||
assert(def.leaves)
|
||||
assert(def.trunks)
|
||||
assert(def.radius)
|
||||
for _, v in pairs(def.trunks) do
|
||||
minetest.override_item(v, {
|
||||
after_destruct = function(pos, oldnode)
|
||||
leafdecay_after_destruct(pos, oldnode, def)
|
||||
end,
|
||||
})
|
||||
end
|
||||
for _, v in pairs(def.leaves) do
|
||||
minetest.override_item(v, {
|
||||
on_timer = function(pos)
|
||||
leafdecay_on_timer(pos, def)
|
||||
end,
|
||||
})
|
||||
end
|
||||
assert(def.leaves)
|
||||
assert(def.trunks)
|
||||
assert(def.radius)
|
||||
for _, v in pairs(def.trunks) do
|
||||
minetest.override_item(v, {
|
||||
after_destruct = function(pos, oldnode)
|
||||
leafdecay_after_destruct(pos, oldnode, def)
|
||||
end,
|
||||
})
|
||||
end
|
||||
for _, v in pairs(def.leaves) do
|
||||
minetest.override_item(v, {
|
||||
on_timer = function(pos)
|
||||
leafdecay_on_timer(pos, def)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------- registration
|
||||
treecaptitator.register_leafdecay({
|
||||
trunks = {"main:tree"},
|
||||
leaves = {"main:leaves"},
|
||||
radius = 2,
|
||||
trunks = {"main:tree"},
|
||||
leaves = {"main:leaves"},
|
||||
radius = 2,
|
||||
})
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,12 @@ function joinplayer (player)
|
||||
hud_elem_type = "image",
|
||||
position = {x = 0.5, y = 0.5},
|
||||
scale = {
|
||||
x = -100,
|
||||
y = -100
|
||||
x = -100,
|
||||
y = -100
|
||||
},
|
||||
text = "vignette.png"
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(joinplayer)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user