mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 20:41:11 +01:00
Merge branch 'master' into buckets
This commit is contained in:
commit
0119793d7a
87 changed files with 960 additions and 1142 deletions
|
@ -47,6 +47,9 @@ read_globals = {
|
||||||
--GENERAL
|
--GENERAL
|
||||||
"default",
|
"default",
|
||||||
|
|
||||||
|
--ENTITIES
|
||||||
|
"cmi",
|
||||||
|
|
||||||
--HUD
|
--HUD
|
||||||
"sfinv", "sfinv_buttons", "unified_inventory", "cmsg", "inventory_plus",
|
"sfinv", "sfinv_buttons", "unified_inventory", "cmsg", "inventory_plus",
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
# Contributing to MineClone 2
|
# Contributing to MineClone 2
|
||||||
So you want to MineClone 2?
|
So you want to contribute to MineClone 2?
|
||||||
Wow, thank you! :-)
|
Wow, thank you! :-)
|
||||||
|
|
||||||
But first, some things to note:
|
But first, some things to note:
|
||||||
|
@ -46,6 +46,28 @@ Your commit names should be relatively descriptive, e.g. when saying "Fix #issue
|
||||||
|
|
||||||
Contributors will be credited in `CREDITS.md`.
|
Contributors will be credited in `CREDITS.md`.
|
||||||
|
|
||||||
|
## Code Style
|
||||||
|
|
||||||
|
Each mod must provide `mod.conf`.
|
||||||
|
Each mod which add API functions should store functions inside a global table named like the mod.
|
||||||
|
Public functions should not use self references but rather just access the table directly.
|
||||||
|
Functions should be defined in this way:
|
||||||
|
```
|
||||||
|
function mcl_xyz.stuff(param) end
|
||||||
|
```
|
||||||
|
Insteed of this way:
|
||||||
|
```
|
||||||
|
mcl_xyz.stuff = function(param) end
|
||||||
|
```
|
||||||
|
Indentation must be unified, more likely with tabs.
|
||||||
|
|
||||||
|
Time sensitive mods should make a local copy of most used API functions to improve performances.
|
||||||
|
```
|
||||||
|
local vector = vector
|
||||||
|
local get_node = minetest.get_node
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Features > 1.12
|
## Features > 1.12
|
||||||
|
|
||||||
If you want to make a feature that was added in a Minecraft version later than 1.12, you should fork MineClone5 (mineclone5 branch in the repository) and add your changes to this.
|
If you want to make a feature that was added in a Minecraft version later than 1.12, you should fork MineClone5 (mineclone5 branch in the repository) and add your changes to this.
|
||||||
|
|
BIN
menu/Header.blend
Normal file
BIN
menu/Header.blend
Normal file
Binary file not shown.
|
@ -121,7 +121,7 @@ local hardness_values = get_hardness_values_for_groups()
|
||||||
-- hardness_value. Used for quick lookup.
|
-- hardness_value. Used for quick lookup.
|
||||||
local hardness_lookup = get_hardness_lookup_for_groups(hardness_values)
|
local hardness_lookup = get_hardness_lookup_for_groups(hardness_values)
|
||||||
|
|
||||||
local function compute_creativetimes(group)
|
--[[local function compute_creativetimes(group)
|
||||||
local creativetimes = {}
|
local creativetimes = {}
|
||||||
|
|
||||||
for index, hardness in pairs(hardness_values[group]) do
|
for index, hardness in pairs(hardness_values[group]) do
|
||||||
|
@ -129,7 +129,7 @@ local function compute_creativetimes(group)
|
||||||
end
|
end
|
||||||
|
|
||||||
return creativetimes
|
return creativetimes
|
||||||
end
|
end]]
|
||||||
|
|
||||||
-- Get the list of digging times for using a specific tool on a specific
|
-- Get the list of digging times for using a specific tool on a specific
|
||||||
-- diggroup.
|
-- diggroup.
|
||||||
|
@ -239,13 +239,13 @@ function mcl_autogroup.can_harvest(nodename, toolname)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get one groupcap field for using a specific tool on a specific group.
|
-- Get one groupcap field for using a specific tool on a specific group.
|
||||||
local function get_groupcap(group, can_harvest, multiplier, efficiency, uses)
|
--[[local function get_groupcap(group, can_harvest, multiplier, efficiency, uses)
|
||||||
return {
|
return {
|
||||||
times = get_digtimes(group, can_harvest, multiplier, efficiency),
|
times = get_digtimes(group, can_harvest, multiplier, efficiency),
|
||||||
uses = uses,
|
uses = uses,
|
||||||
maxlevel = 0,
|
maxlevel = 0,
|
||||||
}
|
}
|
||||||
end
|
end]]
|
||||||
|
|
||||||
-- Returns the tool_capabilities from a tool definition or a default set of
|
-- Returns the tool_capabilities from a tool definition or a default set of
|
||||||
-- tool_capabilities
|
-- tool_capabilities
|
||||||
|
@ -298,7 +298,7 @@ function mcl_autogroup.get_wear(toolname, diggroup)
|
||||||
return math.ceil(65535 / uses)
|
return math.ceil(65535 / uses)
|
||||||
end
|
end
|
||||||
|
|
||||||
local overwrite = function()
|
local function overwrite()
|
||||||
for nname, ndef in pairs(minetest.registered_nodes) do
|
for nname, ndef in pairs(minetest.registered_nodes) do
|
||||||
local newgroups = table.copy(ndef.groups)
|
local newgroups = table.copy(ndef.groups)
|
||||||
if (nname ~= "ignore" and ndef.diggable) then
|
if (nname ~= "ignore" and ndef.diggable) then
|
||||||
|
@ -315,12 +315,12 @@ local overwrite = function()
|
||||||
newgroups.opaque = 1
|
newgroups.opaque = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local creative_breakable = false
|
--local creative_breakable = false
|
||||||
|
|
||||||
-- Assign groups used for digging this node depending on
|
-- Assign groups used for digging this node depending on
|
||||||
-- the registered digging groups
|
-- the registered digging groups
|
||||||
for g, gdef in pairs(mcl_autogroup.registered_diggroups) do
|
for g, gdef in pairs(mcl_autogroup.registered_diggroups) do
|
||||||
creative_breakable = true
|
--creative_breakable = true
|
||||||
local index = hardness_lookup[g][ndef._mcl_hardness or 0]
|
local index = hardness_lookup[g][ndef._mcl_hardness or 0]
|
||||||
if ndef.groups[g] then
|
if ndef.groups[g] then
|
||||||
if gdef.levels then
|
if gdef.levels then
|
||||||
|
|
|
@ -81,11 +81,11 @@ if v6_use_snow_biomes then
|
||||||
end
|
end
|
||||||
local v6_freq_desert = tonumber(minetest.get_mapgen_setting("mgv6_freq_desert") or 0.45)
|
local v6_freq_desert = tonumber(minetest.get_mapgen_setting("mgv6_freq_desert") or 0.45)
|
||||||
|
|
||||||
local NOISE_MAGIC_X = 1619
|
--local NOISE_MAGIC_X = 1619
|
||||||
local NOISE_MAGIC_Y = 31337
|
--local NOISE_MAGIC_Y = 31337
|
||||||
local NOISE_MAGIC_Z = 52591
|
--local NOISE_MAGIC_Z = 52591
|
||||||
local NOISE_MAGIC_SEED = 1013
|
--local NOISE_MAGIC_SEED = 1013
|
||||||
local noise2d = function(x, y, seed)
|
local function noise2d(x, y, seed)
|
||||||
-- TODO: implement noise2d function for biome blend
|
-- TODO: implement noise2d function for biome blend
|
||||||
return 0
|
return 0
|
||||||
--[[
|
--[[
|
||||||
|
|
|
@ -1,62 +1,71 @@
|
||||||
|
local math = math
|
||||||
|
|
||||||
|
local get_node = minetest.get_node
|
||||||
|
local get_item_group = minetest.get_item_group
|
||||||
|
|
||||||
|
local registered_nodes = minetest.registered_nodes
|
||||||
|
|
||||||
flowlib = {}
|
flowlib = {}
|
||||||
|
|
||||||
--sum of direction vectors must match an array index
|
--sum of direction vectors must match an array index
|
||||||
local function to_unit_vector(dir_vector)
|
|
||||||
--(sum,root)
|
--(sum,root)
|
||||||
--(0,1), (1,1+0=1), (2,1+1=2), (3,1+2^2=5), (4,2^2+2^2=8)
|
--(0,1), (1,1+0=1), (2,1+1=2), (3,1+2^2=5), (4,2^2+2^2=8)
|
||||||
local inv_roots = {[0] = 1, [1] = 1, [2] = 0.70710678118655, [4] = 0.5
|
|
||||||
, [5] = 0.44721359549996, [8] = 0.35355339059327}
|
local inv_roots = {
|
||||||
|
[0] = 1,
|
||||||
|
[1] = 1,
|
||||||
|
[2] = 0.70710678118655,
|
||||||
|
[4] = 0.5,
|
||||||
|
[5] = 0.44721359549996,
|
||||||
|
[8] = 0.35355339059327,
|
||||||
|
}
|
||||||
|
|
||||||
|
local function to_unit_vector(dir_vector)
|
||||||
local sum = dir_vector.x * dir_vector.x + dir_vector.z * dir_vector.z
|
local sum = dir_vector.x * dir_vector.x + dir_vector.z * dir_vector.z
|
||||||
return {x=dir_vector.x*inv_roots[sum],y=dir_vector.y
|
return {x = dir_vector.x * inv_roots[sum], y = dir_vector.y, z = dir_vector.z * inv_roots[sum]}
|
||||||
,z=dir_vector.z*inv_roots[sum]}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_touching = function(realpos,nodepos,radius)
|
local function is_touching(realpos,nodepos,radius)
|
||||||
local boarder = 0.5 - radius
|
local boarder = 0.5 - radius
|
||||||
return (math.abs(realpos - nodepos) > (boarder))
|
return math.abs(realpos - nodepos) > (boarder)
|
||||||
end
|
end
|
||||||
|
|
||||||
flowlib.is_touching = is_touching
|
flowlib.is_touching = is_touching
|
||||||
|
|
||||||
local is_water = function(pos)
|
local function is_water(pos)
|
||||||
return (minetest.get_item_group(minetest.get_node(
|
return get_item_group(get_node(pos).name, "water") ~= 0
|
||||||
{x=pos.x,y=pos.y,z=pos.z}).name
|
|
||||||
, "water") ~= 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
flowlib.is_water = is_water
|
flowlib.is_water = is_water
|
||||||
|
|
||||||
local node_is_water = function(node)
|
local function node_is_water(node)
|
||||||
return (minetest.get_item_group(node.name, "water") ~= 0)
|
return get_item_group(node.name, "water") ~= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
flowlib.node_is_water = node_is_water
|
flowlib.node_is_water = node_is_water
|
||||||
|
|
||||||
local is_lava = function(pos)
|
local function is_lava(pos)
|
||||||
return (minetest.get_item_group(minetest.get_node(
|
return get_item_group(get_node(pos).name, "lava") ~= 0
|
||||||
{x=pos.x,y=pos.y,z=pos.z}).name
|
|
||||||
, "lava") ~= 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
flowlib.is_lava = is_lava
|
flowlib.is_lava = is_lava
|
||||||
|
|
||||||
local node_is_lava = function(node)
|
local function node_is_lava(node)
|
||||||
return (minetest.get_item_group(node.name, "lava") ~= 0)
|
return get_item_group(node.name, "lava") ~= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
flowlib.node_is_lava = node_is_lava
|
flowlib.node_is_lava = node_is_lava
|
||||||
|
|
||||||
|
|
||||||
local is_liquid = function(pos)
|
local function is_liquid(pos)
|
||||||
return (minetest.get_item_group(minetest.get_node(
|
return get_item_group(get_node(pos).name, "liquid") ~= 0
|
||||||
{x=pos.x,y=pos.y,z=pos.z}).name
|
|
||||||
, "liquid") ~= 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
flowlib.is_liquid = is_liquid
|
flowlib.is_liquid = is_liquid
|
||||||
|
|
||||||
local node_is_liquid = function(node)
|
local function node_is_liquid(node)
|
||||||
return (minetest.get_item_group(node.name, "liquid") ~= 0)
|
return minetest.get_item_group(node.name, "liquid") ~= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
flowlib.node_is_liquid = node_is_liquid
|
flowlib.node_is_liquid = node_is_liquid
|
||||||
|
@ -64,32 +73,28 @@ flowlib.node_is_liquid = node_is_liquid
|
||||||
--This code is more efficient
|
--This code is more efficient
|
||||||
local function quick_flow_logic(node, pos_testing, direction)
|
local function quick_flow_logic(node, pos_testing, direction)
|
||||||
local name = node.name
|
local name = node.name
|
||||||
if not minetest.registered_nodes[name] then
|
if not registered_nodes[name] then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if minetest.registered_nodes[name].liquidtype == "source" then
|
if registered_nodes[name].liquidtype == "source" then
|
||||||
local node_testing = minetest.get_node(pos_testing)
|
local node_testing = get_node(pos_testing)
|
||||||
local param2_testing = node_testing.param2
|
if not registered_nodes[node_testing.name] then
|
||||||
if not minetest.registered_nodes[node_testing.name] then
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if minetest.registered_nodes[node_testing.name].liquidtype
|
if registered_nodes[node_testing.name].liquidtype ~= "flowing" then
|
||||||
~= "flowing" then
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return direction
|
return direction
|
||||||
end
|
end
|
||||||
elseif minetest.registered_nodes[name].liquidtype == "flowing" then
|
elseif registered_nodes[name].liquidtype == "flowing" then
|
||||||
local node_testing = minetest.get_node(pos_testing)
|
local node_testing = get_node(pos_testing)
|
||||||
local param2_testing = node_testing.param2
|
local param2_testing = node_testing.param2
|
||||||
if not minetest.registered_nodes[node_testing.name] then
|
if not registered_nodes[node_testing.name] then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if minetest.registered_nodes[node_testing.name].liquidtype
|
if registered_nodes[node_testing.name].liquidtype == "source" then
|
||||||
== "source" then
|
|
||||||
return -direction
|
return -direction
|
||||||
elseif minetest.registered_nodes[node_testing.name].liquidtype
|
elseif registered_nodes[node_testing.name].liquidtype == "flowing" then
|
||||||
== "flowing" then
|
|
||||||
if param2_testing < node.param2 then
|
if param2_testing < node.param2 then
|
||||||
if (node.param2 - param2_testing) > 6 then
|
if (node.param2 - param2_testing) > 6 then
|
||||||
return -direction
|
return -direction
|
||||||
|
@ -108,44 +113,37 @@ local function quick_flow_logic(node,pos_testing,direction)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local quick_flow = function(pos,node)
|
local function quick_flow(pos, node)
|
||||||
local x = 0
|
|
||||||
local z = 0
|
|
||||||
|
|
||||||
if not node_is_liquid(node) then
|
if not node_is_liquid(node) then
|
||||||
return {x = 0, y = 0, z = 0}
|
return {x = 0, y = 0, z = 0}
|
||||||
end
|
end
|
||||||
|
local x = quick_flow_logic(node,{x = pos.x-1, y = pos.y, z = pos.z},-1) + quick_flow_logic(node,{x = pos.x+1, y = pos.y, z = pos.z}, 1)
|
||||||
x = x + quick_flow_logic(node,{x=pos.x-1,y=pos.y,z=pos.z},-1)
|
local z = quick_flow_logic(node,{x = pos.x, y = pos.y, z = pos.z-1},-1) + quick_flow_logic(node,{x = pos.x, y = pos.y, z = pos.z+1}, 1)
|
||||||
x = x + quick_flow_logic(node,{x=pos.x+1,y=pos.y,z=pos.z}, 1)
|
|
||||||
z = z + quick_flow_logic(node,{x=pos.x,y=pos.y,z=pos.z-1},-1)
|
|
||||||
z = z + quick_flow_logic(node,{x=pos.x,y=pos.y,z=pos.z+1}, 1)
|
|
||||||
|
|
||||||
return to_unit_vector({x = x, y = 0, z = z})
|
return to_unit_vector({x = x, y = 0, z = z})
|
||||||
end
|
end
|
||||||
|
|
||||||
flowlib.quick_flow = quick_flow
|
flowlib.quick_flow = quick_flow
|
||||||
|
|
||||||
|
|
||||||
--if not in water but touching, move centre to touching block
|
--if not in water but touching, move centre to touching block
|
||||||
--x has higher precedence than z
|
--x has higher precedence than z
|
||||||
--if pos changes with x, it affects z
|
--if pos changes with x, it affects z
|
||||||
local move_centre = function(pos,realpos,node,radius)
|
|
||||||
|
local function move_centre(pos, realpos, node, radius)
|
||||||
if is_touching(realpos.x, pos.x, radius) then
|
if is_touching(realpos.x, pos.x, radius) then
|
||||||
if is_liquid({x = pos.x-1, y = pos.y, z = pos.z}) then
|
if is_liquid({x = pos.x-1, y = pos.y, z = pos.z}) then
|
||||||
node = minetest.get_node({x=pos.x-1,y=pos.y,z=pos.z})
|
node = get_node({x=pos.x-1, y = pos.y, z = pos.z})
|
||||||
pos = {x = pos.x-1, y = pos.y, z = pos.z}
|
pos = {x = pos.x-1, y = pos.y, z = pos.z}
|
||||||
elseif is_liquid({x = pos.x+1, y = pos.y, z = pos.z}) then
|
elseif is_liquid({x = pos.x+1, y = pos.y, z = pos.z}) then
|
||||||
node = minetest.get_node({x=pos.x+1,y=pos.y,z=pos.z})
|
node = get_node({x = pos.x+1, y = pos.y, z = pos.z})
|
||||||
pos = {x = pos.x+1, y = pos.y, z = pos.z}
|
pos = {x = pos.x+1, y = pos.y, z = pos.z}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if is_touching(realpos.z, pos.z, radius) then
|
if is_touching(realpos.z, pos.z, radius) then
|
||||||
if is_liquid({x = pos.x, y = pos.y, z = pos.z - 1}) then
|
if is_liquid({x = pos.x, y = pos.y, z = pos.z - 1}) then
|
||||||
node = minetest.get_node({x=pos.x,y=pos.y,z=pos.z-1})
|
node = get_node({x = pos.x, y = pos.y, z = pos.z - 1})
|
||||||
pos = {x = pos.x, y = pos.y, z = pos.z - 1}
|
pos = {x = pos.x, y = pos.y, z = pos.z - 1}
|
||||||
elseif is_liquid({x = pos.x, y = pos.y, z = pos.z + 1}) then
|
elseif is_liquid({x = pos.x, y = pos.y, z = pos.z + 1}) then
|
||||||
node = minetest.get_node({x=pos.x,y=pos.y,z=pos.z+1})
|
node = get_node({x = pos.x, y = pos.y, z = pos.z + 1})
|
||||||
pos = {x = pos.x, y = pos.y, z = pos.z + 1}
|
pos = {x = pos.x, y = pos.y, z = pos.z + 1}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
|
local vector = vector
|
||||||
|
|
||||||
|
local facedir_to_dir = minetest.facedir_to_dir
|
||||||
|
local get_item_group = minetest.get_item_group
|
||||||
|
local remove_node = minetest.remove_node
|
||||||
|
local get_node = minetest.get_node
|
||||||
|
|
||||||
local original_function = minetest.check_single_for_falling
|
local original_function = minetest.check_single_for_falling
|
||||||
|
|
||||||
minetest.check_single_for_falling = function(pos)
|
function minetest.check_single_for_falling(pos)
|
||||||
local ret_o = original_function(pos)
|
local ret_o = original_function(pos)
|
||||||
|
|
||||||
local ret = false
|
local ret = false
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if minetest.get_item_group(node.name, "attached_node_facedir") ~= 0 then
|
if get_item_group(node.name, "attached_node_facedir") ~= 0 then
|
||||||
local dir = minetest.facedir_to_dir(node.param2)
|
local dir = facedir_to_dir(node.param2)
|
||||||
if dir then
|
if dir then
|
||||||
local cpos = vector.add(pos, dir)
|
if get_item_group(get_node(vector.add(pos, dir)).name, "solid") == 0 then
|
||||||
local cnode = minetest.get_node(cpos)
|
remove_node(pos)
|
||||||
if minetest.get_item_group(cnode.name, "solid") == 0 then
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
local drops = minetest.get_node_drops(node.name, "")
|
local drops = minetest.get_node_drops(node.name, "")
|
||||||
for dr=1, #drops do
|
for dr=1, #drops do
|
||||||
minetest.add_item(pos, drops[dr])
|
minetest.add_item(pos, drops[dr])
|
||||||
|
@ -20,7 +24,6 @@ minetest.check_single_for_falling = function(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return ret_o or ret
|
return ret_o or ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,7 @@ under the LGPLv2.1 license.
|
||||||
mcl_explosions = {}
|
mcl_explosions = {}
|
||||||
|
|
||||||
local mod_fire = minetest.get_modpath("mcl_fire") ~= nil
|
local mod_fire = minetest.get_modpath("mcl_fire") ~= nil
|
||||||
local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire")
|
--local CONTENT_FIRE = minetest.get_content_id("mcl_fire:fire")
|
||||||
|
|
||||||
local S = minetest.get_translator("mcl_explosions")
|
|
||||||
|
|
||||||
local hash_node_position = minetest.hash_node_position
|
local hash_node_position = minetest.hash_node_position
|
||||||
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
||||||
|
@ -174,14 +172,11 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
|
||||||
|
|
||||||
local ystride = (emax.x - emin_x + 1)
|
local ystride = (emax.x - emin_x + 1)
|
||||||
local zstride = ystride * (emax.y - emin_y + 1)
|
local zstride = ystride * (emax.y - emin_y + 1)
|
||||||
local pos_x = pos.x
|
|
||||||
local pos_y = pos.y
|
|
||||||
local pos_z = pos.z
|
|
||||||
|
|
||||||
local area = VoxelArea:new {
|
--[[local area = VoxelArea:new {
|
||||||
MinEdge = emin,
|
MinEdge = emin,
|
||||||
MaxEdge = emax
|
MaxEdge = emax
|
||||||
}
|
}]]
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
local destroy = {}
|
local destroy = {}
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
# textdomain:mcl_explosions
|
|
||||||
@1 was caught in an explosion.=@1 wurde Opfer einer Explosion.
|
|
|
@ -1,2 +0,0 @@
|
||||||
# textdomain:mcl_explosions
|
|
||||||
@1 was caught in an explosion.=@1 a été pris dans une explosion.
|
|
|
@ -1,2 +0,0 @@
|
||||||
# textdomain:mcl_explosions
|
|
||||||
@1 was caught in an explosion.=@1 не удалось пережить взрыва.
|
|
|
@ -1,2 +0,0 @@
|
||||||
# textdomain:mcl_explosions
|
|
||||||
@1 was caught in an explosion.=
|
|
|
@ -40,10 +40,9 @@ function mcl_loot.get_loot(loot_definitions, pr)
|
||||||
total_weight = total_weight + (loot_definitions.items[i].weight or 1)
|
total_weight = total_weight + (loot_definitions.items[i].weight or 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local stacks_min = loot_definitions.stacks_min
|
--local stacks_min = loot_definitions.stacks_min or 1
|
||||||
local stacks_max = loot_definitions.stacks_max
|
--local stacks_max = loot_definitions.stacks_max or 1
|
||||||
if not stacks_min then stacks_min = 1 end
|
|
||||||
if not stacks_max then stacks_max = 1 end
|
|
||||||
local stacks = pr:next(loot_definitions.stacks_min, loot_definitions.stacks_max)
|
local stacks = pr:next(loot_definitions.stacks_min, loot_definitions.stacks_max)
|
||||||
for s=1, stacks do
|
for s=1, stacks do
|
||||||
local r = pr:next(1, total_weight)
|
local r = pr:next(1, total_weight)
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
local vector = vector
|
||||||
|
local table = table
|
||||||
|
|
||||||
|
local hash_node_position = minetest.hash_node_position
|
||||||
|
local add_particlespawner = minetest.add_particlespawner
|
||||||
|
local delete_particlespawner = minetest.delete_particlespawner
|
||||||
|
|
||||||
|
local ipairs = ipairs
|
||||||
|
|
||||||
mcl_particles = {}
|
mcl_particles = {}
|
||||||
|
|
||||||
-- Table of particlespawner IDs on a per-node hash basis
|
-- Table of particlespawner IDs on a per-node hash basis
|
||||||
|
@ -32,11 +41,11 @@ function mcl_particles.add_node_particlespawner(pos, particlespawner_definition,
|
||||||
if allowed_level == 0 or levels[level] > allowed_level then
|
if allowed_level == 0 or levels[level] > allowed_level then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local poshash = minetest.hash_node_position(pos)
|
local poshash = hash_node_position(pos)
|
||||||
if not poshash then
|
if not poshash then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local id = minetest.add_particlespawner(particlespawner_definition)
|
local id = add_particlespawner(particlespawner_definition)
|
||||||
if id == -1 then
|
if id == -1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -47,6 +56,8 @@ function mcl_particles.add_node_particlespawner(pos, particlespawner_definition,
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local add_node_particlespawner = mcl_particles.add_node_particlespawner
|
||||||
|
|
||||||
-- Deletes all particlespawners that are assigned to a node position.
|
-- Deletes all particlespawners that are assigned to a node position.
|
||||||
-- If no particlespawners exist for this position, nothing happens.
|
-- If no particlespawners exist for this position, nothing happens.
|
||||||
-- pos: Node positon. MUST use integer values!
|
-- pos: Node positon. MUST use integer values!
|
||||||
|
@ -55,11 +66,11 @@ function mcl_particles.delete_node_particlespawners(pos)
|
||||||
if allowed_level == 0 then
|
if allowed_level == 0 then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local poshash = minetest.hash_node_position(pos)
|
local poshash = hash_node_position(pos)
|
||||||
local ids = particle_nodes[poshash]
|
local ids = particle_nodes[poshash]
|
||||||
if ids then
|
if ids then
|
||||||
for i=1, #ids do
|
for i=1, #ids do
|
||||||
minetest.delete_particlespawner(ids[i])
|
delete_particlespawner(ids[i])
|
||||||
end
|
end
|
||||||
particle_nodes[poshash] = nil
|
particle_nodes[poshash] = nil
|
||||||
return true
|
return true
|
||||||
|
@ -72,7 +83,6 @@ end
|
||||||
local smoke_pdef_cached = {}
|
local smoke_pdef_cached = {}
|
||||||
|
|
||||||
function mcl_particles.spawn_smoke(pos, name, smoke_pdef_base)
|
function mcl_particles.spawn_smoke(pos, name, smoke_pdef_base)
|
||||||
local min = math.min
|
|
||||||
local new_minpos = vector.add(pos, smoke_pdef_base.minrelpos)
|
local new_minpos = vector.add(pos, smoke_pdef_base.minrelpos)
|
||||||
local new_maxpos = vector.add(pos, smoke_pdef_base.maxrelpos)
|
local new_maxpos = vector.add(pos, smoke_pdef_base.maxrelpos)
|
||||||
|
|
||||||
|
@ -81,7 +91,7 @@ function mcl_particles.spawn_smoke(pos, name, smoke_pdef_base)
|
||||||
for i, smoke_pdef in ipairs(smoke_pdef_cached[name]) do
|
for i, smoke_pdef in ipairs(smoke_pdef_cached[name]) do
|
||||||
smoke_pdef.minpos = new_minpos
|
smoke_pdef.minpos = new_minpos
|
||||||
smoke_pdef.maxpos = new_maxpos
|
smoke_pdef.maxpos = new_maxpos
|
||||||
mcl_particles.add_node_particlespawner(pos, smoke_pdef, "high")
|
add_node_particlespawner(pos, smoke_pdef, "high")
|
||||||
end
|
end
|
||||||
-- cache already populated
|
-- cache already populated
|
||||||
else
|
else
|
||||||
|
@ -111,11 +121,9 @@ function mcl_particles.spawn_smoke(pos, name, smoke_pdef_base)
|
||||||
smoke_pdef.animation.length = exptime + 0.1
|
smoke_pdef.animation.length = exptime + 0.1
|
||||||
-- minexptime must be set such that the last frame is actully rendered,
|
-- minexptime must be set such that the last frame is actully rendered,
|
||||||
-- even if its very short. Larger exptime -> larger range
|
-- even if its very short. Larger exptime -> larger range
|
||||||
smoke_pdef.minexptime = min(exptime, (7.0/8.0 * (exptime + 0.1) + 0.1))
|
smoke_pdef.minexptime = math.min(exptime, (7.0/8.0 * (exptime + 0.1) + 0.1))
|
||||||
smoke_pdef.texture = "mcl_particles_smoke_anim.png^[colorize:#000000:" ..colorize
|
smoke_pdef.texture = "mcl_particles_smoke_anim.png^[colorize:#000000:" ..colorize
|
||||||
|
add_node_particlespawner(pos, smoke_pdef, "high")
|
||||||
mcl_particles.add_node_particlespawner(pos, smoke_pdef, "high")
|
|
||||||
|
|
||||||
table.insert(smoke_pdef_cached[name], table.copy(smoke_pdef))
|
table.insert(smoke_pdef_cached[name], table.copy(smoke_pdef))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -150,7 +150,7 @@ function mcl_util.get_eligible_transfer_item_slot(src_inventory, src_list, dst_i
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns true if itemstack is a shulker box
|
-- Returns true if itemstack is a shulker box
|
||||||
local is_not_shulker_box = function(itemstack)
|
local function is_not_shulker_box(itemstack)
|
||||||
local g = minetest.get_item_group(itemstack:get_name(), "shulker_box")
|
local g = minetest.get_item_group(itemstack:get_name(), "shulker_box")
|
||||||
return g == 0 or g == nil
|
return g == 0 or g == nil
|
||||||
end
|
end
|
||||||
|
@ -212,7 +212,7 @@ function mcl_util.move_item_container(source_pos, destination_pos, source_list,
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Normalize double container by forcing to always use the left segment first
|
-- Normalize double container by forcing to always use the left segment first
|
||||||
local normalize_double_container = function(pos, node, ctype)
|
local function normalize_double_container(pos, node, ctype)
|
||||||
if ctype == 6 then
|
if ctype == 6 then
|
||||||
pos = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right")
|
pos = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right")
|
||||||
if not pos then
|
if not pos then
|
||||||
|
@ -456,14 +456,7 @@ function mcl_util.calculate_durability(itemstack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not uses then
|
uses = uses or (next(itemstack:get_tool_capabilities().groupcaps) or {}).uses
|
||||||
local toolcaps = itemstack:get_tool_capabilities()
|
|
||||||
local groupcaps = toolcaps.groupcaps
|
|
||||||
for _, v in pairs(groupcaps) do
|
|
||||||
uses = v.uses
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return uses or 0
|
return uses or 0
|
||||||
|
|
|
@ -35,9 +35,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
pp.y = ceil(pp.y)
|
pp.y = ceil(pp.y)
|
||||||
local loc = vector_add(pp, {x=0,y=-1,z=0})
|
local loc = vector_add(pp, {x=0,y=-1,z=0})
|
||||||
if loc ~= nil then
|
if loc ~= nil then
|
||||||
|
|
||||||
local nodeiamon = get_node(loc)
|
local nodeiamon = get_node(loc)
|
||||||
|
|
||||||
if nodeiamon ~= nil then
|
if nodeiamon ~= nil then
|
||||||
if on_walk[nodeiamon.name] then
|
if on_walk[nodeiamon.name] then
|
||||||
on_walk[nodeiamon.name](loc, nodeiamon, player)
|
on_walk[nodeiamon.name](loc, nodeiamon, player)
|
||||||
|
@ -48,7 +46,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
timer = 0
|
timer = 0
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
--Dripping Water Mod
|
--Dripping Water Mod
|
||||||
--by kddekadenz
|
--by kddekadenz
|
||||||
|
|
||||||
|
local math = math
|
||||||
|
|
||||||
-- License of code, textures & sounds: CC0
|
-- License of code, textures & sounds: CC0
|
||||||
|
|
||||||
--Drop entities
|
--Drop entities
|
||||||
|
@ -20,23 +22,18 @@ minetest.register_entity("drippingwater:drop_water", {
|
||||||
spritediv = {x=1, y=1},
|
spritediv = {x=1, y=1},
|
||||||
initial_sprite_basepos = {x=0, y=0},
|
initial_sprite_basepos = {x=0, y=0},
|
||||||
static_save = false,
|
static_save = false,
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
self.object:set_sprite({x=0,y=0}, 1, 1, true)
|
self.object:set_sprite({x=0,y=0}, 1, 1, true)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local k = math.random(1,222)
|
local k = math.random(1,222)
|
||||||
local ownpos = self.object:get_pos()
|
local ownpos = self.object:get_pos()
|
||||||
|
|
||||||
if k==1 then
|
if k==1 then
|
||||||
self.object:set_acceleration({x=0, y=-5, z=0})
|
self.object:set_acceleration({x=0, y=-5, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
||||||
self.object:set_acceleration({x=0, y=-5, z=0})
|
self.object:set_acceleration({x=0, y=-5, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
|
minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
|
||||||
|
@ -61,24 +58,18 @@ minetest.register_entity("drippingwater:drop_lava", {
|
||||||
spritediv = {x=1, y=1},
|
spritediv = {x=1, y=1},
|
||||||
initial_sprite_basepos = {x=0, y=0},
|
initial_sprite_basepos = {x=0, y=0},
|
||||||
static_save = false,
|
static_save = false,
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
self.object:set_sprite({x=0,y=0}, 1, 0, true)
|
self.object:set_sprite({x=0,y=0}, 1, 0, true)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local k = math.random(1,222)
|
local k = math.random(1,222)
|
||||||
local ownpos = self.object:get_pos()
|
local ownpos = self.object:get_pos()
|
||||||
|
|
||||||
if k == 1 then
|
if k == 1 then
|
||||||
self.object:set_acceleration({x=0, y=-5, z=0})
|
self.object:set_acceleration({x=0, y=-5, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
||||||
self.object:set_acceleration({x=0, y=-5, z=0})
|
self.object:set_acceleration({x=0, y=-5, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
|
minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
|
||||||
|
@ -90,16 +81,15 @@ minetest.register_entity("drippingwater:drop_lava", {
|
||||||
|
|
||||||
--Create drop
|
--Create drop
|
||||||
|
|
||||||
minetest.register_abm(
|
minetest.register_abm({
|
||||||
{
|
|
||||||
label = "Create water drops",
|
label = "Create water drops",
|
||||||
nodenames = {"group:opaque", "group:leaves"},
|
nodenames = {"group:opaque", "group:leaves"},
|
||||||
neighbors = {"group:water"},
|
neighbors = {"group:water"},
|
||||||
interval = 2,
|
interval = 2,
|
||||||
chance = 22,
|
chance = 22,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0 and
|
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0
|
||||||
minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
||||||
local i = math.random(-45,45) / 100
|
local i = math.random(-45,45) / 100
|
||||||
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water")
|
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water")
|
||||||
end
|
end
|
||||||
|
@ -108,16 +98,15 @@ minetest.register_abm(
|
||||||
|
|
||||||
--Create lava drop
|
--Create lava drop
|
||||||
|
|
||||||
minetest.register_abm(
|
minetest.register_abm({
|
||||||
{
|
|
||||||
label = "Create lava drops",
|
label = "Create lava drops",
|
||||||
nodenames = {"group:opaque"},
|
nodenames = {"group:opaque"},
|
||||||
neighbors = {"group:lava"},
|
neighbors = {"group:lava"},
|
||||||
interval = 2,
|
interval = 2,
|
||||||
chance = 22,
|
chance = 22,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0 and
|
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0
|
||||||
minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
||||||
local i = math.random(-45,45) / 100
|
local i = math.random(-45,45) / 100
|
||||||
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava")
|
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava")
|
||||||
end
|
end
|
||||||
|
|
|
@ -328,10 +328,10 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
|
|
||||||
p.y = p.y - boat_y_offset
|
p.y = p.y - boat_y_offset
|
||||||
local new_velo
|
local new_velo
|
||||||
local new_acce = {x = 0, y = 0, z = 0}
|
local new_acce
|
||||||
if not is_water(p) and not on_ice then
|
if not is_water(p) and not on_ice then
|
||||||
-- Not on water or inside water: Free fall
|
-- Not on water or inside water: Free fall
|
||||||
local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
|
--local nodedef = minetest.registered_nodes[minetest.get_node(p).name]
|
||||||
new_acce = {x = 0, y = -9.8, z = 0}
|
new_acce = {x = 0, y = -9.8, z = 0}
|
||||||
new_velo = get_velocity(self._v, self.object:get_yaw(),
|
new_velo = get_velocity(self._v, self.object:get_yaw(),
|
||||||
self.object:get_velocity().y)
|
self.object:get_velocity().y)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
local S = minetest.get_translator("mcl_burning")
|
|
||||||
|
|
||||||
function mcl_burning.get_storage(obj)
|
function mcl_burning.get_storage(obj)
|
||||||
return obj:is_player() and mcl_burning.storage[obj] or obj:get_luaentity()
|
return obj:is_player() and mcl_burning.storage[obj] or obj:get_luaentity()
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local S = minetest.get_translator("mcl_burning")
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
local modpath = minetest.get_modpath("mcl_burning")
|
|
||||||
|
|
||||||
mcl_burning = {
|
mcl_burning = {
|
||||||
storage = {},
|
storage = {},
|
||||||
|
@ -56,7 +55,6 @@ minetest.register_on_leaveplayer(function(player)
|
||||||
local storage = mcl_burning.storage[player]
|
local storage = mcl_burning.storage[player]
|
||||||
storage.fire_hud_id = nil
|
storage.fire_hud_id = nil
|
||||||
player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage))
|
player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage))
|
||||||
|
|
||||||
mcl_burning.storage[player] = nil
|
mcl_burning.storage[player] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -70,10 +68,8 @@ minetest.register_entity("mcl_burning:fire", {
|
||||||
glow = -1,
|
glow = -1,
|
||||||
backface_culling = false,
|
backface_culling = false,
|
||||||
},
|
},
|
||||||
|
|
||||||
animation_frame = 0,
|
animation_frame = 0,
|
||||||
animation_timer = 0,
|
animation_timer = 0,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local parent, storage = self:sanity_check()
|
local parent, storage = self:sanity_check()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
local S = minetest.get_translator("mcl_falling_nodes")
|
local function get_falling_depth(self)
|
||||||
local has_mcl_armor = minetest.get_modpath("mcl_armor")
|
|
||||||
|
|
||||||
local get_falling_depth = function(self)
|
|
||||||
if not self._startpos then
|
if not self._startpos then
|
||||||
-- Fallback
|
-- Fallback
|
||||||
self._startpos = self.object:get_pos()
|
self._startpos = self.object:get_pos()
|
||||||
|
@ -9,7 +6,7 @@ local get_falling_depth = function(self)
|
||||||
return self._startpos.y - vector.round(self.object:get_pos()).y
|
return self._startpos.y - vector.round(self.object:get_pos()).y
|
||||||
end
|
end
|
||||||
|
|
||||||
local deal_falling_damage = function(self, dtime)
|
local function deal_falling_damage(self, dtime)
|
||||||
if minetest.get_item_group(self.node.name, "falling_node_damage") == 0 then
|
if minetest.get_item_group(self.node.name, "falling_node_damage") == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -38,7 +35,7 @@ local deal_falling_damage = function(self, dtime)
|
||||||
inv:set_stack("armor", 2, helmet)
|
inv:set_stack("armor", 2, helmet)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local deathmsg, dmg_type
|
local dmg_type
|
||||||
if minetest.get_item_group(self.node.name, "anvil") ~= 0 then
|
if minetest.get_item_group(self.node.name, "anvil") ~= 0 then
|
||||||
dmg_type = "anvil"
|
dmg_type = "anvil"
|
||||||
else
|
else
|
||||||
|
@ -60,10 +57,8 @@ minetest.register_entity(":__builtin:falling_node", {
|
||||||
collide_with_objects = false,
|
collide_with_objects = false,
|
||||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||||
},
|
},
|
||||||
|
|
||||||
node = {},
|
node = {},
|
||||||
meta = {},
|
meta = {},
|
||||||
|
|
||||||
set_node = function(self, node, meta)
|
set_node = function(self, node, meta)
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
-- Change falling node if definition tells us to
|
-- Change falling node if definition tells us to
|
||||||
|
@ -90,7 +85,6 @@ minetest.register_entity(":__builtin:falling_node", {
|
||||||
glow = glow,
|
glow = glow,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get_staticdata = function(self)
|
get_staticdata = function(self)
|
||||||
local meta = self.meta
|
local meta = self.meta
|
||||||
-- Workaround: Save inventory seperately from metadata.
|
-- Workaround: Save inventory seperately from metadata.
|
||||||
|
@ -111,7 +105,6 @@ minetest.register_entity(":__builtin:falling_node", {
|
||||||
}
|
}
|
||||||
return minetest.serialize(ds)
|
return minetest.serialize(ds)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
self.object:set_armor_groups({immortal = 1})
|
self.object:set_armor_groups({immortal = 1})
|
||||||
|
|
||||||
|
@ -134,7 +127,6 @@ minetest.register_entity(":__builtin:falling_node", {
|
||||||
end
|
end
|
||||||
self._startpos = vector.round(self._startpos)
|
self._startpos = vector.round(self._startpos)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
-- Set gravity
|
-- Set gravity
|
||||||
local acceleration = self.object:get_acceleration()
|
local acceleration = self.object:get_acceleration()
|
||||||
|
@ -186,10 +178,9 @@ minetest.register_entity(":__builtin:falling_node", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local nd = minetest.registered_nodes[n2.name]
|
local nd = minetest.registered_nodes[n2.name]
|
||||||
if n2.name == "mcl_portals:portal_end" then
|
--if n2.name == "mcl_portals:portal_end" then
|
||||||
-- TODO: Teleport falling node.
|
-- TODO: Teleport falling node.
|
||||||
|
if (nd and nd.buildable_to == true) or minetest.get_item_group(self.node.name, "crush_after_fall") ~= 0 then
|
||||||
elseif (nd and nd.buildable_to == true) or minetest.get_item_group(self.node.name, "crush_after_fall") ~= 0 then
|
|
||||||
-- Replace destination node if it's buildable to
|
-- Replace destination node if it's buildable to
|
||||||
minetest.remove_node(np)
|
minetest.remove_node(np)
|
||||||
-- Run script hook
|
-- Run script hook
|
||||||
|
@ -256,7 +247,6 @@ minetest.register_entity(":__builtin:falling_node", {
|
||||||
self.object:set_pos(npos)
|
self.object:set_pos(npos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
deal_falling_damage(self, dtime)
|
deal_falling_damage(self, dtime)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
# textdomain: mcl_falling_nodes
|
|
||||||
@1 was smashed by a falling anvil.=@1 wurde von einem fallenden Amboss zerschmettert.
|
|
||||||
@1 was smashed by a falling block.=@1 wurde von einem fallenden Block zerschmettert.
|
|
|
@ -1,3 +0,0 @@
|
||||||
# textdomain: mcl_falling_nodes
|
|
||||||
@1 was smashed by a falling anvil.=@1 fue aplastado por la caída de un yunque.
|
|
||||||
@1 was smashed by a falling block.=@1 fue aplastado por la caída de un bloque.
|
|
|
@ -1,3 +0,0 @@
|
||||||
# textdomain: mcl_falling_nodes
|
|
||||||
@1 was smashed by a falling anvil.=@1 a été écrasé par une enclume qui tombait.
|
|
||||||
@1 was smashed by a falling block.=@1 a été écrasé par un bloc qui tombait.
|
|
|
@ -1,3 +0,0 @@
|
||||||
# textdomain: mcl_falling_nodes
|
|
||||||
@1 was smashed by a falling anvil.=@1 придавило падающей наковальней.
|
|
||||||
@1 was smashed by a falling block.=@1 раздавило падающим блоком.
|
|
|
@ -1,3 +0,0 @@
|
||||||
# textdomain: mcl_falling_nodes
|
|
||||||
@1 was smashed by a falling anvil.=
|
|
||||||
@1 was smashed by a falling block.=
|
|
|
@ -38,7 +38,7 @@ item_drop_settings.drop_single_item = false --if true, the drop control dro
|
||||||
|
|
||||||
item_drop_settings.magnet_time = 0.75 -- how many seconds an item follows the player before giving up
|
item_drop_settings.magnet_time = 0.75 -- how many seconds an item follows the player before giving up
|
||||||
|
|
||||||
local get_gravity = function()
|
local function get_gravity()
|
||||||
return tonumber(minetest.settings:get("movement_gravity")) or 9.81
|
return tonumber(minetest.settings:get("movement_gravity")) or 9.81
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ mcl_item_entity.register_pickup_achievement("mcl_mobitems:blaze_rod", "mcl:blaze
|
||||||
mcl_item_entity.register_pickup_achievement("mcl_mobitems:leather", "mcl:killCow")
|
mcl_item_entity.register_pickup_achievement("mcl_mobitems:leather", "mcl:killCow")
|
||||||
mcl_item_entity.register_pickup_achievement("mcl_core:diamond", "mcl:diamonds")
|
mcl_item_entity.register_pickup_achievement("mcl_core:diamond", "mcl:diamonds")
|
||||||
|
|
||||||
local check_pickup_achievements = function(object, player)
|
local function check_pickup_achievements(object, player)
|
||||||
if has_awards then
|
if has_awards then
|
||||||
local itemname = ItemStack(object:get_luaentity().itemstring):get_name()
|
local itemname = ItemStack(object:get_luaentity().itemstring):get_name()
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
|
@ -72,7 +72,7 @@ local check_pickup_achievements = function(object, player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local enable_physics = function(object, luaentity, ignore_check)
|
local function enable_physics(object, luaentity, ignore_check)
|
||||||
if luaentity.physical_state == false or ignore_check == true then
|
if luaentity.physical_state == false or ignore_check == true then
|
||||||
luaentity.physical_state = true
|
luaentity.physical_state = true
|
||||||
object:set_properties({
|
object:set_properties({
|
||||||
|
@ -83,7 +83,7 @@ local enable_physics = function(object, luaentity, ignore_check)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local disable_physics = function(object, luaentity, ignore_check, reset_movement)
|
local function disable_physics(object, luaentity, ignore_check, reset_movement)
|
||||||
if luaentity.physical_state == true or ignore_check == true then
|
if luaentity.physical_state == true or ignore_check == true then
|
||||||
luaentity.physical_state = false
|
luaentity.physical_state = false
|
||||||
object:set_properties({
|
object:set_properties({
|
||||||
|
@ -98,13 +98,11 @@ end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
tick = not tick
|
tick = not tick
|
||||||
|
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
|
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
|
||||||
|
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
@ -426,13 +424,9 @@ minetest.register_entity(":__builtin:item", {
|
||||||
if itemtable then
|
if itemtable then
|
||||||
itemname = stack:to_table().name
|
itemname = stack:to_table().name
|
||||||
end
|
end
|
||||||
local item_texture = nil
|
|
||||||
local item_type = ""
|
|
||||||
local glow
|
local glow
|
||||||
local def = minetest.registered_items[itemname]
|
local def = minetest.registered_items[itemname]
|
||||||
if def then
|
if def then
|
||||||
item_texture = def.inventory_image
|
|
||||||
item_type = def.type
|
|
||||||
description = def.description
|
description = def.description
|
||||||
glow = def.light_source
|
glow = def.light_source
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
local vector = vector
|
||||||
|
|
||||||
function mcl_minecarts:get_sign(z)
|
function mcl_minecarts:get_sign(z)
|
||||||
if z == 0 then
|
if z == 0 then
|
||||||
return 0
|
return 0
|
||||||
|
@ -38,11 +40,9 @@ end
|
||||||
|
|
||||||
function mcl_minecarts:check_front_up_down(pos, dir_, check_down, railtype)
|
function mcl_minecarts:check_front_up_down(pos, dir_, check_down, railtype)
|
||||||
local dir = vector.new(dir_)
|
local dir = vector.new(dir_)
|
||||||
local cur = nil
|
|
||||||
|
|
||||||
-- Front
|
-- Front
|
||||||
dir.y = 0
|
dir.y = 0
|
||||||
cur = vector.add(pos, dir)
|
local cur = vector.add(pos, dir)
|
||||||
if mcl_minecarts:is_rail(cur, railtype) then
|
if mcl_minecarts:is_rail(cur, railtype) then
|
||||||
return dir
|
return dir
|
||||||
end
|
end
|
||||||
|
@ -65,7 +65,7 @@ end
|
||||||
|
|
||||||
function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
||||||
local pos = vector.round(pos_)
|
local pos = vector.round(pos_)
|
||||||
local cur = nil
|
local cur
|
||||||
local left_check, right_check = true, true
|
local left_check, right_check = true, true
|
||||||
|
|
||||||
-- Check left and right
|
-- Check left and right
|
||||||
|
@ -122,7 +122,6 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
||||||
return cur
|
return cur
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Backwards
|
-- Backwards
|
||||||
if not old_switch then
|
if not old_switch then
|
||||||
cur = mcl_minecarts:check_front_up_down(pos, {
|
cur = mcl_minecarts:check_front_up_down(pos, {
|
||||||
|
@ -134,7 +133,5 @@ function mcl_minecarts:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
||||||
return cur
|
return cur
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return {x=0, y=0, z=0}
|
return {x=0, y=0, z=0}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,6 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
if update.pos then
|
if update.pos then
|
||||||
self.object:set_pos(pos)
|
self.object:set_pos(pos)
|
||||||
end
|
end
|
||||||
update = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function cart:get_staticdata()
|
function cart:get_staticdata()
|
||||||
|
@ -497,7 +496,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Place a minecart at pointed_thing
|
-- Place a minecart at pointed_thing
|
||||||
mcl_minecarts.place_minecart = function(itemstack, pointed_thing, placer)
|
function mcl_minecarts.place_minecart(itemstack, pointed_thing, placer)
|
||||||
if not pointed_thing.type == "node" then
|
if not pointed_thing.type == "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -541,7 +540,7 @@ mcl_minecarts.place_minecart = function(itemstack, pointed_thing, placer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local register_craftitem = function(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative)
|
local function register_craftitem(itemstring, entity_id, description, tt_help, longdesc, usagehelp, icon, creative)
|
||||||
entity_mapping[itemstring] = entity_id
|
entity_mapping[itemstring] = entity_id
|
||||||
|
|
||||||
local groups = { minecart = 1, transport = 1 }
|
local groups = { minecart = 1, transport = 1 }
|
||||||
|
@ -817,8 +816,7 @@ minetest.register_craft({
|
||||||
})
|
})
|
||||||
|
|
||||||
-- TODO: Re-enable crafting of special minecarts when they have been implemented
|
-- TODO: Re-enable crafting of special minecarts when they have been implemented
|
||||||
if false then
|
--[[minetest.register_craft({
|
||||||
minetest.register_craft({
|
|
||||||
output = "mcl_minecarts:furnace_minecart",
|
output = "mcl_minecarts:furnace_minecart",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mcl_furnaces:furnace"},
|
{"mcl_furnaces:furnace"},
|
||||||
|
@ -840,8 +838,8 @@ if false then
|
||||||
{"mcl_chests:chest"},
|
{"mcl_chests:chest"},
|
||||||
{"mcl_minecarts:minecart"},
|
{"mcl_minecarts:minecart"},
|
||||||
},
|
},
|
||||||
})
|
})]]
|
||||||
end
|
|
||||||
|
|
||||||
if has_mcl_wip then
|
if has_mcl_wip then
|
||||||
mcl_wip.register_wip_item("mcl_minecarts:chest_minecart")
|
mcl_wip.register_wip_item("mcl_minecarts:chest_minecart")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local S = minetest.get_translator("mcl_minecarts")
|
local S = minetest.get_translator("mcl_minecarts")
|
||||||
|
|
||||||
-- Template rail function
|
-- Template rail function
|
||||||
local register_rail = function(itemstring, tiles, def_extras, creative)
|
local function register_rail(itemstring, tiles, def_extras, creative)
|
||||||
local groups = {handy=1,pickaxey=1, attached_node=1,rail=1,connect_to_raillike=minetest.raillike_group("rail"),dig_by_water=1,destroy_by_lava_flow=1, transport=1}
|
local groups = {handy=1,pickaxey=1, attached_node=1,rail=1,connect_to_raillike=minetest.raillike_group("rail"),dig_by_water=1,destroy_by_lava_flow=1, transport=1}
|
||||||
if creative == false then
|
if creative == false then
|
||||||
groups.not_in_creative_inventory = 1
|
groups.not_in_creative_inventory = 1
|
||||||
|
|
|
@ -11,133 +11,111 @@ local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
|
||||||
local minetest_get_modpath = minetest.get_modpath
|
local minetest_get_modpath = minetest.get_modpath
|
||||||
local minetest_registered_nodes = minetest.registered_nodes
|
local minetest_registered_nodes = minetest.registered_nodes
|
||||||
local minetest_get_node = minetest.get_node
|
local minetest_get_node = minetest.get_node
|
||||||
local minetest_get_item_group = minetest.get_item_group
|
--local minetest_get_item_group = minetest.get_item_group
|
||||||
local minetest_registered_entities = minetest.registered_entities
|
local minetest_registered_entities = minetest.registered_entities
|
||||||
local minetest_line_of_sight = minetest.line_of_sight
|
--local minetest_line_of_sight = minetest.line_of_sight
|
||||||
local minetest_after = minetest.after
|
--local minetest_after = minetest.after
|
||||||
local minetest_sound_play = minetest.sound_play
|
--local minetest_sound_play = minetest.sound_play
|
||||||
local minetest_add_particlespawner = minetest.add_particlespawner
|
--local minetest_add_particlespawner = minetest.add_particlespawner
|
||||||
local minetest_registered_items = minetest.registered_items
|
--local minetest_registered_items = minetest.registered_items
|
||||||
local minetest_set_node = minetest.set_node
|
--local minetest_set_node = minetest.set_node
|
||||||
local minetest_add_item = minetest.add_item
|
local minetest_add_item = minetest.add_item
|
||||||
local minetest_get_craft_result = minetest.get_craft_result
|
--local minetest_get_craft_result = minetest.get_craft_result
|
||||||
local minetest_find_path = minetest.find_path
|
--local minetest_find_path = minetest.find_path
|
||||||
local minetest_is_protected = minetest.is_protected
|
|
||||||
local minetest_is_creative_enabled = minetest.is_creative_enabled
|
local minetest_is_creative_enabled = minetest.is_creative_enabled
|
||||||
local minetest_find_node_near = minetest.find_node_near
|
--local minetest_find_node_near = minetest.find_node_near
|
||||||
local minetest_find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
|
--local minetest_find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
|
||||||
local minetest_raycast = minetest.raycast
|
--local minetest_raycast = minetest.raycast
|
||||||
local minetest_get_us_time = minetest.get_us_time
|
--local minetest_get_us_time = minetest.get_us_time
|
||||||
local minetest_add_entity = minetest.add_entity
|
local minetest_add_entity = minetest.add_entity
|
||||||
local minetest_get_natural_light = minetest.get_natural_light
|
--local minetest_get_natural_light = minetest.get_natural_light
|
||||||
local minetest_get_node_or_nil = minetest.get_node_or_nil
|
--local minetest_get_node_or_nil = minetest.get_node_or_nil
|
||||||
|
|
||||||
-- localize math functions
|
-- localize math functions
|
||||||
local math_pi = math.pi
|
local math = math
|
||||||
local math_sin = math.sin
|
|
||||||
local math_cos = math.cos
|
|
||||||
local math_abs = math.abs
|
|
||||||
local math_min = math.min
|
|
||||||
local math_max = math.max
|
|
||||||
local math_atan = math.atan
|
|
||||||
local math_random = math.random
|
|
||||||
local math_floor = math.floor
|
|
||||||
|
|
||||||
-- localize vector functions
|
-- localize vector functions
|
||||||
local vector_new = vector.new
|
local vector = vector
|
||||||
local vector_add = vector.add
|
|
||||||
local vector_length = vector.length
|
local string = string
|
||||||
local vector_direction = vector.direction
|
|
||||||
local vector_normalize = vector.normalize
|
|
||||||
local vector_multiply = vector.multiply
|
|
||||||
local vector_divide = vector.divide
|
|
||||||
|
|
||||||
-- mob constants
|
-- mob constants
|
||||||
local BREED_TIME = 30
|
--local BREED_TIME = 30
|
||||||
local BREED_TIME_AGAIN = 300
|
--local BREED_TIME_AGAIN = 300
|
||||||
local CHILD_GROW_TIME = 60*20
|
--local CHILD_GROW_TIME = 60*20
|
||||||
local DEATH_DELAY = 0.5
|
--local DEATH_DELAY = 0.5
|
||||||
local DEFAULT_FALL_SPEED = -10
|
local DEFAULT_FALL_SPEED = -10
|
||||||
local FLOP_HEIGHT = 5.0
|
--local FLOP_HEIGHT = 5.0
|
||||||
local FLOP_HOR_SPEED = 1.5
|
--local FLOP_HOR_SPEED = 1.5
|
||||||
local GRAVITY = minetest_settings:get("movement_gravity")-- + 9.81
|
local GRAVITY = minetest_settings:get("movement_gravity")-- + 9.81
|
||||||
|
|
||||||
|
local MAX_MOB_NAME_LENGTH = 30
|
||||||
|
|
||||||
local MOB_CAP = {}
|
|
||||||
|
--[[local MOB_CAP = {}
|
||||||
MOB_CAP.hostile = 70
|
MOB_CAP.hostile = 70
|
||||||
MOB_CAP.passive = 10
|
MOB_CAP.passive = 10
|
||||||
MOB_CAP.ambient = 15
|
MOB_CAP.ambient = 15
|
||||||
MOB_CAP.water = 15
|
MOB_CAP.water = 15
|
||||||
|
]]
|
||||||
|
|
||||||
-- Load main settings
|
-- Load main settings
|
||||||
local damage_enabled = minetest_settings:get_bool("enable_damage")
|
--local damage_enabled = minetest_settings:get_bool("enable_damage")
|
||||||
local disable_blood = minetest_settings:get_bool("mobs_disable_blood")
|
--local disable_blood = minetest_settings:get_bool("mobs_disable_blood")
|
||||||
local mobs_drop_items = minetest_settings:get_bool("mobs_drop_items") ~= false
|
--local mobs_drop_items = minetest_settings:get_bool("mobs_drop_items") ~= false
|
||||||
local mobs_griefing = minetest_settings:get_bool("mobs_griefing") ~= false
|
--local mobs_griefing = minetest_settings:get_bool("mobs_griefing") ~= false
|
||||||
local spawn_protected = minetest_settings:get_bool("mobs_spawn_protected") ~= false
|
--local spawn_protected = minetest_settings:get_bool("mobs_spawn_protected") ~= false
|
||||||
local remove_far = true
|
--local remove_far = true
|
||||||
local difficulty = tonumber(minetest_settings:get("mob_difficulty")) or 1.0
|
local difficulty = tonumber(minetest_settings:get("mob_difficulty")) or 1.0
|
||||||
local show_health = false
|
--local show_health = false
|
||||||
local max_per_block = tonumber(minetest_settings:get("max_objects_per_block") or 64)
|
--local max_per_block = tonumber(minetest_settings:get("max_objects_per_block") or 64)
|
||||||
local mobs_spawn_chance = tonumber(minetest_settings:get("mobs_spawn_chance") or 2.5)
|
---local mobs_spawn_chance = tonumber(minetest_settings:get("mobs_spawn_chance") or 2.5)
|
||||||
|
|
||||||
-- pathfinding settings
|
-- pathfinding settings
|
||||||
local enable_pathfinding = true
|
--local enable_pathfinding = true
|
||||||
local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching
|
--local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching
|
||||||
local stuck_path_timeout = 10 -- how long will mob follow path before giving up
|
--local stuck_path_timeout = 10 -- how long will mob follow path before giving up
|
||||||
|
|
||||||
-- default nodes
|
-- default nodes
|
||||||
local node_ice = "mcl_core:ice"
|
--local node_ice = "mcl_core:ice"
|
||||||
local node_snowblock = "mcl_core:snowblock"
|
--local node_snowblock = "mcl_core:snowblock"
|
||||||
local node_snow = "mcl_core:snow"
|
--local node_snow = "mcl_core:snow"
|
||||||
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
||||||
|
|
||||||
local mod_weather = minetest_get_modpath("mcl_weather") ~= nil
|
--local mod_weather = minetest_get_modpath("mcl_weather")
|
||||||
local mod_explosions = minetest_get_modpath("mcl_explosions") ~= nil
|
--local mod_explosions = minetest_get_modpath("mcl_explosions")
|
||||||
local mod_mobspawners = minetest_get_modpath("mcl_mobspawners") ~= nil
|
local mod_mobspawners = minetest_get_modpath("mcl_mobspawners")
|
||||||
local mod_hunger = minetest_get_modpath("mcl_hunger") ~= nil
|
--local mod_hunger = minetest_get_modpath("mcl_hunger")
|
||||||
local mod_worlds = minetest_get_modpath("mcl_worlds") ~= nil
|
--local mod_worlds = minetest_get_modpath("mcl_worlds")
|
||||||
local mod_armor = minetest_get_modpath("mcl_armor") ~= nil
|
--local mod_armor = minetest_get_modpath("mcl_armor")
|
||||||
local mod_experience = minetest_get_modpath("mcl_experience") ~= nil
|
--local mod_experience = minetest_get_modpath("mcl_experience")
|
||||||
|
|
||||||
|
|
||||||
-- random locals I found
|
-- random locals I found
|
||||||
local los_switcher = false
|
--local los_switcher = false
|
||||||
local height_switcher = false
|
--local height_switcher = false
|
||||||
|
|
||||||
-- Get translator
|
-- Get translator
|
||||||
local S = minetest.get_translator("mcl_mobs")
|
local S = minetest.get_translator("mcl_mobs")
|
||||||
|
|
||||||
-- CMI support check
|
-- CMI support check
|
||||||
local use_cmi = minetest.global_exists("cmi")
|
--local use_cmi = minetest.global_exists("cmi")
|
||||||
|
|
||||||
|
|
||||||
-- Invisibility mod check
|
|
||||||
mobs.invis = {}
|
|
||||||
if minetest.global_exists("invisibility") then
|
|
||||||
mobs.invis = invisibility
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- creative check
|
-- creative check
|
||||||
function mobs.is_creative(name)
|
function mobs.is_creative(name)
|
||||||
return minetest_is_creative_enabled(name)
|
return minetest_is_creative_enabled(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[local function atan(x)
|
||||||
local atan = function(x)
|
|
||||||
if not x or x ~= x then
|
if not x or x ~= x then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return math_atan(x)
|
return math.atan(x)
|
||||||
end
|
end
|
||||||
end
|
end]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Shows helpful debug info above each mob
|
-- Shows helpful debug info above each mob
|
||||||
local mobs_debug = minetest_settings:get_bool("mobs_debug", false)
|
--local mobs_debug = minetest_settings:get_bool("mobs_debug", false)
|
||||||
|
|
||||||
-- Peaceful mode message so players will know there are no monsters
|
-- Peaceful mode message so players will know there are no monsters
|
||||||
if minetest_settings:get_bool("only_peaceful_mobs", false) then
|
if minetest_settings:get_bool("only_peaceful_mobs", false) then
|
||||||
|
@ -191,7 +169,7 @@ function mobs:register_mob(name, def)
|
||||||
if (not value) or (value == default) or (value == special) then
|
if (not value) or (value == default) or (value == special) then
|
||||||
return default
|
return default
|
||||||
else
|
else
|
||||||
return math_max(min, value * difficulty)
|
return math.max(min, value * difficulty)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -366,15 +344,11 @@ function mobs:register_mob(name, def)
|
||||||
random_sound_timer_min = 3,
|
random_sound_timer_min = 3,
|
||||||
random_sound_timer_max = 10,
|
random_sound_timer_max = 10,
|
||||||
|
|
||||||
|
|
||||||
--head code variables
|
--head code variables
|
||||||
--defaults are for the cow's default
|
--defaults are for the cow's default
|
||||||
--because I don't know what else to set them
|
--because I don't know what else to set them
|
||||||
--to :P
|
--to :P
|
||||||
|
|
||||||
has_head = def.has_head or false,
|
|
||||||
head_bone = def.head_bone,
|
|
||||||
|
|
||||||
--you must use these to adjust the mob's head positions
|
--you must use these to adjust the mob's head positions
|
||||||
|
|
||||||
--has_head is used as a logic gate (quick easy check)
|
--has_head is used as a logic gate (quick easy check)
|
||||||
|
@ -444,7 +418,7 @@ function mobs:register_mob(name, def)
|
||||||
--on_detach_child = mob_detach_child,
|
--on_detach_child = mob_detach_child,
|
||||||
|
|
||||||
on_activate = function(self, staticdata, dtime)
|
on_activate = function(self, staticdata, dtime)
|
||||||
self.object:set_acceleration(vector_new(0,-GRAVITY, 0))
|
self.object:set_acceleration(vector.new(0,-GRAVITY, 0))
|
||||||
return mobs.mob_activate(self, staticdata, def, dtime)
|
return mobs.mob_activate(self, staticdata, def, dtime)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -556,10 +530,10 @@ function mobs:register_arrow(name, def)
|
||||||
and def.tail_texture then
|
and def.tail_texture then
|
||||||
|
|
||||||
--do this to prevent clipping through main entity sprite
|
--do this to prevent clipping through main entity sprite
|
||||||
local pos_adjustment = vector_multiply(vector_normalize(vel), -1)
|
local pos_adjustment = vector.multiply(vector.normalize(vel), -1)
|
||||||
local divider = def.tail_distance_divider or 1
|
local divider = def.tail_distance_divider or 1
|
||||||
pos_adjustment = vector_divide(pos_adjustment, divider)
|
pos_adjustment = vector.divide(pos_adjustment, divider)
|
||||||
local new_pos = vector_add(pos, pos_adjustment)
|
local new_pos = vector.add(pos, pos_adjustment)
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = new_pos,
|
pos = new_pos,
|
||||||
velocity = {x = 0, y = 0, z = 0},
|
velocity = {x = 0, y = 0, z = 0},
|
||||||
|
@ -693,12 +667,12 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
|
|
||||||
if pos
|
if pos
|
||||||
--and within_limits(pos, 0)
|
--and within_limits(pos, 0)
|
||||||
and not minetest_is_protected(pos, placer:get_player_name()) then
|
and not minetest.is_protected(pos, placer:get_player_name()) then
|
||||||
|
|
||||||
local name = placer:get_player_name()
|
local name = placer:get_player_name()
|
||||||
local privs = minetest.get_player_privs(name)
|
local privs = minetest.get_player_privs(name)
|
||||||
if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then
|
if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then
|
||||||
if minetest_is_protected(pointed_thing.under, name) then
|
if minetest.is_protected(pointed_thing.under, name) then
|
||||||
minetest.record_protection_violation(pointed_thing.under, name)
|
minetest.record_protection_violation(pointed_thing.under, name)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
@ -743,7 +717,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
||||||
nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH)
|
nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH)
|
||||||
end
|
end
|
||||||
ent.nametag = nametag
|
ent.nametag = nametag
|
||||||
update_tag(ent)
|
--update_tag(ent)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if not in creative then take item
|
-- if not in creative then take item
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
local math_random = math.random
|
local math = math
|
||||||
local math_pi = math.pi
|
local vector = vector
|
||||||
local math_floor = math.floor
|
local string = string
|
||||||
local math_round = math.round
|
|
||||||
|
|
||||||
local vector_multiply = vector.multiply
|
local tonumber = tonumber
|
||||||
local vector_add = vector.add
|
|
||||||
local vector_new = vector.new
|
|
||||||
local vector_distance = vector.distance
|
|
||||||
|
|
||||||
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
||||||
local minetest_get_item_group = minetest.get_item_group
|
local minetest_get_item_group = minetest.get_item_group
|
||||||
|
@ -17,9 +13,8 @@ local minetest_get_node_light = minetest.get_node_light
|
||||||
local DOUBLE_PI = math.pi * 2
|
local DOUBLE_PI = math.pi * 2
|
||||||
local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125
|
local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125
|
||||||
|
|
||||||
|
|
||||||
--a simple helper function which is too small to move into movement.lua
|
--a simple helper function which is too small to move into movement.lua
|
||||||
local quick_rotate = function(self,dtime)
|
local function quick_rotate(self,dtime)
|
||||||
self.yaw = self.yaw + THIRTY_SECONDTH_PI
|
self.yaw = self.yaw + THIRTY_SECONDTH_PI
|
||||||
if self.yaw > DOUBLE_PI then
|
if self.yaw > DOUBLE_PI then
|
||||||
self.yaw = self.yaw - DOUBLE_PI
|
self.yaw = self.yaw - DOUBLE_PI
|
||||||
|
@ -28,7 +23,7 @@ end
|
||||||
|
|
||||||
--a simple helper function for rounding
|
--a simple helper function for rounding
|
||||||
--http://lua-users.org/wiki/SimpleRound
|
--http://lua-users.org/wiki/SimpleRound
|
||||||
function round2(num, numDecimalPlaces)
|
local function round2(num, numDecimalPlaces)
|
||||||
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
|
return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,7 +38,7 @@ end
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
--this is basically reverse jump_check
|
--this is basically reverse jump_check
|
||||||
local cliff_check = function(self,dtime)
|
local function cliff_check(self,dtime)
|
||||||
--mobs will flip out if they are falling without this
|
--mobs will flip out if they are falling without this
|
||||||
if self.object:get_velocity().y ~= 0 then
|
if self.object:get_velocity().y ~= 0 then
|
||||||
return false
|
return false
|
||||||
|
@ -54,20 +49,19 @@ local cliff_check = function(self,dtime)
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
local radius = collisionbox[4] + 0.5
|
local radius = collisionbox[4] + 0.5
|
||||||
|
|
||||||
dir = vector_multiply(dir,radius)
|
dir = vector.multiply(dir,radius)
|
||||||
|
|
||||||
local free_fall, blocker = minetest_line_of_sight(
|
local free_fall = minetest_line_of_sight(
|
||||||
{x = pos.x + dir.x, y = pos.y, z = pos.z + dir.z},
|
{x = pos.x + dir.x, y = pos.y, z = pos.z + dir.z},
|
||||||
{x = pos.x + dir.x, y = pos.y - self.fear_height, z = pos.z + dir.z})
|
{x = pos.x + dir.x, y = pos.y - self.fear_height, z = pos.z + dir.z})
|
||||||
|
|
||||||
return free_fall
|
return free_fall
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- state switching logic (stand, walk, run, attacks)
|
-- state switching logic (stand, walk, run, attacks)
|
||||||
local land_state_list_wandering = {"stand", "walk"}
|
local land_state_list_wandering = {"stand", "walk"}
|
||||||
|
|
||||||
local land_state_switch = function(self, dtime)
|
local function land_state_switch(self, dtime)
|
||||||
|
|
||||||
--do math before sure not attacking, following, or running away so continue
|
--do math before sure not attacking, following, or running away so continue
|
||||||
--doing random walking for mobs if all states are not met
|
--doing random walking for mobs if all states are not met
|
||||||
|
@ -120,7 +114,7 @@ local land_state_switch = function(self, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- states are executed here
|
-- states are executed here
|
||||||
local land_state_execution = function(self,dtime)
|
local function land_state_execution(self, dtime)
|
||||||
|
|
||||||
--[[ -- this is a debug which shows the timer and makes mobs breed 100 times faster
|
--[[ -- this is a debug which shows the timer and makes mobs breed 100 times faster
|
||||||
print(self.breed_timer)
|
print(self.breed_timer)
|
||||||
|
@ -137,7 +131,6 @@ local land_state_execution = function(self,dtime)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--timer to time out looking for mate
|
--timer to time out looking for mate
|
||||||
if self.breed_lookout_timer and self.breed_lookout_timer > 0 then
|
if self.breed_lookout_timer and self.breed_lookout_timer > 0 then
|
||||||
self.breed_lookout_timer = self.breed_lookout_timer - dtime
|
self.breed_lookout_timer = self.breed_lookout_timer - dtime
|
||||||
|
@ -176,12 +169,12 @@ local land_state_execution = function(self,dtime)
|
||||||
if velocity.y < 0 then
|
if velocity.y < 0 then
|
||||||
--lua is acting really weird so we have to help it
|
--lua is acting really weird so we have to help it
|
||||||
if round2(self.object:get_acceleration().y, 1) == -self.gravity then
|
if round2(self.object:get_acceleration().y, 1) == -self.gravity then
|
||||||
self.object:set_acceleration(vector_new(0,0,0))
|
self.object:set_acceleration(vector.new(0,0,0))
|
||||||
mobs.mob_fall_slow(self)
|
mobs.mob_fall_slow(self)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if round2(self.object:get_acceleration().y, 1) == 0 then
|
if round2(self.object:get_acceleration().y, 1) == 0 then
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
self.object:set_acceleration(vector.new(0,-self.gravity,0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -207,14 +200,12 @@ local land_state_execution = function(self,dtime)
|
||||||
|
|
||||||
mobs.lock_yaw(self)
|
mobs.lock_yaw(self)
|
||||||
elseif self.state == "follow" then
|
elseif self.state == "follow" then
|
||||||
|
|
||||||
--always look at players
|
--always look at players
|
||||||
mobs.set_yaw_while_following(self)
|
mobs.set_yaw_while_following(self)
|
||||||
|
|
||||||
--check distance
|
--check distance
|
||||||
local distance_from_follow_person = vector_distance(self.object:get_pos(), self.following_person:get_pos())
|
local distance_from_follow_person = vector.distance(self.object:get_pos(), self.following_person:get_pos())
|
||||||
local distance_2d = mobs.get_2d_distance(self.object:get_pos(), self.following_person:get_pos())
|
local distance_2d = mobs.get_2d_distance(self.object:get_pos(), self.following_person:get_pos())
|
||||||
|
|
||||||
--don't push the player if too close
|
--don't push the player if too close
|
||||||
--don't spin around randomly
|
--don't spin around randomly
|
||||||
if self.follow_distance < distance_from_follow_person and self.minimum_follow_distance < distance_2d then
|
if self.follow_distance < distance_from_follow_person and self.minimum_follow_distance < distance_2d then
|
||||||
|
@ -240,7 +231,7 @@ local land_state_execution = function(self,dtime)
|
||||||
self.walk_timer = math.random(1,6) + math.random()
|
self.walk_timer = math.random(1,6) + math.random()
|
||||||
|
|
||||||
--set the mob into a random direction
|
--set the mob into a random direction
|
||||||
self.yaw = (math_random() * (math.pi * 2))
|
self.yaw = (math.random() * (math.pi * 2))
|
||||||
end
|
end
|
||||||
|
|
||||||
--do animation
|
--do animation
|
||||||
|
@ -253,9 +244,7 @@ local land_state_execution = function(self,dtime)
|
||||||
local node_in_front_of = mobs.jump_check(self)
|
local node_in_front_of = mobs.jump_check(self)
|
||||||
|
|
||||||
if node_in_front_of == 1 then
|
if node_in_front_of == 1 then
|
||||||
|
|
||||||
mobs.jump(self)
|
mobs.jump(self)
|
||||||
|
|
||||||
--turn if on the edge of cliff
|
--turn if on the edge of cliff
|
||||||
--(this is written like this because unlike
|
--(this is written like this because unlike
|
||||||
--jump_check which simply tells the mob to jump
|
--jump_check which simply tells the mob to jump
|
||||||
|
@ -292,9 +281,7 @@ local land_state_execution = function(self,dtime)
|
||||||
local node_in_front_of = mobs.jump_check(self)
|
local node_in_front_of = mobs.jump_check(self)
|
||||||
|
|
||||||
if node_in_front_of == 1 then
|
if node_in_front_of == 1 then
|
||||||
|
|
||||||
mobs.jump(self)
|
mobs.jump(self)
|
||||||
|
|
||||||
--turn if on the edge of cliff
|
--turn if on the edge of cliff
|
||||||
--(this is written like this because unlike
|
--(this is written like this because unlike
|
||||||
--jump_check which simply tells the mob to jump
|
--jump_check which simply tells the mob to jump
|
||||||
|
@ -342,7 +329,7 @@ local land_state_execution = function(self,dtime)
|
||||||
mobs.set_velocity(self, self.walk_velocity)
|
mobs.set_velocity(self, self.walk_velocity)
|
||||||
|
|
||||||
--smoosh together basically
|
--smoosh together basically
|
||||||
if vector_distance(self.object:get_pos(), mate:get_pos()) <= self.breed_distance then
|
if vector.distance(self.object:get_pos(), mate:get_pos()) <= self.breed_distance then
|
||||||
mobs.set_mob_animation(self, "stand")
|
mobs.set_mob_animation(self, "stand")
|
||||||
if self.special_breed_timer == 0 then
|
if self.special_breed_timer == 0 then
|
||||||
self.special_breed_timer = 2 --breeding takes 2 seconds
|
self.special_breed_timer = 2 --breeding takes 2 seconds
|
||||||
|
@ -353,7 +340,7 @@ local land_state_execution = function(self,dtime)
|
||||||
|
|
||||||
--pop a baby out, it's a miracle!
|
--pop a baby out, it's a miracle!
|
||||||
local baby_pos = vector.divide(vector.add(self.object:get_pos(), mate:get_pos()), 2)
|
local baby_pos = vector.divide(vector.add(self.object:get_pos(), mate:get_pos()), 2)
|
||||||
local baby_mob = minetest.add_entity(pos, self.name, minetest.serialize({baby = true, grow_up_timer = self.grow_up_goal, bred = true}))
|
minetest.add_entity(baby_pos, self.name, minetest.serialize({baby = true, grow_up_timer = self.grow_up_goal, bred = true}))
|
||||||
|
|
||||||
mobs.play_sound_specific(self,"item_drop_pickup")
|
mobs.play_sound_specific(self,"item_drop_pickup")
|
||||||
|
|
||||||
|
@ -376,13 +363,12 @@ local land_state_execution = function(self,dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if float_now then
|
if float_now then
|
||||||
mobs.float(self)
|
mobs.float(self)
|
||||||
else
|
else
|
||||||
local acceleration = self.object:get_acceleration()
|
local acceleration = self.object:get_acceleration()
|
||||||
if acceleration and acceleration.y == 0 then
|
if acceleration and acceleration.y == 0 then
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
self.object:set_acceleration(vector.new(0,-self.gravity,0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -404,7 +390,7 @@ end
|
||||||
-- state switching logic (stand, walk, run, attacks)
|
-- state switching logic (stand, walk, run, attacks)
|
||||||
local swim_state_list_wandering = {"stand", "swim"}
|
local swim_state_list_wandering = {"stand", "swim"}
|
||||||
|
|
||||||
local swim_state_switch = function(self, dtime)
|
local function swim_state_switch(self, dtime)
|
||||||
self.state_timer = self.state_timer - dtime
|
self.state_timer = self.state_timer - dtime
|
||||||
if self.state_timer <= 0 then
|
if self.state_timer <= 0 then
|
||||||
self.state_timer = math.random(4,10) + math.random()
|
self.state_timer = math.random(4,10) + math.random()
|
||||||
|
@ -414,7 +400,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
--check if a mob needs to turn while swimming
|
--check if a mob needs to turn while swimming
|
||||||
local swim_turn_check = function(self,dtime)
|
local function swim_turn_check(self,dtime)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
pos.y = pos.y + 0.1
|
pos.y = pos.y + 0.1
|
||||||
|
@ -423,32 +409,31 @@ local swim_turn_check = function(self,dtime)
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
local radius = collisionbox[4] + 0.5
|
local radius = collisionbox[4] + 0.5
|
||||||
|
|
||||||
vector_multiply(dir, radius)
|
vector.multiply(dir, radius)
|
||||||
|
|
||||||
local test_dir = vector.add(pos,dir)
|
local test_dir = vector.add(pos,dir)
|
||||||
|
|
||||||
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
||||||
|
|
||||||
return(green_flag_1)
|
return green_flag_1
|
||||||
end
|
end
|
||||||
|
|
||||||
--this is to swap the built in engine acceleration modifier
|
--this is to swap the built in engine acceleration modifier
|
||||||
local swim_physics_swapper = function(self,inside_swim_node)
|
local function swim_physics_swapper(self, inside_swim_node)
|
||||||
|
|
||||||
--should be swimming, gravity is applied, switch to floating
|
--should be swimming, gravity is applied, switch to floating
|
||||||
if inside_swim_node and self.object:get_acceleration().y ~= 0 then
|
if inside_swim_node and self.object:get_acceleration().y ~= 0 then
|
||||||
self.object:set_acceleration(vector_new(0,0,0))
|
self.object:set_acceleration(vector.new(0,0,0))
|
||||||
--not be swim, gravity isn't applied, switch to falling
|
--not be swim, gravity isn't applied, switch to falling
|
||||||
elseif not inside_swim_node and self.object:get_acceleration().y == 0 then
|
elseif not inside_swim_node and self.object:get_acceleration().y == 0 then
|
||||||
self.pitch = 0
|
self.pitch = 0
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
self.object:set_acceleration(vector.new(0,-self.gravity,0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local random_pitch_multiplier = {-1,1}
|
local random_pitch_multiplier = {-1,1}
|
||||||
-- states are executed here
|
-- states are executed here
|
||||||
local swim_state_execution = function(self,dtime)
|
local function swim_state_execution(self, dtime)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
|
@ -482,22 +467,17 @@ local swim_state_execution = function(self,dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
mobs.lock_yaw(self)
|
mobs.lock_yaw(self)
|
||||||
|
|
||||||
elseif self.state == "swim" then
|
elseif self.state == "swim" then
|
||||||
|
|
||||||
self.walk_timer = self.walk_timer - dtime
|
self.walk_timer = self.walk_timer - dtime
|
||||||
|
|
||||||
--reset the walk timer
|
--reset the walk timer
|
||||||
if self.walk_timer <= 0 then
|
if self.walk_timer <= 0 then
|
||||||
|
|
||||||
--re-randomize the walk timer
|
--re-randomize the walk timer
|
||||||
self.walk_timer = math.random(1,6) + math.random()
|
self.walk_timer = math.random(1,6) + math.random()
|
||||||
|
|
||||||
--set the mob into a random direction
|
--set the mob into a random direction
|
||||||
self.yaw = (math_random() * (math.pi * 2))
|
self.yaw = (math.random() * (math.pi * 2))
|
||||||
|
|
||||||
--create a truly random pitch, since there is no easy access to pitch math that I can find
|
--create a truly random pitch, since there is no easy access to pitch math that I can find
|
||||||
self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)]
|
self.pitch = math.random() * math.random(1,3) * random_pitch_multiplier[math.random(1,2)]
|
||||||
end
|
end
|
||||||
|
|
||||||
--do animation
|
--do animation
|
||||||
|
@ -548,7 +528,7 @@ ______ _
|
||||||
-- state switching logic (stand, walk, run, attacks)
|
-- state switching logic (stand, walk, run, attacks)
|
||||||
local fly_state_list_wandering = {"stand", "fly"}
|
local fly_state_list_wandering = {"stand", "fly"}
|
||||||
|
|
||||||
local fly_state_switch = function(self, dtime)
|
local function fly_state_switch(self, dtime)
|
||||||
|
|
||||||
if self.hostile and self.attacking then
|
if self.hostile and self.attacking then
|
||||||
self.state = "attack"
|
self.state = "attack"
|
||||||
|
@ -564,7 +544,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
--check if a mob needs to turn while flying
|
--check if a mob needs to turn while flying
|
||||||
local fly_turn_check = function(self,dtime)
|
local function fly_turn_check(self, dtime)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
pos.y = pos.y + 0.1
|
pos.y = pos.y + 0.1
|
||||||
|
@ -573,32 +553,32 @@ local fly_turn_check = function(self,dtime)
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
local radius = collisionbox[4] + 0.5
|
local radius = collisionbox[4] + 0.5
|
||||||
|
|
||||||
vector_multiply(dir, radius)
|
vector.multiply(dir, radius)
|
||||||
|
|
||||||
local test_dir = vector.add(pos,dir)
|
local test_dir = vector.add(pos,dir)
|
||||||
|
|
||||||
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
||||||
|
|
||||||
return(green_flag_1)
|
return green_flag_1
|
||||||
end
|
end
|
||||||
|
|
||||||
--this is to swap the built in engine acceleration modifier
|
--this is to swap the built in engine acceleration modifier
|
||||||
local fly_physics_swapper = function(self,inside_fly_node)
|
local function fly_physics_swapper(self, inside_fly_node)
|
||||||
|
|
||||||
--should be flyming, gravity is applied, switch to floating
|
--should be flyming, gravity is applied, switch to floating
|
||||||
if inside_fly_node and self.object:get_acceleration().y ~= 0 then
|
if inside_fly_node and self.object:get_acceleration().y ~= 0 then
|
||||||
self.object:set_acceleration(vector_new(0,0,0))
|
self.object:set_acceleration(vector.new(0,0,0))
|
||||||
--not be fly, gravity isn't applied, switch to falling
|
--not be fly, gravity isn't applied, switch to falling
|
||||||
elseif not inside_fly_node and self.object:get_acceleration().y == 0 then
|
elseif not inside_fly_node and self.object:get_acceleration().y == 0 then
|
||||||
self.pitch = 0
|
self.pitch = 0
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
self.object:set_acceleration(vector.new(0,-self.gravity,0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local random_pitch_multiplier = {-1,1}
|
local random_pitch_multiplier = {-1,1}
|
||||||
-- states are executed here
|
-- states are executed here
|
||||||
local fly_state_execution = function(self,dtime)
|
local function fly_state_execution(self, dtime)
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
pos.y = pos.y + 0.1
|
pos.y = pos.y + 0.1
|
||||||
local current_node = minetest_get_node(pos).name
|
local current_node = minetest_get_node(pos).name
|
||||||
|
@ -635,15 +615,13 @@ local fly_state_execution = function(self,dtime)
|
||||||
|
|
||||||
--reset the walk timer
|
--reset the walk timer
|
||||||
if self.walk_timer <= 0 then
|
if self.walk_timer <= 0 then
|
||||||
|
|
||||||
--re-randomize the walk timer
|
--re-randomize the walk timer
|
||||||
self.walk_timer = math.random(1,6) + math.random()
|
self.walk_timer = math.random(1,6) + math.random()
|
||||||
|
|
||||||
--set the mob into a random direction
|
--set the mob into a random direction
|
||||||
self.yaw = (math_random() * (math.pi * 2))
|
self.yaw = (math.random() * (math.pi * 2))
|
||||||
|
|
||||||
--create a truly random pitch, since there is no easy access to pitch math that I can find
|
--create a truly random pitch, since there is no easy access to pitch math that I can find
|
||||||
self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)]
|
self.pitch = math.random() * math.random(1,3) * random_pitch_multiplier[math.random(1,2)]
|
||||||
end
|
end
|
||||||
|
|
||||||
--do animation
|
--do animation
|
||||||
|
@ -663,9 +641,7 @@ local fly_state_execution = function(self,dtime)
|
||||||
|
|
||||||
--enable rotation locking
|
--enable rotation locking
|
||||||
mobs.movement_rotation_lock(self)
|
mobs.movement_rotation_lock(self)
|
||||||
|
|
||||||
elseif self.state == "attack" then
|
elseif self.state == "attack" then
|
||||||
|
|
||||||
--execute mob attack type
|
--execute mob attack type
|
||||||
--if self.attack_type == "explode" then
|
--if self.attack_type == "explode" then
|
||||||
|
|
||||||
|
@ -709,8 +685,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
--check if a mob needs to turn while jumping
|
--check if a mob needs to turn while jumping
|
||||||
local jump_turn_check = function(self,dtime)
|
--[[local function jump_turn_check(self, dtime)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
pos.y = pos.y + 0.1
|
pos.y = pos.y + 0.1
|
||||||
local dir = minetest_yaw_to_dir(self.yaw)
|
local dir = minetest_yaw_to_dir(self.yaw)
|
||||||
|
@ -718,19 +693,19 @@ local jump_turn_check = function(self,dtime)
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
local radius = collisionbox[4] + 0.5
|
local radius = collisionbox[4] + 0.5
|
||||||
|
|
||||||
vector_multiply(dir, radius)
|
vector.multiply(dir, radius)
|
||||||
|
|
||||||
local test_dir = vector.add(pos,dir)
|
local test_dir = vector.add(pos,dir)
|
||||||
|
|
||||||
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
||||||
|
|
||||||
return(green_flag_1)
|
return green_flag_1
|
||||||
end
|
end]]
|
||||||
|
|
||||||
-- state switching logic (stand, jump, run, attacks)
|
-- state switching logic (stand, jump, run, attacks)
|
||||||
local jump_state_list_wandering = {"stand", "jump"}
|
local jump_state_list_wandering = {"stand", "jump"}
|
||||||
|
|
||||||
local jump_state_switch = function(self, dtime)
|
local function jump_state_switch(self, dtime)
|
||||||
self.state_timer = self.state_timer - dtime
|
self.state_timer = self.state_timer - dtime
|
||||||
if self.state_timer <= 0 then
|
if self.state_timer <= 0 then
|
||||||
self.state_timer = math.random(4,10) + math.random()
|
self.state_timer = math.random(4,10) + math.random()
|
||||||
|
@ -739,8 +714,8 @@ local jump_state_switch = function(self, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- states are executed here
|
-- states are executed here
|
||||||
local jump_state_execution = function(self,dtime)
|
local function jump_state_execution(self, dtime)
|
||||||
|
local node_in_front_of = mobs.jump_check(self)
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
--get the center of the mob
|
--get the center of the mob
|
||||||
|
@ -775,7 +750,7 @@ local jump_state_execution = function(self,dtime)
|
||||||
self.walk_timer = math.random(1,6) + math.random()
|
self.walk_timer = math.random(1,6) + math.random()
|
||||||
|
|
||||||
--set the mob into a random direction
|
--set the mob into a random direction
|
||||||
self.yaw = (math_random() * (math.pi * 2))
|
self.yaw = (math.random() * (math.pi * 2))
|
||||||
end
|
end
|
||||||
|
|
||||||
--do animation
|
--do animation
|
||||||
|
@ -793,15 +768,10 @@ local jump_state_execution = function(self,dtime)
|
||||||
mobs.jump_move(self,self.walk_velocity)
|
mobs.jump_move(self,self.walk_velocity)
|
||||||
|
|
||||||
elseif self.state == "run" then
|
elseif self.state == "run" then
|
||||||
|
|
||||||
print("run")
|
print("run")
|
||||||
|
|
||||||
elseif self.state == "attack" then
|
elseif self.state == "attack" then
|
||||||
|
|
||||||
print("attack")
|
print("attack")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if float_now then
|
if float_now then
|
||||||
mobs.float(self)
|
mobs.float(self)
|
||||||
end
|
end
|
||||||
|
@ -822,7 +792,7 @@ ___ ___ _ _ _
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
--the main loop
|
--the main loop
|
||||||
mobs.mob_step = function(self, dtime)
|
function mobs.mob_step(self, dtime)
|
||||||
|
|
||||||
--do not continue if non-existent
|
--do not continue if non-existent
|
||||||
if not self or not self.object or not self.object:get_luaentity() then
|
if not self or not self.object or not self.object:get_luaentity() then
|
||||||
|
@ -916,7 +886,6 @@ mobs.mob_step = function(self, dtime)
|
||||||
|
|
||||||
elseif self.breath < self.breath_max then
|
elseif self.breath < self.breath_max then
|
||||||
self.breath = self.breath + dtime
|
self.breath = self.breath + dtime
|
||||||
|
|
||||||
--clean timer reset
|
--clean timer reset
|
||||||
if self.breath > self.breath_max then
|
if self.breath > self.breath_max then
|
||||||
self.breath = self.breath_max
|
self.breath = self.breath_max
|
||||||
|
@ -948,10 +917,6 @@ mobs.mob_step = function(self, dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--baby grows up
|
--baby grows up
|
||||||
if self.baby then
|
if self.baby then
|
||||||
--print(self.grow_up_timer)
|
--print(self.grow_up_timer)
|
||||||
|
@ -969,8 +934,6 @@ mobs.mob_step = function(self, dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--do custom mob instructions
|
--do custom mob instructions
|
||||||
if self.do_custom then
|
if self.do_custom then
|
||||||
-- when false skip going any further
|
-- when false skip going any further
|
||||||
|
@ -1015,7 +978,7 @@ mobs.mob_step = function(self, dtime)
|
||||||
self.memory = self.memory - dtime
|
self.memory = self.memory - dtime
|
||||||
--get if memory player is within viewing range
|
--get if memory player is within viewing range
|
||||||
if self.attacking and self.attacking:is_player() then
|
if self.attacking and self.attacking:is_player() then
|
||||||
local distance = vector_distance(self.object:get_pos(), self.attacking:get_pos())
|
local distance = vector.distance(self.object:get_pos(), self.attacking:get_pos())
|
||||||
if distance > self.view_range then
|
if distance > self.view_range then
|
||||||
self.memory = 0
|
self.memory = 0
|
||||||
end
|
end
|
||||||
|
@ -1124,28 +1087,22 @@ mobs.mob_step = function(self, dtime)
|
||||||
--overrides absolutely everything
|
--overrides absolutely everything
|
||||||
--mobs get stuck in cobwebs like players
|
--mobs get stuck in cobwebs like players
|
||||||
if not self.ignores_cobwebs then
|
if not self.ignores_cobwebs then
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local node = pos and minetest_get_node(pos).name
|
local node = pos and minetest_get_node(pos).name
|
||||||
|
|
||||||
if node == "mcl_core:cobweb" then
|
if node == "mcl_core:cobweb" then
|
||||||
|
|
||||||
--fight the rest of the api
|
--fight the rest of the api
|
||||||
if self.object:get_acceleration().y ~= 0 then
|
if self.object:get_acceleration().y ~= 0 then
|
||||||
self.object:set_acceleration(vector_new(0,0,0))
|
self.object:set_acceleration(vector.new(0,0,0))
|
||||||
end
|
end
|
||||||
|
|
||||||
mobs.stick_in_cobweb(self)
|
mobs.stick_in_cobweb(self)
|
||||||
|
|
||||||
self.was_stuck_in_cobweb = true
|
self.was_stuck_in_cobweb = true
|
||||||
|
|
||||||
else
|
else
|
||||||
--do not override other functions
|
--do not override other functions
|
||||||
if self.was_stuck_in_cobweb == true then
|
if self.was_stuck_in_cobweb == true then
|
||||||
--return the mob back to normal
|
--return the mob back to normal
|
||||||
self.was_stuck_in_cobweb = nil
|
self.was_stuck_in_cobweb = nil
|
||||||
if self.object:get_acceleration().y == 0 and not self.swim and not self.fly then
|
if self.object:get_acceleration().y == 0 and not self.swim and not self.fly then
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
self.object:set_acceleration(vector.new(0,-self.gravity,0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local math_pi = math.pi
|
local math = math
|
||||||
local math_floor = math.floor
|
local vector = vector
|
||||||
local math_random = math.random
|
|
||||||
local HALF_PI = math_pi/2
|
local HALF_PI = math.pi/2
|
||||||
|
|
||||||
|
|
||||||
local vector_direction = vector.direction
|
local vector_direction = vector.direction
|
||||||
|
@ -48,7 +48,6 @@ mobs.set_mob_animation = function(self, anim, fixed_frame)
|
||||||
self.animation[anim .. "_speed"] or self.animation.speed_normal or 15,
|
self.animation[anim .. "_speed"] or self.animation.speed_normal or 15,
|
||||||
0, self.animation[anim .. "_loop"] ~= false)
|
0, self.animation[anim .. "_loop"] ~= false)
|
||||||
|
|
||||||
|
|
||||||
self.current_animation = anim
|
self.current_animation = anim
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,14 +64,14 @@ mobs.death_effect = function(pos, yaw, collisionbox, rotate)
|
||||||
max = { x = 0.5, y = 0.5, z = 0.5 }
|
max = { x = 0.5, y = 0.5, z = 0.5 }
|
||||||
end
|
end
|
||||||
if rotate then
|
if rotate then
|
||||||
min = vector.rotate(min, {x=0, y=yaw, z=math_pi/2})
|
min = vector.rotate(min, {x=0, y=yaw, z=math.pi/2})
|
||||||
max = vector.rotate(max, {x=0, y=yaw, z=math_pi/2})
|
max = vector.rotate(max, {x=0, y=yaw, z=math.pi/2})
|
||||||
min, max = vector.sort(min, max)
|
min, max = vector.sort(min, max)
|
||||||
min = vector.multiply(min, 0.5)
|
min = vector.multiply(min, 0.5)
|
||||||
max = vector.multiply(max, 0.5)
|
max = vector.multiply(max, 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest_add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 50,
|
amount = 50,
|
||||||
time = 0.001,
|
time = 0.001,
|
||||||
minpos = vector.add(pos, min),
|
minpos = vector.add(pos, min),
|
||||||
|
@ -88,7 +87,7 @@ mobs.death_effect = function(pos, yaw, collisionbox, rotate)
|
||||||
texture = "mcl_particles_mob_death.png^[colorize:#000000:255",
|
texture = "mcl_particles_mob_death.png^[colorize:#000000:255",
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest_sound_play("mcl_mobs_mob_poof", {
|
minetest.sound_play("mcl_mobs_mob_poof", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = 1.0,
|
gain = 1.0,
|
||||||
max_hear_distance = 8,
|
max_hear_distance = 8,
|
||||||
|
@ -99,7 +98,6 @@ end
|
||||||
--this allows auto facedir rotation while making it so mobs
|
--this allows auto facedir rotation while making it so mobs
|
||||||
--don't look like wet noodles flopping around
|
--don't look like wet noodles flopping around
|
||||||
mobs.movement_rotation_lock = function(self)
|
mobs.movement_rotation_lock = function(self)
|
||||||
|
|
||||||
local current_engine_yaw = self.object:get_yaw()
|
local current_engine_yaw = self.object:get_yaw()
|
||||||
local current_lua_yaw = self.yaw
|
local current_lua_yaw = self.yaw
|
||||||
|
|
||||||
|
@ -159,7 +157,7 @@ local calculate_pitch = function(self)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return(minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos.x,0,pos.z),vector_new(pos2.x,0,pos2.z)),0,pos.y - pos2.y)) + HALF_PI)
|
return minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos.x,0,pos.z),vector_new(pos2.x,0,pos2.z)),0,pos.y - pos2.y)) + HALF_PI
|
||||||
end
|
end
|
||||||
|
|
||||||
--this is a helper function used to make mobs pitch rotation dynamically flow when flying/swimming
|
--this is a helper function used to make mobs pitch rotation dynamically flow when flying/swimming
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local vector_direction = vector.direction
|
local vector_direction = vector.direction
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
--local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||||
local vector_distance = vector.distance
|
local vector_distance = vector.distance
|
||||||
local vector_multiply = vector.multiply
|
local vector_multiply = vector.multiply
|
||||||
local math_random = math.random
|
local math_random = math.random
|
||||||
|
@ -75,7 +75,6 @@ mobs.explode_attack_walk = function(self,dtime)
|
||||||
mobs.jump(self)
|
mobs.jump(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--do biggening explosion thing
|
--do biggening explosion thing
|
||||||
if self.explosion_animation and self.explosion_animation > self.explosion_timer then
|
if self.explosion_animation and self.explosion_animation > self.explosion_timer then
|
||||||
mcl_explosions.explode(self.object:get_pos(), self.explosion_strength,{ drop_chance = 1.0 })
|
mcl_explosions.explode(self.object:get_pos(), self.explosion_strength,{ drop_chance = 1.0 })
|
||||||
|
@ -113,7 +112,6 @@ ______ _
|
||||||
|
|
||||||
|
|
||||||
mobs.punch_attack_walk = function(self,dtime)
|
mobs.punch_attack_walk = function(self,dtime)
|
||||||
|
|
||||||
--this needs an exception
|
--this needs an exception
|
||||||
if self.attacking == nil or not self.attacking:is_player() then
|
if self.attacking == nil or not self.attacking:is_player() then
|
||||||
self.attacking = nil
|
self.attacking = nil
|
||||||
|
@ -282,7 +280,6 @@ ______ _ _ _ _
|
||||||
local random_pitch_multiplier = {-1,1}
|
local random_pitch_multiplier = {-1,1}
|
||||||
|
|
||||||
mobs.projectile_attack_fly = function(self, dtime)
|
mobs.projectile_attack_fly = function(self, dtime)
|
||||||
|
|
||||||
--this needs an exception
|
--this needs an exception
|
||||||
if self.attacking == nil or not self.attacking:is_player() then
|
if self.attacking == nil or not self.attacking:is_player() then
|
||||||
self.attacking = nil
|
self.attacking = nil
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
local disable_physics = function(object, luaentity, ignore_check, reset_movement)
|
local math = math
|
||||||
|
local vector = vector
|
||||||
|
|
||||||
|
local function disable_physics(object, luaentity, ignore_check, reset_movement)
|
||||||
if luaentity.physical_state == true or ignore_check == true then
|
if luaentity.physical_state == true or ignore_check == true then
|
||||||
luaentity.physical_state = false
|
luaentity.physical_state = false
|
||||||
object:set_properties({
|
object:set_properties({
|
||||||
|
@ -12,7 +15,7 @@ local disable_physics = function(object, luaentity, ignore_check, reset_movement
|
||||||
end
|
end
|
||||||
|
|
||||||
----For Water Flowing:
|
----For Water Flowing:
|
||||||
local enable_physics = function(object, luaentity, ignore_check)
|
local function enable_physics(object, luaentity, ignore_check)
|
||||||
if luaentity.physical_state == false or ignore_check == true then
|
if luaentity.physical_state == false or ignore_check == true then
|
||||||
luaentity.physical_state = true
|
luaentity.physical_state = true
|
||||||
object:set_properties({
|
object:set_properties({
|
||||||
|
@ -272,7 +275,7 @@ local falling = function(self, pos)
|
||||||
|
|
||||||
self.object:set_acceleration({
|
self.object:set_acceleration({
|
||||||
x = 0,
|
x = 0,
|
||||||
y = -self.fall_speed / (math_max(1, v.y) ^ 2),
|
y = -self.fall_speed / (math.max(1, v.y) ^ 2),
|
||||||
z = 0
|
z = 0
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -503,9 +506,9 @@ local follow_flop = function(self)
|
||||||
if sdef and sdef.walkable then
|
if sdef and sdef.walkable then
|
||||||
mob_sound(self, "flop")
|
mob_sound(self, "flop")
|
||||||
self.object:set_velocity({
|
self.object:set_velocity({
|
||||||
x = math_random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED),
|
x = math.random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED),
|
||||||
y = FLOP_HEIGHT,
|
y = FLOP_HEIGHT,
|
||||||
z = math_random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED),
|
z = math.random(-FLOP_HOR_SPEED, FLOP_HOR_SPEED),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -987,7 +990,7 @@ local check_for_death = function(self, cause, cmi_cause)
|
||||||
item_drop(self, cooked, looting)
|
item_drop(self, cooked, looting)
|
||||||
|
|
||||||
if mod_experience and ((not self.child) or self.type ~= "animal") and (minetest_get_us_time() - self.xp_timestamp <= 5000000) then
|
if mod_experience and ((not self.child) or self.type ~= "animal") and (minetest_get_us_time() - self.xp_timestamp <= 5000000) then
|
||||||
mcl_experience.throw_experience(self.object:get_pos(), math_random(self.xp_min, self.xp_max))
|
mcl_experience.throw_experience(self.object:get_pos(), math.random(self.xp_min, self.xp_max))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1361,7 +1364,7 @@ local do_attack = function(self, player)
|
||||||
self.state = "attack"
|
self.state = "attack"
|
||||||
|
|
||||||
-- TODO: Implement war_cry sound without being annoying
|
-- TODO: Implement war_cry sound without being annoying
|
||||||
--if math_random(0, 100) < 90 then
|
--if math.random(0, 100) < 90 then
|
||||||
--mob_sound(self, "war_cry", true)
|
--mob_sound(self, "war_cry", true)
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
|
@ -1396,7 +1399,7 @@ local mob_sound = function(self, soundname, is_opinion, fixed_pitch)
|
||||||
pitch = base_pitch
|
pitch = base_pitch
|
||||||
end
|
end
|
||||||
-- randomize the pitch a bit
|
-- randomize the pitch a bit
|
||||||
pitch = pitch + math_random(-10, 10) * 0.005
|
pitch = pitch + math.random(-10, 10) * 0.005
|
||||||
end
|
end
|
||||||
minetest_sound_play(sound, {
|
minetest_sound_play(sound, {
|
||||||
object = self.object,
|
object = self.object,
|
||||||
|
@ -1699,7 +1702,7 @@ local do_env_damage = function(self)
|
||||||
end
|
end
|
||||||
if drowning then
|
if drowning then
|
||||||
|
|
||||||
self.breath = math_max(0, self.breath - 1)
|
self.breath = math.max(0, self.breath - 1)
|
||||||
|
|
||||||
effect(pos, 2, "bubble.png", nil, nil, 1, nil)
|
effect(pos, 2, "bubble.png", nil, nil, 1, nil)
|
||||||
if self.breath <= 0 then
|
if self.breath <= 0 then
|
||||||
|
@ -2044,7 +2047,7 @@ local breed = function(self)
|
||||||
|
|
||||||
-- Give XP
|
-- Give XP
|
||||||
if mod_experience then
|
if mod_experience then
|
||||||
mcl_experience.throw_experience(pos, math_random(1, 7))
|
mcl_experience.throw_experience(pos, math.random(1, 7))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- custom breed function
|
-- custom breed function
|
||||||
|
@ -2061,7 +2064,7 @@ local breed = function(self)
|
||||||
|
|
||||||
|
|
||||||
-- Use texture of one of the parents
|
-- Use texture of one of the parents
|
||||||
local p = math_random(1, 2)
|
local p = math.random(1, 2)
|
||||||
if p == 1 then
|
if p == 1 then
|
||||||
ent_c.base_texture = parent1.base_texture
|
ent_c.base_texture = parent1.base_texture
|
||||||
else
|
else
|
||||||
|
@ -2091,7 +2094,7 @@ local replace = function(self, pos)
|
||||||
or not self.replace_what
|
or not self.replace_what
|
||||||
or self.child == true
|
or self.child == true
|
||||||
or self.object:get_velocity().y ~= 0
|
or self.object:get_velocity().y ~= 0
|
||||||
or math_random(1, self.replace_rate) > 1 then
|
or math.random(1, self.replace_rate) > 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2099,7 +2102,7 @@ local replace = function(self, pos)
|
||||||
|
|
||||||
if type(self.replace_what[1]) == "table" then
|
if type(self.replace_what[1]) == "table" then
|
||||||
|
|
||||||
local num = math_random(#self.replace_what)
|
local num = math.random(#self.replace_what)
|
||||||
|
|
||||||
what = self.replace_what[num][1] or ""
|
what = self.replace_what[num][1] or ""
|
||||||
with = self.replace_what[num][2] or ""
|
with = self.replace_what[num][2] or ""
|
||||||
|
@ -2163,7 +2166,7 @@ function do_states(self)
|
||||||
|
|
||||||
if self.state == "stand" then
|
if self.state == "stand" then
|
||||||
|
|
||||||
if math_random(1, 4) == 1 then
|
if math.random(1, 4) == 1 then
|
||||||
|
|
||||||
local lp = nil
|
local lp = nil
|
||||||
local s = self.object:get_pos()
|
local s = self.object:get_pos()
|
||||||
|
@ -2189,7 +2192,7 @@ function do_states(self)
|
||||||
|
|
||||||
if lp.x > s.x then yaw = yaw + math_pi end
|
if lp.x > s.x then yaw = yaw + math_pi end
|
||||||
else
|
else
|
||||||
yaw = yaw + math_random(-0.5, 0.5)
|
yaw = yaw + math.random(-0.5, 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
yaw = set_yaw(self, yaw, 8)
|
yaw = set_yaw(self, yaw, 8)
|
||||||
|
@ -2204,7 +2207,7 @@ function do_states(self)
|
||||||
|
|
||||||
if self.walk_chance ~= 0
|
if self.walk_chance ~= 0
|
||||||
and self.facing_fence ~= true
|
and self.facing_fence ~= true
|
||||||
and math_random(1, 100) <= self.walk_chance
|
and math.random(1, 100) <= self.walk_chance
|
||||||
and is_at_cliff_or_danger(self) == false then
|
and is_at_cliff_or_danger(self) == false then
|
||||||
|
|
||||||
set_velocity(self, self.walk_velocity)
|
set_velocity(self, self.walk_velocity)
|
||||||
|
@ -2254,7 +2257,7 @@ function do_states(self)
|
||||||
{x = s.x + 5, y = s.y + 1, z = s.z + 5},
|
{x = s.x + 5, y = s.y + 1, z = s.z + 5},
|
||||||
{"group:solid"})
|
{"group:solid"})
|
||||||
|
|
||||||
lp = #lp > 0 and lp[math_random(#lp)]
|
lp = #lp > 0 and lp[math.random(#lp)]
|
||||||
|
|
||||||
-- did we find land?
|
-- did we find land?
|
||||||
if lp then
|
if lp then
|
||||||
|
@ -2280,8 +2283,8 @@ function do_states(self)
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Randomly turn
|
-- Randomly turn
|
||||||
if math_random(1, 100) <= 30 then
|
if math.random(1, 100) <= 30 then
|
||||||
yaw = yaw + math_random(-0.5, 0.5)
|
yaw = yaw + math.random(-0.5, 0.5)
|
||||||
yaw = set_yaw(self, yaw, 8)
|
yaw = set_yaw(self, yaw, 8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2289,9 +2292,9 @@ function do_states(self)
|
||||||
yaw = set_yaw(self, yaw, 8)
|
yaw = set_yaw(self, yaw, 8)
|
||||||
|
|
||||||
-- otherwise randomly turn
|
-- otherwise randomly turn
|
||||||
elseif math_random(1, 100) <= 30 then
|
elseif math.random(1, 100) <= 30 then
|
||||||
|
|
||||||
yaw = yaw + math_random(-0.5, 0.5)
|
yaw = yaw + math.random(-0.5, 0.5)
|
||||||
yaw = set_yaw(self, yaw, 8)
|
yaw = set_yaw(self, yaw, 8)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2302,7 +2305,7 @@ function do_states(self)
|
||||||
end
|
end
|
||||||
if self.facing_fence == true
|
if self.facing_fence == true
|
||||||
or cliff_or_danger
|
or cliff_or_danger
|
||||||
or math_random(1, 100) <= 30 then
|
or math.random(1, 100) <= 30 then
|
||||||
|
|
||||||
set_velocity(self, 0)
|
set_velocity(self, 0)
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
|
@ -2602,7 +2605,7 @@ function do_states(self)
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
|
|
||||||
if self.double_melee_attack
|
if self.double_melee_attack
|
||||||
and math_random(1, 2) == 1 then
|
and math.random(1, 2) == 1 then
|
||||||
set_animation(self, "punch2")
|
set_animation(self, "punch2")
|
||||||
else
|
else
|
||||||
set_animation(self, "punch")
|
set_animation(self, "punch")
|
||||||
|
@ -2669,7 +2672,7 @@ function do_states(self)
|
||||||
if self.shoot_interval
|
if self.shoot_interval
|
||||||
and self.timer > self.shoot_interval
|
and self.timer > self.shoot_interval
|
||||||
and not minetest_raycast(p, self.attack:get_pos(), false, false):next()
|
and not minetest_raycast(p, self.attack:get_pos(), false, false):next()
|
||||||
and math_random(1, 100) <= 60 then
|
and math.random(1, 100) <= 60 then
|
||||||
|
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
set_animation(self, "shoot")
|
set_animation(self, "shoot")
|
||||||
|
@ -2759,7 +2762,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
-- Code to execute before custom on_rightclick handling
|
-- Code to execute before custom on_rightclick handling
|
||||||
local on_rightclick_prefix = function(self, clicker)
|
local function on_rightclick_prefix(self, clicker)
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
|
|
||||||
-- Name mob with nametag
|
-- Name mob with nametag
|
||||||
|
@ -2785,17 +2788,17 @@ local on_rightclick_prefix = function(self, clicker)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local create_mob_on_rightclick = function(on_rightclick)
|
--[[local function create_mob_on_rightclick(on_rightclick)
|
||||||
return function(self, clicker)
|
return function(self, clicker)
|
||||||
local stop = on_rightclick_prefix(self, clicker)
|
local stop = on_rightclick_prefix(self, clicker)
|
||||||
if (not stop) and (on_rightclick) then
|
if (not stop) and (on_rightclick) then
|
||||||
on_rightclick(self, clicker)
|
on_rightclick(self, clicker)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end]]
|
||||||
|
|
||||||
-- set and return valid yaw
|
-- set and return valid yaw
|
||||||
local set_yaw = function(self, yaw, delay, dtime)
|
local function set_yaw(self, yaw, delay, dtime)
|
||||||
|
|
||||||
if not yaw or yaw ~= yaw then
|
if not yaw or yaw ~= yaw then
|
||||||
yaw = 0
|
yaw = 0
|
||||||
|
@ -2805,7 +2808,7 @@ local set_yaw = function(self, yaw, delay, dtime)
|
||||||
|
|
||||||
if delay == 0 then
|
if delay == 0 then
|
||||||
if self.shaking and dtime then
|
if self.shaking and dtime then
|
||||||
yaw = yaw + (math_random() * 2 - 1) * 5 * dtime
|
yaw = yaw + (math.random() * 2 - 1) * 5 * dtime
|
||||||
end
|
end
|
||||||
self.yaw(yaw)
|
self.yaw(yaw)
|
||||||
update_roll(self)
|
update_roll(self)
|
||||||
|
@ -2825,8 +2828,7 @@ function mobs:yaw(self, yaw, delay, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
mob_step = function()
|
--mob_step = function()
|
||||||
|
|
||||||
--if self.state == "die" then
|
--if self.state == "die" then
|
||||||
-- print("need custom die stop moving thing")
|
-- print("need custom die stop moving thing")
|
||||||
-- return
|
-- return
|
||||||
|
@ -2901,7 +2903,7 @@ mob_step = function()
|
||||||
--end
|
--end
|
||||||
|
|
||||||
-- mob plays random sound at times
|
-- mob plays random sound at times
|
||||||
--if math_random(1, 70) == 1 then
|
--if math.random(1, 70) == 1 then
|
||||||
-- mob_sound(self, "random", true)
|
-- mob_sound(self, "random", true)
|
||||||
--end
|
--end
|
||||||
|
|
||||||
|
@ -2934,11 +2936,11 @@ mob_step = function()
|
||||||
|
|
||||||
|
|
||||||
--if is_at_water_danger(self) and self.state ~= "attack" then
|
--if is_at_water_danger(self) and self.state ~= "attack" then
|
||||||
-- if math_random(1, 10) <= 6 then
|
-- if math.random(1, 10) <= 6 then
|
||||||
-- set_velocity(self, 0)
|
-- set_velocity(self, 0)
|
||||||
-- self.state = "stand"
|
-- self.state = "stand"
|
||||||
-- set_animation(self, "stand")
|
-- set_animation(self, "stand")
|
||||||
-- yaw = yaw + math_random(-0.5, 0.5)
|
-- yaw = yaw + math.random(-0.5, 0.5)
|
||||||
-- yaw = set_yaw(self, yaw, 8)
|
-- yaw = set_yaw(self, yaw, 8)
|
||||||
-- end
|
-- end
|
||||||
--end
|
--end
|
||||||
|
@ -2982,7 +2984,7 @@ mob_step = function()
|
||||||
mcl_burning.extinguish(self.object)
|
mcl_burning.extinguish(self.object)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
elseif self.lifetimer <= 10 then
|
elseif self.lifetimer <= 10 then
|
||||||
if math_random(10) < 4 then
|
if math.random(10) < 4 then
|
||||||
self.despawn_immediately = true
|
self.despawn_immediately = true
|
||||||
else
|
else
|
||||||
self.lifetimer = 20
|
self.lifetimer = 20
|
||||||
|
@ -2991,4 +2993,4 @@ mob_step = function()
|
||||||
end
|
end
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
end
|
--end
|
|
@ -1,14 +1,13 @@
|
||||||
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
|
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
|
||||||
|
|
||||||
local vector_distance = vector.distance
|
local vector = vector
|
||||||
|
|
||||||
--check to see if someone nearby has some tasty food
|
--check to see if someone nearby has some tasty food
|
||||||
mobs.check_following = function(self) -- returns true or false
|
mobs.check_following = function(self) -- returns true or false
|
||||||
|
|
||||||
--ignore
|
--ignore
|
||||||
if not self.follow then
|
if not self.follow then
|
||||||
self.following_person = nil
|
self.following_person = nil
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--hey look, this thing works for passive mobs too!
|
--hey look, this thing works for passive mobs too!
|
||||||
|
@ -20,20 +19,20 @@ mobs.check_following = function(self) -- returns true or false
|
||||||
--safety check
|
--safety check
|
||||||
if not stack then
|
if not stack then
|
||||||
self.following_person = nil
|
self.following_person = nil
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local item_name = stack:get_name()
|
local item_name = stack:get_name()
|
||||||
--all checks have passed, that guy has some good looking food
|
--all checks have passed, that guy has some good looking food
|
||||||
if item_name == self.follow then
|
if item_name == self.follow then
|
||||||
self.following_person = follower
|
self.following_person = follower
|
||||||
return(true)
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--everything failed
|
--everything failed
|
||||||
self.following_person = nil
|
self.following_person = nil
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--a function which attempts to make mobs enter
|
--a function which attempts to make mobs enter
|
||||||
|
@ -42,25 +41,25 @@ mobs.enter_breed_state = function(self,clicker)
|
||||||
|
|
||||||
--do not breed if baby
|
--do not breed if baby
|
||||||
if self.baby then
|
if self.baby then
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--do not do anything if looking for mate or
|
--do not do anything if looking for mate or
|
||||||
--if cooling off from breeding
|
--if cooling off from breeding
|
||||||
if self.breed_lookout_timer > 0 or self.breed_timer > 0 then
|
if self.breed_lookout_timer > 0 or self.breed_timer > 0 then
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--if this is caught, that means something has gone
|
--if this is caught, that means something has gone
|
||||||
--seriously wrong
|
--seriously wrong
|
||||||
if not clicker or not clicker:is_player() then
|
if not clicker or not clicker:is_player() then
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local stack = clicker:get_wielded_item()
|
local stack = clicker:get_wielded_item()
|
||||||
--safety check
|
--safety check
|
||||||
if not stack then
|
if not stack then
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local item_name = stack:get_name()
|
local item_name = stack:get_name()
|
||||||
|
@ -73,11 +72,11 @@ mobs.enter_breed_state = function(self,clicker)
|
||||||
self.breed_lookout_timer = self.breed_lookout_timer_goal
|
self.breed_lookout_timer = self.breed_lookout_timer_goal
|
||||||
self.bred = true
|
self.bred = true
|
||||||
mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic")
|
mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic")
|
||||||
return(true)
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
--everything failed
|
--everything failed
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,15 +103,15 @@ mobs.look_for_mate = function(self)
|
||||||
|
|
||||||
local pos2 = mate:get_pos()
|
local pos2 = mate:get_pos()
|
||||||
|
|
||||||
local distance = vector_distance(pos1,pos2)
|
local distance = vector.distance(pos1,pos2)
|
||||||
|
|
||||||
if distance <= radius then
|
if distance <= radius then
|
||||||
if line_of_sight then
|
if minetest.line_of_sight then
|
||||||
--must add eye height or stuff breaks randomly because of
|
--must add eye height or stuff breaks randomly because of
|
||||||
--seethrough nodes being a blocker (like grass)
|
--seethrough nodes being a blocker (like grass)
|
||||||
if minetest_line_of_sight(
|
if minetest.line_of_sight(
|
||||||
vector_new(pos1.x, pos1.y, pos1.z),
|
vector.new(pos1.x, pos1.y, pos1.z),
|
||||||
vector_new(pos2.x, pos2.y + mate:get_properties().eye_height, pos2.z)
|
vector.new(pos2.x, pos2.y + mate:get_properties().eye_height, pos2.z)
|
||||||
) then
|
) then
|
||||||
mates_detected = mates_detected + 1
|
mates_detected = mates_detected + 1
|
||||||
mates_in_area[mate] = distance
|
mates_in_area[mate] = distance
|
||||||
|
@ -141,9 +140,7 @@ mobs.look_for_mate = function(self)
|
||||||
winner_mate = mate
|
winner_mate = mate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return winner_mate
|
||||||
return(winner_mate)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--make the baby grow up
|
--make the baby grow up
|
||||||
|
@ -161,7 +158,7 @@ mobs.make_baby_grow_faster = function(self,clicker)
|
||||||
local stack = clicker:get_wielded_item()
|
local stack = clicker:get_wielded_item()
|
||||||
--safety check
|
--safety check
|
||||||
if not stack then
|
if not stack then
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local item_name = stack:get_name()
|
local item_name = stack:get_name()
|
||||||
|
@ -175,10 +172,8 @@ mobs.make_baby_grow_faster = function(self,clicker)
|
||||||
end
|
end
|
||||||
|
|
||||||
mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic")
|
mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic")
|
||||||
|
return true
|
||||||
return(true)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
return(false)
|
|
||||||
end
|
end
|
|
@ -8,10 +8,8 @@ local vector_direction = vector.direction
|
||||||
local integer_test = {-1,1}
|
local integer_test = {-1,1}
|
||||||
|
|
||||||
mobs.collision = function(self)
|
mobs.collision = function(self)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
|
|
||||||
if not self or not self.object or not self.object:get_luaentity() then
|
if not self or not self.object or not self.object:get_luaentity() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -104,11 +102,9 @@ mobs.collision = function(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.object:add_velocity(vel1)
|
self.object:add_velocity(vel1)
|
||||||
object:add_velocity(vel2)
|
object:add_velocity(vel2)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -116,7 +112,6 @@ end
|
||||||
|
|
||||||
--this is used for arrow collisions
|
--this is used for arrow collisions
|
||||||
mobs.arrow_hit = function(self, player)
|
mobs.arrow_hit = function(self, player)
|
||||||
|
|
||||||
player:punch(self.object, 1.0, {
|
player:punch(self.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = self._damage}
|
damage_groups = {fleshy = self._damage}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local minetest_add_item = minetest.add_item
|
local minetest_add_item = minetest.add_item
|
||||||
local minetest_sound_play = minetest.sound_play
|
--local minetest_sound_play = minetest.sound_play
|
||||||
|
|
||||||
local math_pi = math.pi
|
local math_pi = math.pi
|
||||||
local math_random = math.random
|
local math_random = math.random
|
||||||
|
@ -19,7 +19,7 @@ local item_drop = function(self, cooked, looting_level)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local obj, item, num
|
local obj, item
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
self.drops = self.drops or {} -- nil check
|
self.drops = self.drops or {} -- nil check
|
||||||
|
@ -56,8 +56,11 @@ local item_drop = function(self, cooked, looting_level)
|
||||||
-- cook items when true
|
-- cook items when true
|
||||||
if cooked then
|
if cooked then
|
||||||
|
|
||||||
local output = minetest_get_craft_result({
|
local output = minetest.get_craft_result({
|
||||||
method = "cooking", width = 1, items = {item}})
|
method = "cooking",
|
||||||
|
width = 1,
|
||||||
|
items = {item},
|
||||||
|
})
|
||||||
|
|
||||||
if output and output.item and not output.item:is_empty() then
|
if output and output.item and not output.item:is_empty() then
|
||||||
item = output.item:get_name()
|
item = output.item:get_name()
|
||||||
|
@ -117,15 +120,10 @@ mobs.death_logic = function(self, dtime)
|
||||||
|
|
||||||
--the final POOF of a mob despawning
|
--the final POOF of a mob despawning
|
||||||
if self.death_animation_timer >= 1.25 then
|
if self.death_animation_timer >= 1.25 then
|
||||||
|
|
||||||
item_drop(self,false,1)
|
item_drop(self,false,1)
|
||||||
|
|
||||||
mobs.death_effect(self)
|
mobs.death_effect(self)
|
||||||
|
|
||||||
mcl_experience.throw_experience(self.object:get_pos(), math_random(self.xp_min, self.xp_max))
|
mcl_experience.throw_experience(self.object:get_pos(), math_random(self.xp_min, self.xp_max))
|
||||||
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local minetest_line_of_sight = minetest.line_of_sight
|
local minetest_line_of_sight = minetest.line_of_sight
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
--local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||||
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
||||||
local minetest_get_node = minetest.get_node
|
local minetest_get_node = minetest.get_node
|
||||||
local minetest_get_item_group = minetest.get_item_group
|
local minetest_get_item_group = minetest.get_item_group
|
||||||
|
@ -18,19 +18,16 @@ local table_copy = table.copy
|
||||||
local math_abs = math.abs
|
local math_abs = math.abs
|
||||||
|
|
||||||
-- default function when mobs are blown up with TNT
|
-- default function when mobs are blown up with TNT
|
||||||
local do_tnt = function(obj, damage)
|
--[[local function do_tnt(obj, damage)
|
||||||
|
|
||||||
obj.object:punch(obj.object, 1.0, {
|
obj.object:punch(obj.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = damage},
|
damage_groups = {fleshy = damage},
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
return false, true, {}
|
return false, true, {}
|
||||||
end
|
end]]
|
||||||
|
|
||||||
--a fast function to be able to detect only players without using objects_in_radius
|
--a fast function to be able to detect only players without using objects_in_radius
|
||||||
mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, object_height_adder)
|
mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, object_height_adder)
|
||||||
|
|
||||||
local pos1 = self.object:get_pos()
|
local pos1 = self.object:get_pos()
|
||||||
local players_in_area = {}
|
local players_in_area = {}
|
||||||
local winner_player = nil
|
local winner_player = nil
|
||||||
|
@ -79,8 +76,7 @@ mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius,
|
||||||
winner_player = player
|
winner_player = player
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return winner_player
|
||||||
return(winner_player)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,14 +103,13 @@ mobs.jump_check = function(self,dtime)
|
||||||
|
|
||||||
if green_flag_1 and green_flag_2 then
|
if green_flag_1 and green_flag_2 then
|
||||||
--can jump over node
|
--can jump over node
|
||||||
return(1)
|
return 1
|
||||||
elseif green_flag_1 and not green_flag_2 then
|
elseif green_flag_1 and not green_flag_2 then
|
||||||
--wall in front of mob
|
--wall in front of mob
|
||||||
return(2)
|
return 2
|
||||||
end
|
end
|
||||||
|
|
||||||
--nothing to jump over
|
--nothing to jump over
|
||||||
return(0)
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- a helper function to quickly turn neutral passive mobs hostile
|
-- a helper function to quickly turn neutral passive mobs hostile
|
||||||
|
@ -180,15 +175,10 @@ end
|
||||||
-- check if within physical map limits (-30911 to 30927)
|
-- check if within physical map limits (-30911 to 30927)
|
||||||
-- within_limits, wmin, wmax = nil, -30913, 30928
|
-- within_limits, wmin, wmax = nil, -30913, 30928
|
||||||
mobs.within_limits = function(pos, radius)
|
mobs.within_limits = function(pos, radius)
|
||||||
|
local wmin, wmax
|
||||||
if mcl_vars then
|
if mcl_vars then
|
||||||
if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then
|
if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then
|
||||||
wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max
|
wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max
|
||||||
within_limits = function(pos, radius)
|
|
||||||
return pos
|
|
||||||
and (pos.x - radius) > wmin and (pos.x + radius) < wmax
|
|
||||||
and (pos.y - radius) > wmin and (pos.y + radius) < wmax
|
|
||||||
and (pos.z - radius) > wmin and (pos.z + radius) < wmax
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return pos
|
return pos
|
||||||
|
@ -231,12 +221,12 @@ mobs.check_for_player_within_area = function(self, radius)
|
||||||
local distance = vector_distance(pos1,pos2)
|
local distance = vector_distance(pos1,pos2)
|
||||||
if distance < radius then
|
if distance < radius then
|
||||||
--found a player
|
--found a player
|
||||||
return(true)
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--did not find a player
|
--did not find a player
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -244,7 +234,7 @@ end
|
||||||
mobs.get_2d_distance = function(pos1,pos2)
|
mobs.get_2d_distance = function(pos1,pos2)
|
||||||
pos1.y = 0
|
pos1.y = 0
|
||||||
pos2.y = 0
|
pos2.y = 0
|
||||||
return(vector_distance(pos1, pos2))
|
return vector_distance(pos1, pos2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- fall damage onto solid ground
|
-- fall damage onto solid ground
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
local vector_new = vector.new
|
local math = math
|
||||||
|
local vector = vector
|
||||||
|
|
||||||
--converts yaw to degrees
|
--converts yaw to degrees
|
||||||
local degrees = function(yaw)
|
local degrees = function(yaw)
|
||||||
return(yaw*180.0/math.pi)
|
return yaw*180.0/math.pi
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
mobs.do_head_logic = function(self,dtime)
|
mobs.do_head_logic = function(self,dtime)
|
||||||
|
|
||||||
local player = minetest.get_player_by_name("singleplayer")
|
local player = minetest.get_player_by_name("singleplayer")
|
||||||
|
@ -14,25 +13,18 @@ mobs.do_head_logic = function(self,dtime)
|
||||||
local look_at = player:get_pos()
|
local look_at = player:get_pos()
|
||||||
look_at.y = look_at.y + player:get_properties().eye_height
|
look_at.y = look_at.y + player:get_properties().eye_height
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
local body_yaw = self.object:get_yaw()
|
local body_yaw = self.object:get_yaw()
|
||||||
|
|
||||||
local body_dir = minetest.yaw_to_dir(body_yaw)
|
local body_dir = minetest.yaw_to_dir(body_yaw)
|
||||||
|
|
||||||
|
|
||||||
pos.y = pos.y + self.head_height_offset
|
pos.y = pos.y + self.head_height_offset
|
||||||
|
|
||||||
local head_offset = vector.multiply(body_dir, self.head_direction_offset)
|
local head_offset = vector.multiply(body_dir, self.head_direction_offset)
|
||||||
|
|
||||||
pos = vector.add(pos, head_offset)
|
pos = vector.add(pos, head_offset)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = pos,
|
pos = pos,
|
||||||
velocity = {x=0, y=0, z=0},
|
velocity = {x=0, y=0, z=0},
|
||||||
|
@ -42,9 +34,7 @@ mobs.do_head_logic = function(self,dtime)
|
||||||
texture = "default_dirt.png",
|
texture = "default_dirt.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local bone_pos = vector.new(0,0,0)
|
||||||
local bone_pos = vector_new(0,0,0)
|
|
||||||
|
|
||||||
|
|
||||||
--(horizontal)
|
--(horizontal)
|
||||||
bone_pos.y = self.head_bone_pos_y
|
bone_pos.y = self.head_bone_pos_y
|
||||||
|
@ -59,9 +49,7 @@ mobs.do_head_logic = function(self,dtime)
|
||||||
--bone_rot.x = bone_rot.x + (dtime * 10)
|
--bone_rot.x = bone_rot.x + (dtime * 10)
|
||||||
--bone_rot.z = bone_rot.z + (dtime * 10)
|
--bone_rot.z = bone_rot.z + (dtime * 10)
|
||||||
|
|
||||||
|
local head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw
|
||||||
local head_yaw
|
|
||||||
head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw
|
|
||||||
|
|
||||||
if self.reverse_head_yaw then
|
if self.reverse_head_yaw then
|
||||||
head_yaw = head_yaw * -1
|
head_yaw = head_yaw * -1
|
||||||
|
@ -102,11 +90,9 @@ mobs.do_head_logic = function(self,dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.swap_y_with_x then
|
if self.swap_y_with_x then
|
||||||
self.object:set_bone_position(self.head_bone, bone_pos, vector_new(degrees(head_pitch),degrees(head_yaw),0))
|
self.object:set_bone_position(self.head_bone, bone_pos, vector.new(degrees(head_pitch),degrees(head_yaw),0))
|
||||||
else
|
else
|
||||||
self.object:set_bone_position(self.head_bone, bone_pos, vector_new(degrees(head_pitch),0,degrees(head_yaw)))
|
self.object:set_bone_position(self.head_bone, bone_pos, vector.new(degrees(head_pitch),0,degrees(head_yaw)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--set_bone_position([bone, position, rotation])
|
--set_bone_position([bone, position, rotation])
|
||||||
end
|
end
|
|
@ -2,22 +2,19 @@ local minetest_after = minetest.after
|
||||||
local minetest_sound_play = minetest.sound_play
|
local minetest_sound_play = minetest.sound_play
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||||
|
|
||||||
local math_floor = math.floor
|
local math = math
|
||||||
local math_min = math.min
|
local vector = vector
|
||||||
local math_random = math.random
|
|
||||||
|
|
||||||
local vector_direction = vector.direction
|
|
||||||
local vector_multiply = vector.multiply
|
|
||||||
|
|
||||||
local MAX_MOB_NAME_LENGTH = 30
|
local MAX_MOB_NAME_LENGTH = 30
|
||||||
|
|
||||||
|
local mod_hunger = minetest.get_modpath("mcl_hunger")
|
||||||
|
|
||||||
mobs.feed_tame = function(self)
|
mobs.feed_tame = function(self)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Code to execute before custom on_rightclick handling
|
-- Code to execute before custom on_rightclick handling
|
||||||
local on_rightclick_prefix = function(self, clicker)
|
local function on_rightclick_prefix(self, clicker)
|
||||||
|
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
|
|
||||||
-- Name mob with nametag
|
-- Name mob with nametag
|
||||||
|
@ -60,7 +57,6 @@ end
|
||||||
|
|
||||||
-- deal damage and effects when mob punched
|
-- deal damage and effects when mob punched
|
||||||
mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
|
|
||||||
--don't do anything if the mob is already dead
|
--don't do anything if the mob is already dead
|
||||||
if self.health <= 0 then
|
if self.health <= 0 then
|
||||||
return
|
return
|
||||||
|
@ -94,14 +90,13 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
pos2.y = 0
|
pos2.y = 0
|
||||||
|
|
||||||
|
|
||||||
local dir = vector_direction(pos2,pos1)
|
local dir = vector.direction(pos2,pos1)
|
||||||
|
|
||||||
local yaw = minetest_dir_to_yaw(dir)
|
local yaw = minetest_dir_to_yaw(dir)
|
||||||
|
|
||||||
self.yaw = yaw
|
self.yaw = yaw
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- custom punch function
|
-- custom punch function
|
||||||
if self.do_punch then
|
if self.do_punch then
|
||||||
-- when false skip going any further
|
-- when false skip going any further
|
||||||
|
@ -115,21 +110,18 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- error checking when mod profiling is enabled
|
-- error checking when mod profiling is enabled
|
||||||
if not tool_capabilities then
|
if not tool_capabilities then
|
||||||
minetest.log("warning", "[mobs_mc] Mod profiling enabled, damage not enabled")
|
minetest.log("warning", "[mobs_mc] Mod profiling enabled, damage not enabled")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local is_player = hitter:is_player()
|
local is_player = hitter:is_player()
|
||||||
|
|
||||||
|
|
||||||
-- punch interval
|
-- punch interval
|
||||||
local weapon = hitter:get_wielded_item()
|
local weapon = hitter:get_wielded_item()
|
||||||
|
|
||||||
local punch_interval = 1.4
|
--local punch_interval = 1.4
|
||||||
|
|
||||||
-- exhaust attacker
|
-- exhaust attacker
|
||||||
if mod_hunger and is_player then
|
if mod_hunger and is_player then
|
||||||
|
@ -139,7 +131,6 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
-- calculate mob damage
|
-- calculate mob damage
|
||||||
local damage = 0
|
local damage = 0
|
||||||
local armor = self.object:get_armor_groups() or {}
|
local armor = self.object:get_armor_groups() or {}
|
||||||
local tmp
|
|
||||||
|
|
||||||
--calculate damage groups
|
--calculate damage groups
|
||||||
for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do
|
for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do
|
||||||
|
@ -163,13 +154,13 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
|
|
||||||
-- healing
|
-- healing
|
||||||
if damage <= -1 then
|
if damage <= -1 then
|
||||||
self.health = self.health - math_floor(damage)
|
self.health = self.health - math.floor(damage)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if tool_capabilities then
|
--if tool_capabilities then
|
||||||
punch_interval = tool_capabilities.full_punch_interval or 1.4
|
-- punch_interval = tool_capabilities.full_punch_interval or 1.4
|
||||||
end
|
--end
|
||||||
|
|
||||||
-- add weapon wear manually
|
-- add weapon wear manually
|
||||||
-- Required because we have custom health handling ("health" property)
|
-- Required because we have custom health handling ("health" property)
|
||||||
|
@ -183,7 +174,7 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
local weapon = hitter:get_wielded_item(player)
|
local weapon = hitter:get_wielded_item(player)
|
||||||
local def = weapon:get_definition()
|
local def = weapon:get_definition()
|
||||||
if def.tool_capabilities and def.tool_capabilities.punch_attack_uses then
|
if def.tool_capabilities and def.tool_capabilities.punch_attack_uses then
|
||||||
local wear = math_floor(65535/tool_capabilities.punch_attack_uses)
|
local wear = math.floor(65535/tool_capabilities.punch_attack_uses)
|
||||||
weapon:add_wear(wear)
|
weapon:add_wear(wear)
|
||||||
hitter:set_wielded_item(weapon)
|
hitter:set_wielded_item(weapon)
|
||||||
end
|
end
|
||||||
|
@ -240,7 +231,6 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
up = 0
|
up = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--0.75 for perfect distance to not be too easy, and not be too hard
|
--0.75 for perfect distance to not be too easy, and not be too hard
|
||||||
local multiplier = 0.75
|
local multiplier = 0.75
|
||||||
|
|
||||||
|
@ -255,20 +245,15 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
if self.hostile then
|
if self.hostile then
|
||||||
multiplier = multiplier + 2
|
multiplier = multiplier + 2
|
||||||
end
|
end
|
||||||
|
dir = vector.multiply(dir,multiplier)
|
||||||
dir = vector_multiply(dir,multiplier)
|
|
||||||
|
|
||||||
dir.y = up
|
dir.y = up
|
||||||
|
|
||||||
--add the velocity
|
--add the velocity
|
||||||
self.object:add_velocity(dir)
|
self.object:add_velocity(dir)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--do internal per mob projectile calculations
|
--do internal per mob projectile calculations
|
||||||
mobs.shoot_projectile = function(self)
|
mobs.shoot_projectile = function(self)
|
||||||
|
|
||||||
local pos1 = self.object:get_pos()
|
local pos1 = self.object:get_pos()
|
||||||
--add mob eye height
|
--add mob eye height
|
||||||
pos1.y = pos1.y + self.eye_height
|
pos1.y = pos1.y + self.eye_height
|
||||||
|
@ -278,7 +263,7 @@ mobs.shoot_projectile = function(self)
|
||||||
pos2.y = pos2.y + self.attacking:get_properties().eye_height
|
pos2.y = pos2.y + self.attacking:get_properties().eye_height
|
||||||
|
|
||||||
--get direction
|
--get direction
|
||||||
local dir = vector_direction(pos1,pos2)
|
local dir = vector.direction(pos1,pos2)
|
||||||
|
|
||||||
--call internal shoot_arrow function
|
--call internal shoot_arrow function
|
||||||
self.shoot_arrow(self,pos1,dir)
|
self.shoot_arrow(self,pos1,dir)
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
local minetest_add_particlespawner = minetest.add_particlespawner
|
local minetest_add_particlespawner = minetest.add_particlespawner
|
||||||
|
|
||||||
mobs.death_effect = function(self)
|
mobs.death_effect = function(self)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local yaw = self.object:get_yaw()
|
--local yaw = self.object:get_yaw()
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
|
|
||||||
local min, max
|
local min, max
|
||||||
|
@ -33,7 +32,7 @@ end
|
||||||
mobs.critical_effect = function(self)
|
mobs.critical_effect = function(self)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local yaw = self.object:get_yaw()
|
--local yaw = self.object:get_yaw()
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
|
|
||||||
local min, max
|
local min, max
|
||||||
|
@ -62,9 +61,8 @@ end
|
||||||
|
|
||||||
--when feeding a mob
|
--when feeding a mob
|
||||||
mobs.feed_effect = function(self)
|
mobs.feed_effect = function(self)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local yaw = self.object:get_yaw()
|
--local yaw = self.object:get_yaw()
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
|
|
||||||
local min, max
|
local min, max
|
||||||
|
@ -94,7 +92,7 @@ end
|
||||||
--hearts when tamed
|
--hearts when tamed
|
||||||
mobs.tamed_effect = function(self)
|
mobs.tamed_effect = function(self)
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local yaw = self.object:get_yaw()
|
--local yaw = self.object:get_yaw()
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
|
|
||||||
local min, max
|
local min, max
|
||||||
|
@ -124,7 +122,7 @@ end
|
||||||
--hearts when breeding
|
--hearts when breeding
|
||||||
mobs.breeding_effect = function(self)
|
mobs.breeding_effect = function(self)
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local yaw = self.object:get_yaw()
|
--local yaw = self.object:get_yaw()
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
local collisionbox = self.object:get_properties().collisionbox
|
||||||
|
|
||||||
local min, max
|
local min, max
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
local math_pi = math.pi
|
-- localize math functions
|
||||||
local math_sin = math.sin
|
local math = math
|
||||||
local math_cos = math.cos
|
local HALF_PI = math.pi / 2
|
||||||
local math_random = math.random
|
local DOUBLE_PI = math.pi * 2
|
||||||
local HALF_PI = math_pi / 2
|
|
||||||
local DOUBLE_PI = math_pi * 2
|
|
||||||
|
|
||||||
-- localize vector functions
|
-- localize vector functions
|
||||||
local vector_new = vector.new
|
local vector = vector
|
||||||
local vector_length = vector.length
|
|
||||||
local vector_multiply = vector.multiply
|
|
||||||
local vector_distance = vector.distance
|
|
||||||
local vector_normalize = vector.normalize
|
|
||||||
|
|
||||||
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||||
|
@ -19,18 +13,17 @@ local DEFAULT_JUMP_HEIGHT = 5
|
||||||
local DEFAULT_FLOAT_SPEED = 4
|
local DEFAULT_FLOAT_SPEED = 4
|
||||||
local DEFAULT_CLIMB_SPEED = 3
|
local DEFAULT_CLIMB_SPEED = 3
|
||||||
|
|
||||||
|
|
||||||
mobs.stick_in_cobweb = function(self)
|
mobs.stick_in_cobweb = function(self)
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
|
||||||
local goal_velocity = vector_multiply(vector_normalize(current_velocity), 0.4)
|
local goal_velocity = vector.multiply(vector.normalize(current_velocity), 0.4)
|
||||||
|
|
||||||
goal_velocity.y = -0.5
|
goal_velocity.y = -0.5
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
||||||
|
|
||||||
--smooths out mobs a bit
|
--smooths out mobs a bit
|
||||||
if vector_length(new_velocity_addition) >= 0.0001 then
|
if vector.length(new_velocity_addition) >= 0.0001 then
|
||||||
self.object:add_velocity(new_velocity_addition)
|
self.object:add_velocity(new_velocity_addition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -38,8 +31,11 @@ end
|
||||||
--this is a generic float function
|
--this is a generic float function
|
||||||
mobs.float = function(self)
|
mobs.float = function(self)
|
||||||
|
|
||||||
if self.object:get_acceleration().y ~= 0 then
|
local acceleration = self.object:get_acceleration()
|
||||||
self.object:set_acceleration(vector_new(0,0,0))
|
if acceleration and acceleration.y ~= 0 then
|
||||||
|
self.object:set_acceleration(vector.new(0,0,0))
|
||||||
|
else
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
@ -56,7 +52,7 @@ mobs.float = function(self)
|
||||||
new_velocity_addition.z = 0
|
new_velocity_addition.z = 0
|
||||||
|
|
||||||
--smooths out mobs a bit
|
--smooths out mobs a bit
|
||||||
if vector_length(new_velocity_addition) >= 0.0001 then
|
if vector.length(new_velocity_addition) >= 0.0001 then
|
||||||
self.object:add_velocity(new_velocity_addition)
|
self.object:add_velocity(new_velocity_addition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -78,7 +74,7 @@ mobs.climb = function(self)
|
||||||
new_velocity_addition.z = 0
|
new_velocity_addition.z = 0
|
||||||
|
|
||||||
--smooths out mobs a bit
|
--smooths out mobs a bit
|
||||||
if vector_length(new_velocity_addition) >= 0.0001 then
|
if vector.length(new_velocity_addition) >= 0.0001 then
|
||||||
self.object:add_velocity(new_velocity_addition)
|
self.object:add_velocity(new_velocity_addition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -106,22 +102,22 @@ mobs.set_velocity = function(self, v)
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
|
||||||
local goal_velocity = {
|
local goal_velocity = {
|
||||||
x = (math_sin(yaw) * -v),
|
x = (math.sin(yaw) * -v),
|
||||||
y = 0,
|
y = 0,
|
||||||
z = (math_cos(yaw) * v),
|
z = (math.cos(yaw) * v),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
||||||
|
|
||||||
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
|
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
||||||
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
|
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
||||||
end
|
end
|
||||||
|
|
||||||
new_velocity_addition.y = 0
|
new_velocity_addition.y = 0
|
||||||
|
|
||||||
--smooths out mobs a bit
|
--smooths out mobs a bit
|
||||||
if vector_length(new_velocity_addition) >= 0.0001 then
|
if vector.length(new_velocity_addition) >= 0.0001 then
|
||||||
self.object:add_velocity(new_velocity_addition)
|
self.object:add_velocity(new_velocity_addition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -136,7 +132,7 @@ mobs.get_velocity = function(self)
|
||||||
v.y = 0
|
v.y = 0
|
||||||
|
|
||||||
if v then
|
if v then
|
||||||
return vector_length(v)
|
return vector.length(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -152,7 +148,7 @@ mobs.jump = function(self, velocity)
|
||||||
--fallback velocity to allow modularity
|
--fallback velocity to allow modularity
|
||||||
velocity = velocity or DEFAULT_JUMP_HEIGHT
|
velocity = velocity or DEFAULT_JUMP_HEIGHT
|
||||||
|
|
||||||
self.object:add_velocity(vector_new(0,velocity,0))
|
self.object:add_velocity(vector.new(0,velocity,0))
|
||||||
end
|
end
|
||||||
|
|
||||||
--make mobs fall slowly
|
--make mobs fall slowly
|
||||||
|
@ -172,15 +168,15 @@ mobs.mob_fall_slow = function(self)
|
||||||
new_velocity_addition.x = 0
|
new_velocity_addition.x = 0
|
||||||
new_velocity_addition.z = 0
|
new_velocity_addition.z = 0
|
||||||
|
|
||||||
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
|
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
||||||
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
|
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
||||||
end
|
end
|
||||||
|
|
||||||
new_velocity_addition.x = 0
|
new_velocity_addition.x = 0
|
||||||
new_velocity_addition.z = 0
|
new_velocity_addition.z = 0
|
||||||
|
|
||||||
--smooths out mobs a bit
|
--smooths out mobs a bit
|
||||||
if vector_length(new_velocity_addition) >= 0.0001 then
|
if vector.length(new_velocity_addition) >= 0.0001 then
|
||||||
self.object:add_velocity(new_velocity_addition)
|
self.object:add_velocity(new_velocity_addition)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -212,13 +208,13 @@ mobs.flop = function(self, velocity)
|
||||||
velocity = velocity or DEFAULT_JUMP_HEIGHT
|
velocity = velocity or DEFAULT_JUMP_HEIGHT
|
||||||
|
|
||||||
--create a random direction (2d yaw)
|
--create a random direction (2d yaw)
|
||||||
local dir = DOUBLE_PI * math_random()
|
local dir = DOUBLE_PI * math.random()
|
||||||
|
|
||||||
--create a random force value
|
--create a random force value
|
||||||
local force = math_random(0,3) + math_random()
|
local force = math.random(0,3) + math.random()
|
||||||
|
|
||||||
--convert the yaw to a direction vector then multiply it times the force
|
--convert the yaw to a direction vector then multiply it times the force
|
||||||
local final_additional_force = vector_multiply(minetest_yaw_to_dir(dir), force)
|
local final_additional_force = vector.multiply(minetest_yaw_to_dir(dir), force)
|
||||||
|
|
||||||
--place in the "flop" velocity to make the mob flop
|
--place in the "flop" velocity to make the mob flop
|
||||||
final_additional_force.y = velocity
|
final_additional_force.y = velocity
|
||||||
|
@ -246,20 +242,20 @@ mobs.set_swim_velocity = function(self, v)
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
|
||||||
local goal_velocity = {
|
local goal_velocity = {
|
||||||
x = (math_sin(yaw) * -v),
|
x = (math.sin(yaw) * -v),
|
||||||
y = pitch,
|
y = pitch,
|
||||||
z = (math_cos(yaw) * v),
|
z = (math.cos(yaw) * v),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
||||||
|
|
||||||
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
|
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
||||||
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
|
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
||||||
end
|
end
|
||||||
|
|
||||||
--smooths out mobs a bit
|
--smooths out mobs a bit
|
||||||
if vector_length(new_velocity_addition) >= 0.0001 then
|
if vector.length(new_velocity_addition) >= 0.0001 then
|
||||||
self.object:add_velocity(new_velocity_addition)
|
self.object:add_velocity(new_velocity_addition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -291,20 +287,20 @@ mobs.set_fly_velocity = function(self, v)
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
|
||||||
local goal_velocity = {
|
local goal_velocity = {
|
||||||
x = (math_sin(yaw) * -v),
|
x = (math.sin(yaw) * -v),
|
||||||
y = pitch,
|
y = pitch,
|
||||||
z = (math_cos(yaw) * v),
|
z = (math.cos(yaw) * v),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
||||||
|
|
||||||
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
|
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
||||||
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
|
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
||||||
end
|
end
|
||||||
|
|
||||||
--smooths out mobs a bit
|
--smooths out mobs a bit
|
||||||
if vector_length(new_velocity_addition) >= 0.0001 then
|
if vector.length(new_velocity_addition) >= 0.0001 then
|
||||||
self.object:add_velocity(new_velocity_addition)
|
self.object:add_velocity(new_velocity_addition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -316,7 +312,7 @@ mobs.calculate_pitch = function(pos1, pos2)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return(minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos1.x,0,pos1.z),vector_new(pos2.x,0,pos2.z)),0,pos1.y - pos2.y)) + HALF_PI)
|
return minetest_dir_to_yaw(vector.new(vector.distance(vector.new(pos1.x,0,pos1.z),vector.new(pos2.x,0,pos2.z)),0,pos1.y - pos2.y)) + HALF_PI
|
||||||
end
|
end
|
||||||
|
|
||||||
--make mobs fly up or down based on their y difference
|
--make mobs fly up or down based on their y difference
|
||||||
|
@ -353,27 +349,27 @@ mobs.jump_move = function(self, velocity)
|
||||||
mobs.set_velocity(self,0)
|
mobs.set_velocity(self,0)
|
||||||
|
|
||||||
--fallback velocity to allow modularity
|
--fallback velocity to allow modularity
|
||||||
jump_height = DEFAULT_JUMP_HEIGHT
|
local jump_height = DEFAULT_JUMP_HEIGHT
|
||||||
|
|
||||||
local yaw = (self.yaw or 0)
|
local yaw = (self.yaw or 0)
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
local current_velocity = self.object:get_velocity()
|
||||||
|
|
||||||
local goal_velocity = {
|
local goal_velocity = {
|
||||||
x = (math_sin(yaw) * -velocity),
|
x = (math.sin(yaw) * -velocity),
|
||||||
y = jump_height,
|
y = jump_height,
|
||||||
z = (math_cos(yaw) * velocity),
|
z = (math.cos(yaw) * velocity),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
||||||
|
|
||||||
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
|
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
||||||
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
|
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
||||||
end
|
end
|
||||||
|
|
||||||
--smooths out mobs a bit
|
--smooths out mobs a bit
|
||||||
if vector_length(new_velocity_addition) >= 0.0001 then
|
if vector.length(new_velocity_addition) >= 0.0001 then
|
||||||
self.object:add_velocity(new_velocity_addition)
|
self.object:add_velocity(new_velocity_addition)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,9 +2,11 @@ local math_random = math.random
|
||||||
|
|
||||||
local minetest_settings = minetest.settings
|
local minetest_settings = minetest.settings
|
||||||
|
|
||||||
|
-- CMI support check
|
||||||
|
local use_cmi = minetest.global_exists("cmi")
|
||||||
|
|
||||||
-- get entity staticdata
|
-- get entity staticdata
|
||||||
mobs.mob_staticdata = function(self)
|
mobs.mob_staticdata = function(self)
|
||||||
|
|
||||||
--despawn mechanism
|
--despawn mechanism
|
||||||
--don't despawned tamed or bred mobs
|
--don't despawned tamed or bred mobs
|
||||||
if not self.tamed and not self.bred then
|
if not self.tamed and not self.bred then
|
||||||
|
@ -142,8 +144,6 @@ mobs.mob_activate = function(self, staticdata, def, dtime)
|
||||||
self.health = math_random (self.hp_min, self.hp_max)
|
self.health = math_random (self.hp_min, self.hp_max)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not self.random_sound_timer then
|
if not self.random_sound_timer then
|
||||||
self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max)
|
self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max)
|
||||||
end
|
end
|
||||||
|
@ -186,7 +186,6 @@ mobs.mob_activate = function(self, staticdata, def, dtime)
|
||||||
|
|
||||||
self.texture_mods = {}
|
self.texture_mods = {}
|
||||||
|
|
||||||
|
|
||||||
self.v_start = false
|
self.v_start = false
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
self.blinktimer = 0
|
self.blinktimer = 0
|
||||||
|
@ -200,7 +199,6 @@ mobs.mob_activate = function(self, staticdata, def, dtime)
|
||||||
self.object:set_texture_mod("")
|
self.object:set_texture_mod("")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- set anything changed above
|
-- set anything changed above
|
||||||
self.object:set_properties(self)
|
self.object:set_properties(self)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
|
||||||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||||
|
|
||||||
local enable_crash = false
|
--local enable_crash = false
|
||||||
local crash_threshold = 6.5 -- ignored if enable_crash=false
|
--local crash_threshold = 6.5 -- ignored if enable_crash=false
|
||||||
|
|
||||||
|
local math = math
|
||||||
|
local vector = vector
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -10,7 +13,7 @@ local crash_threshold = 6.5 -- ignored if enable_crash=false
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
--
|
--
|
||||||
|
|
||||||
local node_ok = function(pos, fallback)
|
--[[local function node_ok(pos, fallback)
|
||||||
|
|
||||||
fallback = fallback or mobs.fallback_node
|
fallback = fallback or mobs.fallback_node
|
||||||
|
|
||||||
|
@ -21,10 +24,10 @@ local node_ok = function(pos, fallback)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {name = fallback}
|
return {name = fallback}
|
||||||
end
|
end]]
|
||||||
|
|
||||||
|
|
||||||
local function node_is(pos)
|
--[[local function node_is(pos)
|
||||||
|
|
||||||
local node = node_ok(pos)
|
local node = node_ok(pos)
|
||||||
|
|
||||||
|
@ -45,7 +48,7 @@ local function node_is(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
return "other"
|
return "other"
|
||||||
end
|
end]]
|
||||||
|
|
||||||
|
|
||||||
local function get_sign(i)
|
local function get_sign(i)
|
||||||
|
@ -60,13 +63,11 @@ local function get_sign(i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function get_velocity(v, yaw, y)
|
--[[local function get_velocity(v, yaw, y)
|
||||||
|
|
||||||
local x = -math.sin(yaw) * v
|
local x = -math.sin(yaw) * v
|
||||||
local z = math.cos(yaw) * v
|
local z = math.cos(yaw) * v
|
||||||
|
|
||||||
return {x = x, y = y, z = z}
|
return {x = x, y = y, z = z}
|
||||||
end
|
end]]
|
||||||
|
|
||||||
|
|
||||||
local function get_v(v)
|
local function get_v(v)
|
||||||
|
@ -187,13 +188,13 @@ end
|
||||||
|
|
||||||
function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
|
|
||||||
local rot_view = 0
|
--local rot_view = 0
|
||||||
|
|
||||||
if entity.player_rotation.y == 90 then
|
--if entity.player_rotation.y == 90 then
|
||||||
rot_view = math.pi/2
|
-- rot_view = math.pi/2
|
||||||
end
|
--end
|
||||||
|
|
||||||
local acce_y = 0
|
--local acce_y = 0
|
||||||
local velo = entity.object:get_velocity()
|
local velo = entity.object:get_velocity()
|
||||||
|
|
||||||
entity.v = get_v(velo) * get_sign(entity.v)
|
entity.v = get_v(velo) * get_sign(entity.v)
|
||||||
|
@ -388,7 +389,6 @@ end
|
||||||
-- directional flying routine by D00Med (edited by TenPlus1)
|
-- directional flying routine by D00Med (edited by TenPlus1)
|
||||||
|
|
||||||
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
||||||
|
|
||||||
if true then
|
if true then
|
||||||
print("succ")
|
print("succ")
|
||||||
return
|
return
|
||||||
|
|
|
@ -9,9 +9,9 @@ local get_objects_inside_radius = minetest.get_objects_inside_radius
|
||||||
|
|
||||||
local math_random = math.random
|
local math_random = math.random
|
||||||
local math_floor = math.floor
|
local math_floor = math.floor
|
||||||
local max = math.max
|
--local max = math.max
|
||||||
|
|
||||||
local vector_distance = vector.distance
|
--local vector_distance = vector.distance
|
||||||
local vector_new = vector.new
|
local vector_new = vector.new
|
||||||
local vector_floor = vector.floor
|
local vector_floor = vector.floor
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ Overworld regular:
|
||||||
|
|
||||||
|
|
||||||
-- count how many mobs are in an area
|
-- count how many mobs are in an area
|
||||||
local count_mobs = function(pos)
|
local function count_mobs(pos)
|
||||||
local num = 0
|
local num = 0
|
||||||
for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do
|
for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do
|
||||||
if object and object:get_luaentity() and object:get_luaentity()._cmi_is_mob then
|
if object and object:get_luaentity() and object:get_luaentity()._cmi_is_mob then
|
||||||
|
@ -242,8 +242,7 @@ function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_ligh
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
local spawn_action
|
local function spawn_action(pos, node, active_object_count, active_object_count_wider, name)
|
||||||
spawn_action = function(pos, node, active_object_count, active_object_count_wider, name)
|
|
||||||
|
|
||||||
local orig_pos = table.copy(pos)
|
local orig_pos = table.copy(pos)
|
||||||
-- is mob actually registered?
|
-- is mob actually registered?
|
||||||
|
@ -486,7 +485,8 @@ local axis
|
||||||
local inner = 15
|
local inner = 15
|
||||||
local outer = 64
|
local outer = 64
|
||||||
local int = {-1,1}
|
local int = {-1,1}
|
||||||
local position_calculation = function(pos)
|
|
||||||
|
local function position_calculation(pos)
|
||||||
|
|
||||||
pos = vector_floor(pos)
|
pos = vector_floor(pos)
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ local position_calculation = function(pos)
|
||||||
pos.z = pos.z + math_random(inner,outer)*int[math_random(1,2)]
|
pos.z = pos.z + math_random(inner,outer)*int[math_random(1,2)]
|
||||||
pos.x = pos.x + math_random(-outer,outer)
|
pos.x = pos.x + math_random(-outer,outer)
|
||||||
end
|
end
|
||||||
return(pos)
|
return pos
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
|
@ -2,4 +2,4 @@ name = mcl_mobs
|
||||||
author = PilzAdam
|
author = PilzAdam
|
||||||
description = Adds a mob API for mods to add animals or monsters, etc.
|
description = Adds a mob API for mods to add animals or monsters, etc.
|
||||||
depends = mcl_particles
|
depends = mcl_particles
|
||||||
optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience
|
optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience
|
||||||
|
|
|
@ -13,7 +13,7 @@ minetest.log("info", "[mcl_moon] Moon phase offset of this world: "..phase_offse
|
||||||
mcl_moon = {}
|
mcl_moon = {}
|
||||||
mcl_moon.MOON_PHASES = MOON_PHASES
|
mcl_moon.MOON_PHASES = MOON_PHASES
|
||||||
|
|
||||||
mcl_moon.get_moon_phase = function()
|
function mcl_moon.get_moon_phase()
|
||||||
local after_midday = 0
|
local after_midday = 0
|
||||||
-- Moon phase changes after midday
|
-- Moon phase changes after midday
|
||||||
local tod = minetest.get_timeofday()
|
local tod = minetest.get_timeofday()
|
||||||
|
@ -23,7 +23,7 @@ mcl_moon.get_moon_phase = function()
|
||||||
return (minetest.get_day_count() + phase_offset + after_midday) % MOON_PHASES
|
return (minetest.get_day_count() + phase_offset + after_midday) % MOON_PHASES
|
||||||
end
|
end
|
||||||
|
|
||||||
local get_moon_texture = function()
|
local function get_moon_texture()
|
||||||
local phase = mcl_moon.get_moon_phase()
|
local phase = mcl_moon.get_moon_phase()
|
||||||
local x = phase % MOON_PHASES_HALF
|
local x = phase % MOON_PHASES_HALF
|
||||||
local y
|
local y
|
||||||
|
|
|
@ -20,7 +20,7 @@ mcl_weather.rain = {
|
||||||
init_done = false,
|
init_done = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
mcl_weather.rain.sound_handler = function(player)
|
function mcl_weather.rain.sound_handler(player)
|
||||||
return minetest.sound_play("weather_rain", {
|
return minetest.sound_play("weather_rain", {
|
||||||
to_player = player:get_player_name(),
|
to_player = player:get_player_name(),
|
||||||
loop = true,
|
loop = true,
|
||||||
|
@ -28,7 +28,7 @@ mcl_weather.rain.sound_handler = function(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set skybox based on time (uses skycolor api)
|
-- set skybox based on time (uses skycolor api)
|
||||||
mcl_weather.rain.set_sky_box = function()
|
function mcl_weather.rain.set_sky_box()
|
||||||
if mcl_weather.state == "rain" then
|
if mcl_weather.state == "rain" then
|
||||||
mcl_weather.skycolor.add_layer(
|
mcl_weather.skycolor.add_layer(
|
||||||
"weather-pack-rain-sky",
|
"weather-pack-rain-sky",
|
||||||
|
@ -46,8 +46,7 @@ end
|
||||||
|
|
||||||
-- creating manually parctiles instead of particles spawner because of easier to control
|
-- creating manually parctiles instead of particles spawner because of easier to control
|
||||||
-- spawn position.
|
-- spawn position.
|
||||||
mcl_weather.rain.add_rain_particles = function(player)
|
function mcl_weather.rain.add_rain_particles(player)
|
||||||
|
|
||||||
mcl_weather.rain.last_rp_count = 0
|
mcl_weather.rain.last_rp_count = 0
|
||||||
for i=mcl_weather.rain.particles_count, 1,-1 do
|
for i=mcl_weather.rain.particles_count, 1,-1 do
|
||||||
local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player)
|
local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player)
|
||||||
|
@ -70,7 +69,7 @@ mcl_weather.rain.add_rain_particles = function(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Simple random texture getter
|
-- Simple random texture getter
|
||||||
mcl_weather.rain.get_texture = function()
|
function mcl_weather.rain.get_texture()
|
||||||
local texture_name
|
local texture_name
|
||||||
local random_number = math.random()
|
local random_number = math.random()
|
||||||
if random_number > 0.33 then
|
if random_number > 0.33 then
|
||||||
|
@ -85,7 +84,7 @@ end
|
||||||
|
|
||||||
-- register player for rain weather.
|
-- register player for rain weather.
|
||||||
-- basically needs for origin sky reference and rain sound controls.
|
-- basically needs for origin sky reference and rain sound controls.
|
||||||
mcl_weather.rain.add_player = function(player)
|
function mcl_weather.rain.add_player(player)
|
||||||
if mcl_weather.players[player:get_player_name()] == nil then
|
if mcl_weather.players[player:get_player_name()] == nil then
|
||||||
local player_meta = {}
|
local player_meta = {}
|
||||||
player_meta.origin_sky = {player:get_sky()}
|
player_meta.origin_sky = {player:get_sky()}
|
||||||
|
@ -95,7 +94,7 @@ end
|
||||||
|
|
||||||
-- remove player from player list effected by rain.
|
-- remove player from player list effected by rain.
|
||||||
-- be sure to remove sound before removing player otherwise soundhandler reference will be lost.
|
-- be sure to remove sound before removing player otherwise soundhandler reference will be lost.
|
||||||
mcl_weather.rain.remove_player = function(player)
|
function mcl_weather.rain.remove_player(player)
|
||||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||||
if player_meta ~= nil and player_meta.origin_sky ~= nil then
|
if player_meta ~= nil and player_meta.origin_sky ~= nil then
|
||||||
player:set_clouds({color="#FFF0F0E5"})
|
player:set_clouds({color="#FFF0F0E5"})
|
||||||
|
@ -119,7 +118,7 @@ end)
|
||||||
-- adds and removes rain sound depending how much rain particles around player currently exist.
|
-- adds and removes rain sound depending how much rain particles around player currently exist.
|
||||||
-- have few seconds delay before each check to avoid on/off sound too often
|
-- have few seconds delay before each check to avoid on/off sound too often
|
||||||
-- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance.
|
-- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance.
|
||||||
mcl_weather.rain.update_sound = function(player)
|
function mcl_weather.rain.update_sound(player)
|
||||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||||
if player_meta ~= nil then
|
if player_meta ~= nil then
|
||||||
if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then
|
if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then
|
||||||
|
@ -140,7 +139,7 @@ mcl_weather.rain.update_sound = function(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- rain sound removed from player.
|
-- rain sound removed from player.
|
||||||
mcl_weather.rain.remove_sound = function(player)
|
function mcl_weather.rain.remove_sound(player)
|
||||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||||
if player_meta ~= nil and player_meta.sound_handler ~= nil then
|
if player_meta ~= nil and player_meta.sound_handler ~= nil then
|
||||||
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
|
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
|
||||||
|
@ -150,7 +149,7 @@ mcl_weather.rain.remove_sound = function(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- callback function for removing rain
|
-- callback function for removing rain
|
||||||
mcl_weather.rain.clear = function()
|
function mcl_weather.rain.clear()
|
||||||
mcl_weather.rain.raining = false
|
mcl_weather.rain.raining = false
|
||||||
mcl_weather.rain.sky_last_update = -1
|
mcl_weather.rain.sky_last_update = -1
|
||||||
mcl_weather.rain.init_done = false
|
mcl_weather.rain.init_done = false
|
||||||
|
@ -166,11 +165,10 @@ minetest.register_globalstep(function(dtime)
|
||||||
if mcl_weather.state ~= "rain" then
|
if mcl_weather.state ~= "rain" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_weather.rain.make_weather()
|
mcl_weather.rain.make_weather()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
mcl_weather.rain.make_weather = function()
|
function mcl_weather.rain.make_weather()
|
||||||
if mcl_weather.rain.init_done == false then
|
if mcl_weather.rain.init_done == false then
|
||||||
mcl_weather.rain.raining = true
|
mcl_weather.rain.raining = true
|
||||||
mcl_weather.rain.set_sky_box()
|
mcl_weather.rain.set_sky_box()
|
||||||
|
@ -190,7 +188,7 @@ mcl_weather.rain.make_weather = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Switch the number of raindrops: "thunder" for many raindrops, otherwise for normal raindrops
|
-- Switch the number of raindrops: "thunder" for many raindrops, otherwise for normal raindrops
|
||||||
mcl_weather.rain.set_particles_mode = function(mode)
|
function mcl_weather.rain.set_particles_mode(mode)
|
||||||
if mode == "thunder" then
|
if mode == "thunder" then
|
||||||
mcl_weather.rain.particles_count = PARTICLES_COUNT_THUNDER
|
mcl_weather.rain.particles_count = PARTICLES_COUNT_THUNDER
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
local S = minetest.get_translator("hudbars")
|
local modname = minetest.get_current_modname()
|
||||||
|
local modpath = minetest.get_modpath(modname)
|
||||||
|
|
||||||
|
local S = minetest.get_translator(modname)
|
||||||
local N = function(s) return s end
|
local N = function(s) return s end
|
||||||
|
|
||||||
hb = {}
|
local math = math
|
||||||
|
local table = table
|
||||||
hb.hudtables = {}
|
|
||||||
|
|
||||||
|
hb = {
|
||||||
|
hudtables = {},
|
||||||
-- number of registered HUD bars
|
-- number of registered HUD bars
|
||||||
hb.hudbars_count = 0
|
hudbars_count = 0,
|
||||||
|
|
||||||
-- table which records which HUD bar slots have been “registered” so far; used for automatic positioning
|
-- table which records which HUD bar slots have been “registered” so far; used for automatic positioning
|
||||||
hb.registered_slots = {}
|
registered_slots = {},
|
||||||
|
settings = {},
|
||||||
hb.settings = {}
|
-- Table which contains all players with active default HUD bars (only for internal use)
|
||||||
|
players = {},
|
||||||
|
}
|
||||||
|
|
||||||
function hb.load_setting(sname, stype, defaultval, valid_values)
|
function hb.load_setting(sname, stype, defaultval, valid_values)
|
||||||
local sval
|
local sval
|
||||||
|
@ -45,7 +50,8 @@ function hb.load_setting(sname, stype, defaultval, valid_values)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load default settings
|
-- Load default settings
|
||||||
dofile(minetest.get_modpath("hudbars").."/default_settings.lua")
|
dofile(modpath.."/default_settings.lua")
|
||||||
|
|
||||||
if minetest.get_modpath("mcl_experience") and not minetest.is_creative_enabled("") then
|
if minetest.get_modpath("mcl_experience") and not minetest.is_creative_enabled("") then
|
||||||
-- reserve some space for experience bar:
|
-- reserve some space for experience bar:
|
||||||
hb.settings.start_offset_left.y = hb.settings.start_offset_left.y - 20
|
hb.settings.start_offset_left.y = hb.settings.start_offset_left.y - 20
|
||||||
|
@ -85,9 +91,6 @@ local function make_label(format_string, format_string_config, label, start_valu
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Table which contains all players with active default HUD bars (only for internal use)
|
|
||||||
hb.players = {}
|
|
||||||
|
|
||||||
function hb.value_to_barlength(value, max)
|
function hb.value_to_barlength(value, max)
|
||||||
if max == 0 then
|
if max == 0 then
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -237,12 +237,10 @@ mcl_damage.register_on_damage(function(obj, damage, reason)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
local new_assist = {}
|
|
||||||
|
|
||||||
for obj, tbl in pairs(mcl_death_messages.assist) do
|
for obj, tbl in pairs(mcl_death_messages.assist) do
|
||||||
tbl.timeout = tbl.timeout - dtime
|
tbl.timeout = tbl.timeout - dtime
|
||||||
if (obj:is_player() or obj:get_luaentity()) and tbl.timeout > 0 then
|
if not obj:is_player() and not obj:get_luaentity() or tbl.timeout > 0 then
|
||||||
new_assist[obj] = tbl
|
mcl_death_messages.assist[obj] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -120,9 +120,9 @@ end
|
||||||
hud_manager.hud_exists = function(player,hud_name)
|
hud_manager.hud_exists = function(player,hud_name)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if player_huds[name] and player_huds[name][hud_name] then
|
if player_huds[name] and player_huds[name][hud_name] then
|
||||||
return(true)
|
return true
|
||||||
else
|
else
|
||||||
return(false)
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-------------------
|
-------------------
|
||||||
|
@ -150,7 +150,7 @@ end)
|
||||||
|
|
||||||
function mcl_experience.get_player_xp_level(player)
|
function mcl_experience.get_player_xp_level(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
return(pool[name].level)
|
return pool[name].level
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_experience.set_player_xp_level(player,level)
|
function mcl_experience.set_player_xp_level(player,level)
|
||||||
|
|
|
@ -1,31 +1,34 @@
|
||||||
local S = minetest.get_translator("mcl_hbarmor")
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
|
||||||
local mcl_hbarmor = {}
|
local math = math
|
||||||
|
local tonumber = tonumber
|
||||||
|
|
||||||
|
local get_connected_players = minetest.get_connected_players
|
||||||
|
|
||||||
|
local mcl_hbarmor = {
|
||||||
-- HUD statbar values
|
-- HUD statbar values
|
||||||
mcl_hbarmor.armor = {}
|
armor = {},
|
||||||
|
|
||||||
-- Stores if player's HUD bar has been initialized so far.
|
-- Stores if player's HUD bar has been initialized so far.
|
||||||
mcl_hbarmor.player_active = {}
|
player_active = {},
|
||||||
|
|
||||||
-- Time difference in seconds between updates to the HUD armor bar.
|
-- Time difference in seconds between updates to the HUD armor bar.
|
||||||
-- Increase this number for slow servers.
|
-- Increase this number for slow servers.
|
||||||
mcl_hbarmor.tick = 0.1
|
tick = 0.1,
|
||||||
|
|
||||||
-- If true, the armor bar is hidden when the player does not wear any armor
|
-- If true, the armor bar is hidden when the player does not wear any armor
|
||||||
mcl_hbarmor.autohide = true
|
autohide = true,
|
||||||
|
}
|
||||||
|
|
||||||
set = minetest.settings:get("mcl_hbarmor_tick")
|
local tick_config = minetest.settings:get("mcl_hbarmor_tick")
|
||||||
if tonumber(set) ~= nil then
|
|
||||||
mcl_hbarmor.tick = tonumber(set)
|
if tonumber(tick_config) ~= nil then
|
||||||
|
mcl_hbarmor.tick = tonumber(tick_config)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local must_hide = function(playername, arm)
|
local function must_hide(playername, arm)
|
||||||
return arm == 0
|
return arm == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local arm_printable = function(arm)
|
local function arm_printable(arm)
|
||||||
return math.ceil(math.floor(arm+0.5))
|
return math.ceil(math.floor(arm+0.5))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -106,12 +109,13 @@ end)
|
||||||
local main_timer = 0
|
local main_timer = 0
|
||||||
local timer = 0
|
local timer = 0
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
--TODO: replace this by playerglobalstep API then implemented
|
||||||
main_timer = main_timer + dtime
|
main_timer = main_timer + dtime
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
if main_timer > mcl_hbarmor.tick or timer > 4 then
|
if main_timer > mcl_hbarmor.tick or timer > 4 then
|
||||||
if minetest.settings:get_bool("enable_damage") then
|
if minetest.settings:get_bool("enable_damage") then
|
||||||
if main_timer > mcl_hbarmor.tick then main_timer = 0 end
|
if main_timer > mcl_hbarmor.tick then main_timer = 0 end
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(get_connected_players()) do
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if mcl_hbarmor.player_active[name] == true then
|
if mcl_hbarmor.player_active[name] == true then
|
||||||
local ret = mcl_hbarmor.get_armor(player)
|
local ret = mcl_hbarmor.get_armor(player)
|
||||||
|
|
|
@ -96,12 +96,12 @@ local function rules_from_dir(ruleset, dir)
|
||||||
if dir.z == -1 then return ruleset.zn end
|
if dir.z == -1 then return ruleset.zn end
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.rules.buttonlike_get = function(node)
|
function mesecon.rules.buttonlike_get(node)
|
||||||
local dir = minetest.facedir_to_dir(node.param2)
|
local dir = minetest.facedir_to_dir(node.param2)
|
||||||
return rules_from_dir(rules_buttonlike, dir)
|
return rules_from_dir(rules_buttonlike, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.rules.wallmounted_get = function(node)
|
function mesecon.rules.wallmounted_get(node)
|
||||||
local dir = minetest.wallmounted_to_dir(node.param2)
|
local dir = minetest.wallmounted_to_dir(node.param2)
|
||||||
return rules_from_dir(rules_wallmounted, dir)
|
return rules_from_dir(rules_wallmounted, dir)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-- Dig and place services
|
-- Dig and place services
|
||||||
|
|
||||||
mesecon.on_placenode = function(pos, node)
|
function mesecon.on_placenode(pos, node)
|
||||||
mesecon.execute_autoconnect_hooks_now(pos, node)
|
mesecon.execute_autoconnect_hooks_now(pos, node)
|
||||||
|
|
||||||
-- Receptors: Send on signal when active
|
-- Receptors: Send on signal when active
|
||||||
|
@ -70,7 +70,7 @@ mesecon.on_placenode = function(pos, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.on_dignode = function(pos, node)
|
function mesecon.on_dignode(pos, node)
|
||||||
if mesecon.is_conductor_on(node) then
|
if mesecon.is_conductor_on(node) then
|
||||||
mesecon.receptor_off(pos, mesecon.conductor_get_rules(node))
|
mesecon.receptor_off(pos, mesecon.conductor_get_rules(node))
|
||||||
elseif mesecon.is_receptor_on(node.name) then
|
elseif mesecon.is_receptor_on(node.name) then
|
||||||
|
@ -95,7 +95,7 @@ mesecon.on_dignode = function(pos, node)
|
||||||
mesecon.execute_autoconnect_hooks_queue(pos, node)
|
mesecon.execute_autoconnect_hooks_queue(pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.on_blastnode = function(pos, node)
|
function mesecon.on_blastnode(pos, node)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
mesecon.on_dignode(pos, node)
|
mesecon.on_dignode(pos, node)
|
||||||
|
|
|
@ -21,7 +21,7 @@ local boxes_on = {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Push the button
|
-- Push the button
|
||||||
mesecon.push_button = function(pos, node)
|
function mesecon.push_button(pos, node)
|
||||||
-- No-op if button is already pushed
|
-- No-op if button is already pushed
|
||||||
if mesecon.is_receptor_on(node) then
|
if mesecon.is_receptor_on(node) then
|
||||||
return
|
return
|
||||||
|
|
|
@ -68,7 +68,7 @@ mcl_damage.register_modifier(function(obj, damage, reason)
|
||||||
|
|
||||||
if do_irregular_damage or thorns_damage_regular < 4 and math.random() < enchantments.thorns * 0.15 then
|
if do_irregular_damage or thorns_damage_regular < 4 and math.random() < enchantments.thorns * 0.15 then
|
||||||
if do_irregular_damage then
|
if do_irregular_damage then
|
||||||
thorns_damage_irregular = thorns_damage_irregular + throrns_level - 10
|
thorns_damage_irregular = thorns_damage_irregular + enchantments.thorns - 10
|
||||||
else
|
else
|
||||||
thorns_damage_regular = math.min(4, thorns_damage_regular + math.random(4))
|
thorns_damage_regular = math.min(4, thorns_damage_regular + math.random(4))
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
-- Crafting definition
|
-- Crafting definition
|
||||||
--
|
--
|
||||||
|
|
||||||
local craft_planks = function(output, input)
|
local function craft_planks(output, input)
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_core:"..output.."wood 4",
|
output = "mcl_core:"..output.."wood 4",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
|
|
@ -53,7 +53,7 @@ minetest.register_abm({
|
||||||
--
|
--
|
||||||
|
|
||||||
-- Functions
|
-- Functions
|
||||||
mcl_core.grow_cactus = function(pos, node)
|
function mcl_core.grow_cactus(pos, node)
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
if minetest.get_item_group(name, "sand") ~= 0 then
|
if minetest.get_item_group(name, "sand") ~= 0 then
|
||||||
|
@ -71,7 +71,7 @@ mcl_core.grow_cactus = function(pos, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_core.grow_reeds = function(pos, node)
|
function mcl_core.grow_reeds(pos, node)
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
if minetest.get_item_group(name, "soil_sugarcane") ~= 0 then
|
if minetest.get_item_group(name, "soil_sugarcane") ~= 0 then
|
||||||
|
@ -114,8 +114,8 @@ local function drop_attached_node(p)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Helper function for node actions for liquid flow
|
-- Helper function for node actions for liquid flow
|
||||||
local liquid_flow_action = function(pos, group, action)
|
local function liquid_flow_action(pos, group, action)
|
||||||
local check_detach = function(pos, xp, yp, zp)
|
local function check_detach(pos, xp, yp, zp)
|
||||||
local p = {x=pos.x+xp, y=pos.y+yp, z=pos.z+zp}
|
local p = {x=pos.x+xp, y=pos.y+yp, z=pos.z+zp}
|
||||||
local n = minetest.get_node_or_nil(p)
|
local n = minetest.get_node_or_nil(p)
|
||||||
if not n then
|
if not n then
|
||||||
|
@ -594,13 +594,13 @@ function mcl_core.generate_v6_spruce_tree(pos)
|
||||||
vm:write_to_map()
|
vm:write_to_map()
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_core.generate_spruce_tree = function(pos)
|
function mcl_core.generate_spruce_tree(pos)
|
||||||
local r = math.random(1, 3)
|
local r = math.random(1, 3)
|
||||||
local path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_spruce_"..r..".mts"
|
local path = minetest.get_modpath("mcl_core") .. "/schematics/mcl_core_spruce_"..r..".mts"
|
||||||
minetest.place_schematic({ x = pos.x - 3, y = pos.y - 1, z = pos.z - 3 }, path, "0", nil, false)
|
minetest.place_schematic({ x = pos.x - 3, y = pos.y - 1, z = pos.z - 3 }, path, "0", nil, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_core.generate_huge_spruce_tree = function(pos)
|
function mcl_core.generate_huge_spruce_tree(pos)
|
||||||
local r1 = math.random(1, 2)
|
local r1 = math.random(1, 2)
|
||||||
local r2 = math.random(1, 4)
|
local r2 = math.random(1, 4)
|
||||||
local path
|
local path
|
||||||
|
@ -911,7 +911,7 @@ minetest.register_lbm({
|
||||||
--------------------------
|
--------------------------
|
||||||
local treelight = 9
|
local treelight = 9
|
||||||
|
|
||||||
local sapling_grow_action = function(tree_id, soil_needed, one_by_one, two_by_two, sapling)
|
local function sapling_grow_action(tree_id, soil_needed, one_by_one, two_by_two, sapling)
|
||||||
return function(pos)
|
return function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if meta:get("grown") then return end
|
if meta:get("grown") then return end
|
||||||
|
@ -953,7 +953,7 @@ local sapling_grow_action = function(tree_id, soil_needed, one_by_one, two_by_tw
|
||||||
-- This sapling grows in a special way when there are 4 saplings in a 2×2 pattern
|
-- This sapling grows in a special way when there are 4 saplings in a 2×2 pattern
|
||||||
if two_by_two then
|
if two_by_two then
|
||||||
-- Check 8 surrounding saplings and try to find a 2×2 pattern
|
-- Check 8 surrounding saplings and try to find a 2×2 pattern
|
||||||
local is_sapling = function(pos, sapling)
|
local function is_sapling(pos, sapling)
|
||||||
return minetest.get_node(pos).name == sapling
|
return minetest.get_node(pos).name == sapling
|
||||||
end
|
end
|
||||||
local p2 = {x=pos.x+1, y=pos.y, z=pos.z}
|
local p2 = {x=pos.x+1, y=pos.y, z=pos.z}
|
||||||
|
@ -1040,7 +1040,7 @@ local grow_birch = sapling_grow_action(BIRCH_TREE_ID, 1, true, false)
|
||||||
-- pos: Position
|
-- pos: Position
|
||||||
-- node: Node table of the node at this position, from minetest.get_node
|
-- node: Node table of the node at this position, from minetest.get_node
|
||||||
-- Returns true on success and false on failure
|
-- Returns true on success and false on failure
|
||||||
mcl_core.grow_sapling = function(pos, node)
|
function mcl_core.grow_sapling(pos, node)
|
||||||
local grow
|
local grow
|
||||||
if node.name == "mcl_core:sapling" then
|
if node.name == "mcl_core:sapling" then
|
||||||
grow = grow_oak
|
grow = grow_oak
|
||||||
|
@ -1245,7 +1245,7 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add vines below pos (if empty)
|
-- Add vines below pos (if empty)
|
||||||
local spread_down = function(origin, target, dir, node)
|
local function spread_down(origin, target, dir, node)
|
||||||
if math.random(1, 2) == 1 then
|
if math.random(1, 2) == 1 then
|
||||||
if minetest.get_node(target).name == "air" then
|
if minetest.get_node(target).name == "air" then
|
||||||
minetest.add_node(target, {name = "mcl_core:vine", param2 = node.param2})
|
minetest.add_node(target, {name = "mcl_core:vine", param2 = node.param2})
|
||||||
|
@ -1254,7 +1254,7 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add vines above pos if it is backed up
|
-- Add vines above pos if it is backed up
|
||||||
local spread_up = function(origin, target, dir, node)
|
local function spread_up(origin, target, dir, node)
|
||||||
local vines_in_area = minetest.find_nodes_in_area({x=origin.x-4, y=origin.y-1, z=origin.z-4}, {x=origin.x+4, y=origin.y+1, z=origin.z+4}, "mcl_core:vine")
|
local vines_in_area = minetest.find_nodes_in_area({x=origin.x-4, y=origin.y-1, z=origin.z-4}, {x=origin.x+4, y=origin.y+1, z=origin.z+4}, "mcl_core:vine")
|
||||||
-- Less then 4 vines blocks around the ticked vines block (remember the ticked block is counted by above function as well)
|
-- Less then 4 vines blocks around the ticked vines block (remember the ticked block is counted by above function as well)
|
||||||
if #vines_in_area < 5 then
|
if #vines_in_area < 5 then
|
||||||
|
@ -1273,7 +1273,7 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local spread_horizontal = function(origin, target, dir, node)
|
local function spread_horizontal(origin, target, dir, node)
|
||||||
local vines_in_area = minetest.find_nodes_in_area({x=origin.x-4, y=origin.y-1, z=origin.z-4}, {x=origin.x+4, y=origin.y+1, z=origin.z+4}, "mcl_core:vine")
|
local vines_in_area = minetest.find_nodes_in_area({x=origin.x-4, y=origin.y-1, z=origin.z-4}, {x=origin.x+4, y=origin.y+1, z=origin.z+4}, "mcl_core:vine")
|
||||||
-- Less then 4 vines blocks around the ticked vines block (remember the ticked block is counted by above function as well)
|
-- Less then 4 vines blocks around the ticked vines block (remember the ticked block is counted by above function as well)
|
||||||
if #vines_in_area < 5 then
|
if #vines_in_area < 5 then
|
||||||
|
@ -1310,7 +1310,7 @@ minetest.register_abm({
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Returns true of the node supports vines
|
-- Returns true of the node supports vines
|
||||||
mcl_core.supports_vines = function(nodename)
|
function mcl_core.supports_vines(nodename)
|
||||||
local def = minetest.registered_nodes[nodename]
|
local def = minetest.registered_nodes[nodename]
|
||||||
-- Rules: 1) walkable 2) full cube
|
-- Rules: 1) walkable 2) full cube
|
||||||
return def.walkable and
|
return def.walkable and
|
||||||
|
@ -1530,7 +1530,7 @@ end
|
||||||
--
|
--
|
||||||
-- The snowable nodes also MUST have _mcl_snowed defined to contain the name
|
-- The snowable nodes also MUST have _mcl_snowed defined to contain the name
|
||||||
-- of the snowed node.
|
-- of the snowed node.
|
||||||
mcl_core.register_snowed_node = function(itemstring_snowed, itemstring_clear, tiles, sounds, clear_colorization, desc)
|
function mcl_core.register_snowed_node(itemstring_snowed, itemstring_clear, tiles, sounds, clear_colorization, desc)
|
||||||
local def = table.copy(minetest.registered_nodes[itemstring_clear])
|
local def = table.copy(minetest.registered_nodes[itemstring_clear])
|
||||||
local create_doc_alias
|
local create_doc_alias
|
||||||
if def.description then
|
if def.description then
|
||||||
|
@ -1593,7 +1593,7 @@ end
|
||||||
-- Reverts a snowed dirtlike node at pos to its original snow-less form.
|
-- Reverts a snowed dirtlike node at pos to its original snow-less form.
|
||||||
-- This function assumes there is no snow cover node above. This function
|
-- This function assumes there is no snow cover node above. This function
|
||||||
-- MUST NOT be called if there is a snow cover node above pos.
|
-- MUST NOT be called if there is a snow cover node above pos.
|
||||||
mcl_core.clear_snow_dirt = function(pos, node)
|
function mcl_core.clear_snow_dirt(pos, node)
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
if def._mcl_snowless then
|
if def._mcl_snowless then
|
||||||
minetest.swap_node(pos, {name = def._mcl_snowless, param2=node.param2})
|
minetest.swap_node(pos, {name = def._mcl_snowless, param2=node.param2})
|
||||||
|
@ -1605,7 +1605,7 @@ end
|
||||||
|
|
||||||
-- on_construct
|
-- on_construct
|
||||||
-- Makes constructed snowable node snowed if placed below a snow cover node.
|
-- Makes constructed snowable node snowed if placed below a snow cover node.
|
||||||
mcl_core.on_snowable_construct = function(pos)
|
function mcl_core.on_snowable_construct(pos)
|
||||||
-- Myself
|
-- Myself
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
|
|
||||||
|
@ -1633,7 +1633,7 @@ end
|
||||||
|
|
||||||
-- on_construct
|
-- on_construct
|
||||||
-- Makes snowable node below snowed.
|
-- Makes snowable node below snowed.
|
||||||
mcl_core.on_snow_construct = function(pos)
|
function mcl_core.on_snow_construct(pos)
|
||||||
local npos = {x=pos.x, y=pos.y-1, z=pos.z}
|
local npos = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
local node = minetest.get_node(npos)
|
local node = minetest.get_node(npos)
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
@ -1643,7 +1643,7 @@ mcl_core.on_snow_construct = function(pos)
|
||||||
end
|
end
|
||||||
-- after_destruct
|
-- after_destruct
|
||||||
-- Clears snowed dirtlike node below.
|
-- Clears snowed dirtlike node below.
|
||||||
mcl_core.after_snow_destruct = function(pos)
|
function mcl_core.after_snow_destruct(pos)
|
||||||
local nn = minetest.get_node(pos).name
|
local nn = minetest.get_node(pos).name
|
||||||
-- No-op if snow was replaced with snow
|
-- No-op if snow was replaced with snow
|
||||||
if minetest.get_item_group(nn, "snow_cover") == 1 then
|
if minetest.get_item_group(nn, "snow_cover") == 1 then
|
||||||
|
|
|
@ -86,7 +86,7 @@ minetest.register_node("mcl_core:stone_with_gold", {
|
||||||
})
|
})
|
||||||
|
|
||||||
local redstone_timer = 68.28
|
local redstone_timer = 68.28
|
||||||
local redstone_ore_activate = function(pos)
|
local function redstone_ore_activate(pos)
|
||||||
minetest.swap_node(pos, {name="mcl_core:stone_with_redstone_lit"})
|
minetest.swap_node(pos, {name="mcl_core:stone_with_redstone_lit"})
|
||||||
local t = minetest.get_node_timer(pos)
|
local t = minetest.get_node_timer(pos)
|
||||||
t:start(redstone_timer)
|
t:start(redstone_timer)
|
||||||
|
@ -124,7 +124,7 @@ minetest.register_node("mcl_core:stone_with_redstone", {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
local redstone_ore_reactivate = function(pos)
|
local function redstone_ore_reactivate(pos)
|
||||||
local t = minetest.get_node_timer(pos)
|
local t = minetest.get_node_timer(pos)
|
||||||
t:start(redstone_timer)
|
t:start(redstone_timer)
|
||||||
end
|
end
|
||||||
|
@ -864,7 +864,7 @@ minetest.register_node("mcl_core:packed_ice", {
|
||||||
-- Frosted Ice (4 nodes)
|
-- Frosted Ice (4 nodes)
|
||||||
for i=0,3 do
|
for i=0,3 do
|
||||||
local ice = {}
|
local ice = {}
|
||||||
ice.increase_age = function(pos, ice_near, first_melt)
|
function ice.increase_age(pos, ice_near, first_melt)
|
||||||
-- Increase age of frosted age or turn to water source if too old
|
-- Increase age of frosted age or turn to water source if too old
|
||||||
local nn = minetest.get_node(pos).name
|
local nn = minetest.get_node(pos).name
|
||||||
local age = tonumber(string.sub(nn, -1))
|
local age = tonumber(string.sub(nn, -1))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
-- Climbable nodes
|
-- Climbable nodes
|
||||||
local S = minetest.get_translator("mcl_core")
|
local S = minetest.get_translator("mcl_core")
|
||||||
|
|
||||||
local rotate_climbable = function(pos, node, user, mode)
|
local function rotate_climbable(pos, node, user, mode)
|
||||||
if mode == screwdriver.ROTATE_FACE then
|
if mode == screwdriver.ROTATE_FACE then
|
||||||
local r = screwdriver.rotate.wallmounted(pos, node, mode)
|
local r = screwdriver.rotate.wallmounted(pos, node, mode)
|
||||||
node.param2 = r
|
node.param2 = r
|
||||||
|
|
|
@ -212,7 +212,7 @@ S("• When lava is directly above water, the water turns into stone."),
|
||||||
_mcl_hardness = -1,
|
_mcl_hardness = -1,
|
||||||
})
|
})
|
||||||
|
|
||||||
local emit_lava_particle = function(pos)
|
local function emit_lava_particle(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if minetest.get_item_group(node.name, "lava_source") == 0 then
|
if minetest.get_item_group(node.name, "lava_source") == 0 then
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,7 +8,7 @@ if mod_screwdriver then
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register tree trunk (wood) and bark
|
-- Register tree trunk (wood) and bark
|
||||||
local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_varient)
|
local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_varient)
|
||||||
minetest.register_node("mcl_core:"..subname, {
|
minetest.register_node("mcl_core:"..subname, {
|
||||||
description = description_trunk,
|
description = description_trunk,
|
||||||
_doc_items_longdesc = longdesc,
|
_doc_items_longdesc = longdesc,
|
||||||
|
@ -91,7 +91,7 @@ local register_stripped_trunk = function(subname, description_stripped_trunk, de
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local register_wooden_planks = function(subname, description, tiles)
|
local function register_wooden_planks(subname, description, tiles)
|
||||||
minetest.register_node("mcl_core:"..subname, {
|
minetest.register_node("mcl_core:"..subname, {
|
||||||
description = description,
|
description = description,
|
||||||
_doc_items_longdesc = doc.sub.items.temp.build,
|
_doc_items_longdesc = doc.sub.items.temp.build,
|
||||||
|
@ -106,7 +106,7 @@ local register_wooden_planks = function(subname, description, tiles)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local register_leaves = function(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances, leafdecay_distance)
|
local function register_leaves(subname, description, longdesc, tiles, sapling, drop_apples, sapling_chances, leafdecay_distance)
|
||||||
if leafdecay_distance == nil then
|
if leafdecay_distance == nil then
|
||||||
leafdecay_distance = 4
|
leafdecay_distance = 4
|
||||||
end
|
end
|
||||||
|
@ -173,7 +173,7 @@ local register_leaves = function(subname, description, longdesc, tiles, sapling,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local register_sapling = function(subname, description, longdesc, tt_help, texture, selbox)
|
local function register_sapling(subname, description, longdesc, tt_help, texture, selbox)
|
||||||
minetest.register_node("mcl_core:"..subname, {
|
minetest.register_node("mcl_core:"..subname, {
|
||||||
description = description,
|
description = description,
|
||||||
_tt_help = tt_help,
|
_tt_help = tt_help,
|
||||||
|
|
|
@ -7,7 +7,7 @@ end
|
||||||
|
|
||||||
function mcl_enchanting.get_enchantments(itemstack)
|
function mcl_enchanting.get_enchantments(itemstack)
|
||||||
if not itemstack then
|
if not itemstack then
|
||||||
return({})
|
return {}
|
||||||
end
|
end
|
||||||
return minetest.deserialize(itemstack:get_meta():get_string("mcl_enchanting:enchantments")) or {}
|
return minetest.deserialize(itemstack:get_meta():get_string("mcl_enchanting:enchantments")) or {}
|
||||||
end
|
end
|
||||||
|
|
|
@ -450,6 +450,8 @@ function mcl_end.grow_chorus_plant_step(pos, node, pr)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- ABM ---
|
--- ABM ---
|
||||||
|
local seed = minetest.get_mapgen_params().seed
|
||||||
|
local pr = PseudoRandom(seed)
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
label = "Chorus plant growth",
|
label = "Chorus plant growth",
|
||||||
nodenames = { "mcl_end:chorus_flower" },
|
nodenames = { "mcl_end:chorus_flower" },
|
||||||
|
|
|
@ -20,7 +20,7 @@ local cz2 = {-2/16, -0.5, 2/16, 2/16, 1.01, 0.5} --unten(quer) z
|
||||||
|
|
||||||
mcl_fences = {}
|
mcl_fences = {}
|
||||||
|
|
||||||
mcl_fences.register_fence = function(id, fence_name, texture, groups, hardness, blast_resistance, connects_to, sounds)
|
function mcl_fences.register_fence(id, fence_name, texture, groups, hardness, blast_resistance, connects_to, sounds)
|
||||||
local cgroups = table.copy(groups)
|
local cgroups = table.copy(groups)
|
||||||
if cgroups == nil then cgroups = {} end
|
if cgroups == nil then cgroups = {} end
|
||||||
cgroups.fence = 1
|
cgroups.fence = 1
|
||||||
|
@ -72,7 +72,7 @@ mcl_fences.register_fence = function(id, fence_name, texture, groups, hardness,
|
||||||
return fence_id
|
return fence_id
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_fences.register_fence_gate = function(id, fence_gate_name, texture, groups, hardness, blast_resistance, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close)
|
function mcl_fences.register_fence_gate(id, fence_gate_name, texture, groups, hardness, blast_resistance, sounds, sound_open, sound_close, sound_gain_open, sound_gain_close)
|
||||||
local meta2
|
local meta2
|
||||||
local state2 = 0
|
local state2 = 0
|
||||||
|
|
||||||
|
|
|
@ -522,7 +522,7 @@ end
|
||||||
-- * pointed_thing: Pointed thing to ignite
|
-- * pointed_thing: Pointed thing to ignite
|
||||||
-- * player: Player who sets fire or nil if nobody
|
-- * player: Player who sets fire or nil if nobody
|
||||||
-- * allow_on_fire: If false, can't ignite fire on fire (default: true)
|
-- * allow_on_fire: If false, can't ignite fire on fire (default: true)
|
||||||
mcl_fire.set_fire = function(pointed_thing, player, allow_on_fire)
|
function mcl_fire.set_fire(pointed_thing, player, allow_on_fire)
|
||||||
local pname
|
local pname
|
||||||
if player == nil then
|
if player == nil then
|
||||||
pname = ""
|
pname = ""
|
||||||
|
|
|
@ -305,7 +305,7 @@ local flying_bobber_ENTITY={
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Movement function of flying bobber
|
-- Movement function of flying bobber
|
||||||
local flying_bobber_on_step = function(self, dtime)
|
local function flying_bobber_on_step(self, dtime)
|
||||||
self.timer=self.timer+dtime
|
self.timer=self.timer+dtime
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
|
@ -315,12 +315,9 @@ local flying_bobber_on_step = function(self, dtime)
|
||||||
-- Destroy when hitting a solid node
|
-- Destroy when hitting a solid node
|
||||||
if self._lastpos.x~=nil then
|
if self._lastpos.x~=nil then
|
||||||
if (def and (def.walkable or def.liquidtype == "flowing" or def.liquidtype == "source")) or not def then
|
if (def and (def.walkable or def.liquidtype == "flowing" or def.liquidtype == "source")) or not def then
|
||||||
local make_child= function(object)
|
local ent = minetest.add_entity(self._lastpos, "mcl_fishing:bobber_entity"):get_luaentity()
|
||||||
local ent = object:get_luaentity()
|
|
||||||
ent.player = self._thrower
|
ent.player = self._thrower
|
||||||
ent.child = true
|
ent.child = true
|
||||||
end
|
|
||||||
make_child(minetest.add_entity(self._lastpos, "mcl_fishing:bobber_entity"))
|
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
-- Lava in the Nether
|
-- Lava in the Nether
|
||||||
|
|
||||||
local S = minetest.get_translator("mcl_nether")
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
local N = function(s) return s end
|
|
||||||
|
|
||||||
local msg = {
|
|
||||||
N("@1 has become one with the lava."),
|
|
||||||
N("@1 has been consumed by the lava."),
|
|
||||||
}
|
|
||||||
|
|
||||||
-- TODO: Increase flow speed. This could be done by reducing viscosity,
|
-- TODO: Increase flow speed. This could be done by reducing viscosity,
|
||||||
-- but this would also allow players to swim faster in lava.
|
-- but this would also allow players to swim faster in lava.
|
||||||
|
@ -20,7 +14,6 @@ lava_src_def._doc_items_usagehelp = nil
|
||||||
lava_src_def.liquid_range = 7
|
lava_src_def.liquid_range = 7
|
||||||
lava_src_def.liquid_alternative_source = "mcl_nether:nether_lava_source"
|
lava_src_def.liquid_alternative_source = "mcl_nether:nether_lava_source"
|
||||||
lava_src_def.liquid_alternative_flowing = "mcl_nether:nether_lava_flowing"
|
lava_src_def.liquid_alternative_flowing = "mcl_nether:nether_lava_flowing"
|
||||||
lava_src_def._mcl_node_death_message = msg,
|
|
||||||
minetest.register_node("mcl_nether:nether_lava_source", lava_src_def)
|
minetest.register_node("mcl_nether:nether_lava_source", lava_src_def)
|
||||||
|
|
||||||
local lava_flow_def = table.copy(minetest.registered_nodes["mcl_core:lava_flowing"])
|
local lava_flow_def = table.copy(minetest.registered_nodes["mcl_core:lava_flowing"])
|
||||||
|
@ -29,7 +22,6 @@ lava_flow_def._doc_items_create_entry = false
|
||||||
lava_flow_def.liquid_range = 7
|
lava_flow_def.liquid_range = 7
|
||||||
lava_flow_def.liquid_alternative_flowing = "mcl_nether:nether_lava_flowing"
|
lava_flow_def.liquid_alternative_flowing = "mcl_nether:nether_lava_flowing"
|
||||||
lava_flow_def.liquid_alternative_source = "mcl_nether:nether_lava_source"
|
lava_flow_def.liquid_alternative_source = "mcl_nether:nether_lava_source"
|
||||||
lava_flow_def._mcl_node_death_message = msg,
|
|
||||||
minetest.register_node("mcl_nether:nether_lava_flowing", lava_flow_def)
|
minetest.register_node("mcl_nether:nether_lava_flowing", lava_flow_def)
|
||||||
|
|
||||||
-- Add entry aliases for the Help
|
-- Add entry aliases for the Help
|
||||||
|
|
|
@ -38,5 +38,3 @@ Place this item on soul sand to plant it and watch it grow.=Platzieren Sie den G
|
||||||
Burns your feet=Verbrennt Ihre Füße
|
Burns your feet=Verbrennt Ihre Füße
|
||||||
Grows on soul sand=Wächst auf Seelensand
|
Grows on soul sand=Wächst auf Seelensand
|
||||||
Reduces walking speed=Reduziert das Schritttempo
|
Reduces walking speed=Reduziert das Schritttempo
|
||||||
@1 has become one with the lava.=@1 wurde eins mit der Lava.
|
|
||||||
@1 has been consumed by the lava.=@1 wurde von der Lava verzehrt.
|
|
||||||
|
|
|
@ -38,5 +38,3 @@ Place this item on soul sand to plant it and watch it grow.=Placez cet article s
|
||||||
Burns your feet=Vous brûle les pieds
|
Burns your feet=Vous brûle les pieds
|
||||||
Grows on soul sand=Pousse sur le sable de l'âme
|
Grows on soul sand=Pousse sur le sable de l'âme
|
||||||
Reduces walking speed=Réduit la vitesse de marche
|
Reduces walking speed=Réduit la vitesse de marche
|
||||||
@1 has become one with the lava.=@1 est devenu un avec la lave.
|
|
||||||
@1 has been consumed by the lava.=@1 a été consumé par la lave.
|
|
|
@ -38,5 +38,3 @@ Place this item on soul sand to plant it and watch it grow.=Поместите
|
||||||
Burns your feet=Обжигает ваши ноги
|
Burns your feet=Обжигает ваши ноги
|
||||||
Grows on soul sand=Растёт на песке душ
|
Grows on soul sand=Растёт на песке душ
|
||||||
Reduces walking speed=Уменьшает скорость ходьбы
|
Reduces walking speed=Уменьшает скорость ходьбы
|
||||||
@1 has become one with the lava.=@1 породнился(лась) с лавой.
|
|
||||||
@1 has been consumed by the lava.=@1 был(а) поглощен(а) лавой.
|
|
||||||
|
|
|
@ -38,5 +38,3 @@ Place this item on soul sand to plant it and watch it grow.=
|
||||||
Burns your feet=
|
Burns your feet=
|
||||||
Grows on soul sand=
|
Grows on soul sand=
|
||||||
Reduces walking speed=
|
Reduces walking speed=
|
||||||
@1 has become one with the lava.=
|
|
||||||
@1 has been consumed by the lava.=
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ end
|
||||||
|
|
||||||
local canonical_color = "yellow"
|
local canonical_color = "yellow"
|
||||||
-- Register glass pane (stained and unstained)
|
-- Register glass pane (stained and unstained)
|
||||||
local pane = function(description, node, append)
|
local function pane(description, node, append)
|
||||||
local texture1, longdesc, entry_name, create_entry
|
local texture1, longdesc, entry_name, create_entry
|
||||||
local is_canonical = true
|
local is_canonical = true
|
||||||
-- Special case: Default (unstained) glass texture
|
-- Special case: Default (unstained) glass texture
|
||||||
|
|
|
@ -1775,7 +1775,7 @@ local function register_biomelike_ores()
|
||||||
-- Mesa strata (registered as sheet ores)
|
-- Mesa strata (registered as sheet ores)
|
||||||
|
|
||||||
-- Helper function to create strata.
|
-- Helper function to create strata.
|
||||||
local stratum = function(y_min, height, color, seed, is_perfect)
|
local function stratum(y_min, height, color, seed, is_perfect)
|
||||||
if not height then
|
if not height then
|
||||||
height = 1
|
height = 1
|
||||||
end
|
end
|
||||||
|
@ -3079,7 +3079,7 @@ local function register_decorations()
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Doubletall grass
|
-- Doubletall grass
|
||||||
local register_doubletall_grass = function(offset, scale, biomes)
|
local function register_doubletall_grass(offset, scale, biomes)
|
||||||
|
|
||||||
for b=1, #biomes do
|
for b=1, #biomes do
|
||||||
local param2 = minetest.registered_biomes[biomes[b]]._mcl_palette_index
|
local param2 = minetest.registered_biomes[biomes[b]]._mcl_palette_index
|
||||||
|
@ -3115,7 +3115,7 @@ local function register_decorations()
|
||||||
register_doubletall_grass(-0.0005, -0.03, {"Savanna", "SavannaM"})
|
register_doubletall_grass(-0.0005, -0.03, {"Savanna", "SavannaM"})
|
||||||
|
|
||||||
-- Large ferns
|
-- Large ferns
|
||||||
local register_double_fern = function(offset, scale, biomes)
|
local function register_double_fern(offset, scale, biomes)
|
||||||
for b=1, #biomes do
|
for b=1, #biomes do
|
||||||
local param2 = minetest.registered_biomes[biomes[b]]._mcl_palette_index
|
local param2 = minetest.registered_biomes[biomes[b]]._mcl_palette_index
|
||||||
minetest.register_decoration({
|
minetest.register_decoration({
|
||||||
|
@ -3149,7 +3149,7 @@ local function register_decorations()
|
||||||
register_double_fern(0.15, 0.1, { "JungleM" })
|
register_double_fern(0.15, 0.1, { "JungleM" })
|
||||||
|
|
||||||
-- Large flowers
|
-- Large flowers
|
||||||
local register_large_flower = function(name, biomes, seed, offset, flower_forest_offset)
|
local function register_large_flower(name, biomes, seed, offset, flower_forest_offset)
|
||||||
local maxi
|
local maxi
|
||||||
if flower_forest_offset then
|
if flower_forest_offset then
|
||||||
maxi = 2
|
maxi = 2
|
||||||
|
|
|
@ -765,7 +765,7 @@ local function register_mgv6_decorations()
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Large flowers
|
-- Large flowers
|
||||||
local register_large_flower = function(name, seed, offset)
|
local function register_large_flower(name, seed, offset)
|
||||||
minetest.register_decoration({
|
minetest.register_decoration({
|
||||||
deco_type = "schematic",
|
deco_type = "schematic",
|
||||||
schematic = {
|
schematic = {
|
||||||
|
@ -1169,7 +1169,7 @@ end
|
||||||
-- minp and maxp (from an on_generated callback) and returns the real world coordinates
|
-- minp and maxp (from an on_generated callback) and returns the real world coordinates
|
||||||
-- as X, Z.
|
-- as X, Z.
|
||||||
-- Inverse function of xz_to_biomemap
|
-- Inverse function of xz_to_biomemap
|
||||||
--[[local biomemap_to_xz = function(index, minp, maxp)
|
--[[local function biomemap_to_xz(index, minp, maxp)
|
||||||
local xwidth = maxp.x - minp.x + 1
|
local xwidth = maxp.x - minp.x + 1
|
||||||
local zwidth = maxp.z - minp.z + 1
|
local zwidth = maxp.z - minp.z + 1
|
||||||
local x = ((index-1) % xwidth) + minp.x
|
local x = ((index-1) % xwidth) + minp.x
|
||||||
|
@ -1180,7 +1180,7 @@ end]]
|
||||||
-- Takes x and z coordinates and minp and maxp of a generated chunk
|
-- Takes x and z coordinates and minp and maxp of a generated chunk
|
||||||
-- (in on_generated callback) and returns a biomemap index)
|
-- (in on_generated callback) and returns a biomemap index)
|
||||||
-- Inverse function of biomemap_to_xz
|
-- Inverse function of biomemap_to_xz
|
||||||
local xz_to_biomemap_index = function(x, z, minp, maxp)
|
local function xz_to_biomemap_index(x, z, minp, maxp)
|
||||||
local xwidth = maxp.x - minp.x + 1
|
local xwidth = maxp.x - minp.x + 1
|
||||||
local zwidth = maxp.z - minp.z + 1
|
local zwidth = maxp.z - minp.z + 1
|
||||||
local minix = x % xwidth
|
local minix = x % xwidth
|
||||||
|
@ -1404,7 +1404,7 @@ local function generate_structures(minp, maxp, blockseed, biomemap)
|
||||||
|
|
||||||
-- TODO: Spawn witch in or around hut when the mob sucks less.
|
-- TODO: Spawn witch in or around hut when the mob sucks less.
|
||||||
|
|
||||||
local place_tree_if_free = function(pos, prev_result)
|
local function place_tree_if_free(pos, prev_result)
|
||||||
local nn = minetest.get_node(pos).name
|
local nn = minetest.get_node(pos).name
|
||||||
if nn == "mcl_flowers:waterlily" or nn == "mcl_core:water_source" or nn == "mcl_core:water_flowing" or nn == "air" then
|
if nn == "mcl_flowers:waterlily" or nn == "mcl_core:water_source" or nn == "mcl_core:water_flowing" or nn == "air" then
|
||||||
minetest.set_node(pos, {name="mcl_core:tree", param2=0})
|
minetest.set_node(pos, {name="mcl_core:tree", param2=0})
|
||||||
|
@ -1720,7 +1720,7 @@ end
|
||||||
|
|
||||||
-- Generate mushrooms in caves manually.
|
-- Generate mushrooms in caves manually.
|
||||||
-- Minetest's API does not support decorations in caves yet. :-(
|
-- Minetest's API does not support decorations in caves yet. :-(
|
||||||
local generate_underground_mushrooms = function(minp, maxp, seed)
|
local function generate_underground_mushrooms(minp, maxp, seed)
|
||||||
local pr_shroom = PseudoRandom(seed-24359)
|
local pr_shroom = PseudoRandom(seed-24359)
|
||||||
-- Generate rare underground mushrooms
|
-- Generate rare underground mushrooms
|
||||||
-- TODO: Make them appear in groups, use Perlin noise
|
-- TODO: Make them appear in groups, use Perlin noise
|
||||||
|
@ -1754,7 +1754,7 @@ else
|
||||||
end
|
end
|
||||||
-- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart
|
-- Generate Nether decorations manually: Eternal fire, mushrooms, nether wart
|
||||||
-- Minetest's API does not support decorations in caves yet. :-(
|
-- Minetest's API does not support decorations in caves yet. :-(
|
||||||
local generate_nether_decorations = function(minp, maxp, seed)
|
local function generate_nether_decorations(minp, maxp, seed)
|
||||||
local pr_nether = PseudoRandom(seed+667)
|
local pr_nether = PseudoRandom(seed+667)
|
||||||
|
|
||||||
if minp.y > mcl_vars.mg_nether_max or maxp.y < mcl_vars.mg_nether_min then
|
if minp.y > mcl_vars.mg_nether_max or maxp.y < mcl_vars.mg_nether_min then
|
||||||
|
@ -1771,7 +1771,7 @@ local generate_nether_decorations = function(minp, maxp, seed)
|
||||||
local ssand = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:soul_sand"})
|
local ssand = minetest.find_nodes_in_area_under_air(minp, maxp, {"mcl_nether:soul_sand"})
|
||||||
|
|
||||||
-- Helper function to spawn “fake” decoration
|
-- Helper function to spawn “fake” decoration
|
||||||
local special_deco = function(nodes, spawn_func)
|
local function special_deco(nodes, spawn_func)
|
||||||
for n = 1, #nodes do
|
for n = 1, #nodes do
|
||||||
bpos = {x = nodes[n].x, y = nodes[n].y + 1, z = nodes[n].z }
|
bpos = {x = nodes[n].x, y = nodes[n].y + 1, z = nodes[n].z }
|
||||||
|
|
||||||
|
@ -1912,7 +1912,7 @@ end
|
||||||
|
|
||||||
local bedrock_check
|
local bedrock_check
|
||||||
if mcl_vars.mg_bedrock_is_rough then
|
if mcl_vars.mg_bedrock_is_rough then
|
||||||
bedrock_check = function(pos, _, pr)
|
function bedrock_check(pos, _, pr)
|
||||||
local y = pos.y
|
local y = pos.y
|
||||||
-- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer
|
-- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer
|
||||||
-- This code assumes a bedrock height of 5 layers.
|
-- This code assumes a bedrock height of 5 layers.
|
||||||
|
|
|
@ -25,7 +25,7 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl
|
||||||
-- The stronghold positions are based on the world seed.
|
-- The stronghold positions are based on the world seed.
|
||||||
-- The actual position might be offset by a few blocks because it might be shifted
|
-- The actual position might be offset by a few blocks because it might be shifted
|
||||||
-- to make sure the end portal room is completely within the boundaries of a mapchunk.
|
-- to make sure the end portal room is completely within the boundaries of a mapchunk.
|
||||||
local init_strongholds = function()
|
local function init_strongholds()
|
||||||
if strongholds_inited then
|
if strongholds_inited then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -67,7 +67,7 @@ local init_strongholds = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stronghold generation for register_on_generated.
|
-- Stronghold generation for register_on_generated.
|
||||||
local generate_strongholds = function(minp, maxp, blockseed)
|
local function generate_strongholds(minp, maxp, blockseed)
|
||||||
local pr = PseudoRandom(blockseed)
|
local pr = PseudoRandom(blockseed)
|
||||||
for s=1, #strongholds do
|
for s=1, #strongholds do
|
||||||
if not strongholds[s].generated then
|
if not strongholds[s].generated then
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
local S = minetest.get_translator("mcl_structures")
|
local modname = minetest.get_current_modname()
|
||||||
|
local S = minetest.get_translator(modname)
|
||||||
|
local modpath = minetest.get_modpath(modname)
|
||||||
|
|
||||||
mcl_structures = {}
|
mcl_structures = {}
|
||||||
|
|
||||||
local rotations = {
|
local rotations = {
|
||||||
"0",
|
"0",
|
||||||
"90",
|
"90",
|
||||||
|
@ -14,8 +18,9 @@ local function ecb_place(blockpos, action, calls_remaining, param)
|
||||||
param.after_placement_callback(param.p1, param.p2, param.size, param.rotation, param.pr, param.callback_param)
|
param.after_placement_callback(param.p1, param.p2, param.size, param.rotation, param.pr, param.callback_param)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mcl_structures.place_schematic = function(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param)
|
|
||||||
local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return(schematic)")()
|
function mcl_structures.place_schematic(pos, schematic, rotation, replacements, force_placement, flags, after_placement_callback, pr, callback_param)
|
||||||
|
local s = loadstring(minetest.serialize_schematic(schematic, "lua", {lua_use_comments = false, lua_num_indent_spaces = 0}) .. " return schematic")()
|
||||||
if s and s.size then
|
if s and s.size then
|
||||||
local x, z = s.size.x, s.size.z
|
local x, z = s.size.x, s.size.z
|
||||||
if rotation then
|
if rotation then
|
||||||
|
@ -37,7 +42,7 @@ mcl_structures.place_schematic = function(pos, schematic, rotation, replacements
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.get_struct = function(file)
|
function mcl_structures.get_struct(file)
|
||||||
local localfile = minetest.get_modpath("mcl_structures").."/schematics/"..file
|
local localfile = minetest.get_modpath("mcl_structures").."/schematics/"..file
|
||||||
local file, errorload = io.open(localfile, "rb")
|
local file, errorload = io.open(localfile, "rb")
|
||||||
if errorload ~= nil then
|
if errorload ~= nil then
|
||||||
|
@ -53,7 +58,7 @@ end
|
||||||
|
|
||||||
-- Call on_construct on pos.
|
-- Call on_construct on pos.
|
||||||
-- Useful to init chests from formspec.
|
-- Useful to init chests from formspec.
|
||||||
local init_node_construct = function(pos)
|
local function init_node_construct(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
if def and def.on_construct then
|
if def and def.on_construct then
|
||||||
|
@ -64,7 +69,7 @@ local init_node_construct = function(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The call of Struct
|
-- The call of Struct
|
||||||
mcl_structures.call_struct = function(pos, struct_style, rotation, pr)
|
function mcl_structures.call_struct(pos, struct_style, rotation, pr)
|
||||||
minetest.log("action","[mcl_structures] call_struct " .. struct_style.." at "..minetest.pos_to_string(pos))
|
minetest.log("action","[mcl_structures] call_struct " .. struct_style.." at "..minetest.pos_to_string(pos))
|
||||||
if not rotation then
|
if not rotation then
|
||||||
rotation = "random"
|
rotation = "random"
|
||||||
|
@ -96,13 +101,13 @@ mcl_structures.call_struct = function(pos, struct_style, rotation, pr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_desert_well = function(pos, rot)
|
function mcl_structures.generate_desert_well(pos, rot)
|
||||||
local newpos = {x=pos.x,y=pos.y-2,z=pos.z}
|
local newpos = {x=pos.x,y=pos.y-2,z=pos.z}
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_well.mts"
|
local path = modpath.."/schematics/mcl_structures_desert_well.mts"
|
||||||
return mcl_structures.place_schematic(newpos, path, rot or "0", nil, true)
|
return mcl_structures.place_schematic(newpos, path, rot or "0", nil, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_igloo = function(pos, rotation, pr)
|
function mcl_structures.generate_igloo(pos, rotation, pr)
|
||||||
-- Place igloo
|
-- Place igloo
|
||||||
local success, rotation = mcl_structures.generate_igloo_top(pos, pr)
|
local success, rotation = mcl_structures.generate_igloo_top(pos, pr)
|
||||||
-- Place igloo basement with 50% chance
|
-- Place igloo basement with 50% chance
|
||||||
|
@ -148,7 +153,7 @@ mcl_structures.generate_igloo = function(pos, rotation, pr)
|
||||||
else
|
else
|
||||||
return success
|
return success
|
||||||
end
|
end
|
||||||
local set_brick = function(pos)
|
local function set_brick(pos)
|
||||||
local c = pr:next(1, 3) -- cracked chance
|
local c = pr:next(1, 3) -- cracked chance
|
||||||
local m = pr:next(1, 10) -- chance for monster egg
|
local m = pr:next(1, 10) -- chance for monster egg
|
||||||
local brick
|
local brick
|
||||||
|
@ -198,11 +203,11 @@ mcl_structures.generate_igloo = function(pos, rotation, pr)
|
||||||
return success
|
return success
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_igloo_top = function(pos, pr)
|
function mcl_structures.generate_igloo_top(pos, pr)
|
||||||
-- FIXME: This spawns bookshelf instead of furnace. Fix this!
|
-- FIXME: This spawns bookshelf instead of furnace. Fix this!
|
||||||
-- Furnace does ot work atm because apparently meta is not set. :-(
|
-- Furnace does ot work atm because apparently meta is not set. :-(
|
||||||
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_igloo_top.mts"
|
local path = modpath.."/schematics/mcl_structures_igloo_top.mts"
|
||||||
local rotation = tostring(pr:next(0,3)*90)
|
local rotation = tostring(pr:next(0,3)*90)
|
||||||
return mcl_structures.place_schematic(newpos, path, rotation, nil, true), rotation
|
return mcl_structures.place_schematic(newpos, path, rotation, nil, true), rotation
|
||||||
end
|
end
|
||||||
|
@ -250,22 +255,22 @@ local function igloo_placement_callback(p1, p2, size, orientation, pr)
|
||||||
mcl_loot.fill_inventory(inv, "main", lootitems, pr)
|
mcl_loot.fill_inventory(inv, "main", lootitems, pr)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_igloo_basement = function(pos, orientation, pr)
|
function mcl_structures.generate_igloo_basement(pos, orientation, pr)
|
||||||
-- TODO: Add brewing stand
|
-- TODO: Add brewing stand
|
||||||
-- TODO: Add monster eggs
|
-- TODO: Add monster eggs
|
||||||
-- TODO: Spawn villager and zombie villager
|
-- TODO: Spawn villager and zombie villager
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_igloo_basement.mts"
|
local path = modpath.."/schematics/mcl_structures_igloo_basement.mts"
|
||||||
mcl_structures.place_schematic(pos, path, orientation, nil, true, nil, igloo_placement_callback, pr)
|
mcl_structures.place_schematic(pos, path, orientation, nil, true, nil, igloo_placement_callback, pr)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_boulder = function(pos, rotation, pr)
|
function mcl_structures.generate_boulder(pos, rotation, pr)
|
||||||
-- Choose between 2 boulder sizes (2×2×2 or 3×3×3)
|
-- Choose between 2 boulder sizes (2×2×2 or 3×3×3)
|
||||||
local r = pr:next(1, 10)
|
local r = pr:next(1, 10)
|
||||||
local path
|
local path
|
||||||
if r <= 3 then
|
if r <= 3 then
|
||||||
path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder_small.mts"
|
path = modpath.."/schematics/mcl_structures_boulder_small.mts"
|
||||||
else
|
else
|
||||||
path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder.mts"
|
path = modpath.."/schematics/mcl_structures_boulder.mts"
|
||||||
end
|
end
|
||||||
|
|
||||||
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||||
|
@ -284,22 +289,22 @@ local function hut_placement_callback(p1, p2, size, orientation, pr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_witch_hut = function(pos, rotation, pr)
|
function mcl_structures.generate_witch_hut(pos, rotation, pr)
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_witch_hut.mts"
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_witch_hut.mts"
|
||||||
mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr)
|
mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_ice_spike_small = function(pos, rotation)
|
function mcl_structures.generate_ice_spike_small(pos, rotation)
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_small.mts"
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_small.mts"
|
||||||
return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0
|
return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_ice_spike_large = function(pos, rotation)
|
function mcl_structures.generate_ice_spike_large(pos, rotation)
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_large.mts"
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_large.mts"
|
||||||
return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0
|
return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_fossil = function(pos, rotation, pr)
|
function mcl_structures.generate_fossil(pos, rotation, pr)
|
||||||
-- Generates one out of 8 possible fossil pieces
|
-- Generates one out of 8 possible fossil pieces
|
||||||
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||||
local fossils = {
|
local fossils = {
|
||||||
|
@ -317,17 +322,17 @@ mcl_structures.generate_fossil = function(pos, rotation, pr)
|
||||||
return mcl_structures.place_schematic(newpos, path, rotation or "random", nil, true)
|
return mcl_structures.place_schematic(newpos, path, rotation or "random", nil, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_end_exit_portal = function(pos, rot)
|
function mcl_structures.generate_end_exit_portal(pos, rot)
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts"
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts"
|
||||||
return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true)
|
return mcl_structures.place_schematic(pos, path, rot or "0", {["mcl_portals:portal_end"] = "air"}, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_end_exit_portal_open = function(pos, rot)
|
function mcl_structures.generate_end_exit_portal_open(pos, rot)
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts"
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts"
|
||||||
return mcl_structures.place_schematic(pos, path, rot or "0", nil, true)
|
return mcl_structures.place_schematic(pos, path, rot or "0", nil, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_end_gateway_portal = function(pos, rot)
|
function mcl_structures.generate_end_gateway_portal(pos, rot)
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts"
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_gateway_portal.mts"
|
||||||
return mcl_structures.place_schematic(pos, path, rot or "0", nil, true)
|
return mcl_structures.place_schematic(pos, path, rot or "0", nil, true)
|
||||||
end
|
end
|
||||||
|
@ -410,7 +415,7 @@ local function shrine_placement_callback(p1, p2, size, rotation, pr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_end_portal_shrine = function(pos, rotation, pr)
|
function mcl_structures.generate_end_portal_shrine(pos, rotation, pr)
|
||||||
local offset = {x=6, y=4, z=6}
|
local offset = {x=6, y=4, z=6}
|
||||||
--local size = {x=13, y=8, z=13}
|
--local size = {x=13, y=8, z=13}
|
||||||
local newpos = { x = pos.x - offset.x, y = pos.y, z = pos.z - offset.z }
|
local newpos = { x = pos.x - offset.x, y = pos.y, z = pos.z - offset.z }
|
||||||
|
@ -493,7 +498,7 @@ local function temple_placement_callback(p1, p2, size, rotation, pr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.generate_desert_temple = function(pos, rotation, pr)
|
function mcl_structures.generate_desert_temple(pos, rotation, pr)
|
||||||
-- No Generating for the temple ... Why using it ? No Change
|
-- No Generating for the temple ... Why using it ? No Change
|
||||||
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_temple.mts"
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_temple.mts"
|
||||||
local newpos = {x=pos.x,y=pos.y-12,z=pos.z}
|
local newpos = {x=pos.x,y=pos.y-12,z=pos.z}
|
||||||
|
@ -517,7 +522,7 @@ Format of return value:
|
||||||
|
|
||||||
TODO: Implement this function for all other structure types as well.
|
TODO: Implement this function for all other structure types as well.
|
||||||
]]
|
]]
|
||||||
mcl_structures.get_registered_structures = function(structure_type)
|
function mcl_structures.get_registered_structures(structure_type)
|
||||||
if registered_structures[structure_type] then
|
if registered_structures[structure_type] then
|
||||||
return table.copy(registered_structures[structure_type])
|
return table.copy(registered_structures[structure_type])
|
||||||
else
|
else
|
||||||
|
@ -527,7 +532,7 @@ end
|
||||||
|
|
||||||
-- Register a structures table for the given type. The table format is the same as for
|
-- Register a structures table for the given type. The table format is the same as for
|
||||||
-- mcl_structures.get_registered_structures.
|
-- mcl_structures.get_registered_structures.
|
||||||
mcl_structures.register_structures = function(structure_type, structures)
|
function mcl_structures.register_structures(structure_type, structures)
|
||||||
registered_structures[structure_type] = structures
|
registered_structures[structure_type] = structures
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ function settlements.build_schematic(vm, data, va, pos, building, replace_wall,
|
||||||
-- schematic conversion to lua
|
-- schematic conversion to lua
|
||||||
local schem_lua = minetest.serialize_schematic(building,
|
local schem_lua = minetest.serialize_schematic(building,
|
||||||
"lua",
|
"lua",
|
||||||
{lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)"
|
{lua_use_comments = false, lua_num_indent_spaces = 0}).." return schematic"
|
||||||
-- replace material
|
-- replace material
|
||||||
if replace_wall == "y" then
|
if replace_wall == "y" then
|
||||||
schem_lua = schem_lua:gsub("mcl_core:cobble", material)
|
schem_lua = schem_lua:gsub("mcl_core:cobble", material)
|
||||||
|
@ -228,7 +228,7 @@ function settlements.place_schematics(settlement_info, pr)
|
||||||
-- schematic conversion to lua
|
-- schematic conversion to lua
|
||||||
local schem_lua = minetest.serialize_schematic(building,
|
local schem_lua = minetest.serialize_schematic(building,
|
||||||
"lua",
|
"lua",
|
||||||
{lua_use_comments = false, lua_num_indent_spaces = 0}).." return(schematic)"
|
{lua_use_comments = false, lua_num_indent_spaces = 0}).." return schematic"
|
||||||
schem_lua = schem_lua:gsub("mcl_core:stonebrickcarved", "mcl_villages:stonebrickcarved")
|
schem_lua = schem_lua:gsub("mcl_core:stonebrickcarved", "mcl_villages:stonebrickcarved")
|
||||||
-- replace material
|
-- replace material
|
||||||
if replace_wall then
|
if replace_wall then
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
-- switch for debugging
|
-- switch for debugging
|
||||||
settlements.debug = function(message)
|
function settlements.debug(message)
|
||||||
-- minetest.chat_send_all(message)
|
-- minetest.chat_send_all(message)
|
||||||
-- minetest.log("warning", "[mcl_villages] "..message)
|
-- minetest.log("warning", "[mcl_villages] "..message)
|
||||||
minetest.log("verbose", "[mcl_villages] "..message)
|
minetest.log("verbose", "[mcl_villages] "..message)
|
||||||
|
|
|
@ -27,7 +27,7 @@ if mg_name == "v6" then
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
-- This generates dark oak wood in mesa biomes and oak wood everywhere else.
|
-- This generates dark oak wood in mesa biomes and oak wood everywhere else.
|
||||||
tsm_railcorridors.nodes.corridor_woods_function = function(pos, node)
|
function tsm_railcorridors.nodes.corridor_woods_function(pos, node)
|
||||||
if minetest.get_item_group(node.name, "hardened_clay") ~= 0 then
|
if minetest.get_item_group(node.name, "hardened_clay") ~= 0 then
|
||||||
return "mcl_core:darkwood", "mcl_fences:dark_oak_fence"
|
return "mcl_core:darkwood", "mcl_fences:dark_oak_fence"
|
||||||
else
|
else
|
||||||
|
|
|
@ -114,7 +114,8 @@ if not tsm_railcorridors.nodes.corridor_woods_function then
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Random Perlin noise generators
|
-- Random Perlin noise generators
|
||||||
local pr, pr_carts, pr_treasures, pr_deco, webperlin_major, webperlin_minor
|
local pr, pr_carts, pr_deco, webperlin_major, webperlin_minor
|
||||||
|
--local pr_treasures
|
||||||
|
|
||||||
local function InitRandomizer(seed)
|
local function InitRandomizer(seed)
|
||||||
-- Mostly used for corridor gen.
|
-- Mostly used for corridor gen.
|
||||||
|
@ -124,7 +125,7 @@ local function InitRandomizer(seed)
|
||||||
-- Separate randomizer for carts because spawning carts is very timing-dependent
|
-- Separate randomizer for carts because spawning carts is very timing-dependent
|
||||||
pr_carts = PseudoRandom(seed-654)
|
pr_carts = PseudoRandom(seed-654)
|
||||||
-- Chest contents randomizer
|
-- Chest contents randomizer
|
||||||
pr_treasures = PseudoRandom(seed+777)
|
--pr_treasures = PseudoRandom(seed+777)
|
||||||
-- Used for cobweb generation, both noises have to reach a high value for cobwebs to appear
|
-- Used for cobweb generation, both noises have to reach a high value for cobwebs to appear
|
||||||
webperlin_major = PerlinNoise(934, 3, 0.6, 500)
|
webperlin_major = PerlinNoise(934, 3, 0.6, 500)
|
||||||
webperlin_minor = PerlinNoise(834, 3, 0.6, 50)
|
webperlin_minor = PerlinNoise(834, 3, 0.6, 50)
|
||||||
|
@ -684,7 +685,7 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d
|
||||||
|
|
||||||
-- Randomly returns either the left or right side of the main rail.
|
-- Randomly returns either the left or right side of the main rail.
|
||||||
-- Also returns offset as second return value.
|
-- Also returns offset as second return value.
|
||||||
local left_or_right = function(pos, vek)
|
local function left_or_right(pos, vek)
|
||||||
local off
|
local off
|
||||||
if pr:next(1, 2) == 1 then
|
if pr:next(1, 2) == 1 then
|
||||||
-- left
|
-- left
|
||||||
|
@ -764,7 +765,7 @@ local function create_corridor_section(waypoint, axis, sign, up_or_down, up_or_d
|
||||||
-- Place cobwebs left and right in the corridor
|
-- Place cobwebs left and right in the corridor
|
||||||
if place_cobwebs and tsm_railcorridors.nodes.cobweb then
|
if place_cobwebs and tsm_railcorridors.nodes.cobweb then
|
||||||
-- Helper function to place a cobweb at the side (based on chance an Perlin noise)
|
-- Helper function to place a cobweb at the side (based on chance an Perlin noise)
|
||||||
local cobweb_at_side = function(basepos, vek)
|
local function cobweb_at_side(basepos, vek)
|
||||||
if pr:next(1,5) == 1 then
|
if pr:next(1,5) == 1 then
|
||||||
local h = pr:next(0, 2) -- 3 possible cobweb heights
|
local h = pr:next(0, 2) -- 3 possible cobweb heights
|
||||||
local cpos = {x=basepos.x+vek.x, y=basepos.y+h, z=basepos.z+vek.z}
|
local cpos = {x=basepos.x+vek.x, y=basepos.y+h, z=basepos.z+vek.z}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
local table = table
|
||||||
|
|
||||||
-- Player state for public API
|
-- Player state for public API
|
||||||
mcl_playerinfo = {}
|
mcl_playerinfo = {}
|
||||||
|
|
||||||
|
@ -21,7 +23,7 @@ end
|
||||||
|
|
||||||
local time = 0
|
local time = 0
|
||||||
|
|
||||||
local get_player_nodes = function(player_pos)
|
local function get_player_nodes(player_pos)
|
||||||
local work_pos = table.copy(player_pos)
|
local work_pos = table.copy(player_pos)
|
||||||
|
|
||||||
-- what is around me?
|
-- what is around me?
|
||||||
|
|
|
@ -25,7 +25,7 @@ local mcl_playerplus_internal = {}
|
||||||
local time = 0
|
local time = 0
|
||||||
local look_pitch = 0
|
local look_pitch = 0
|
||||||
|
|
||||||
local player_collision = function(player)
|
local function player_collision(player)
|
||||||
|
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
--local vel = player:get_velocity()
|
--local vel = player:get_velocity()
|
||||||
|
@ -48,8 +48,7 @@ local player_collision = function(player)
|
||||||
z = z + (vec.z * force)
|
z = z + (vec.z * force)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return {x,z}
|
||||||
return({x,z})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- converts yaw to degrees
|
-- converts yaw to degrees
|
||||||
|
@ -57,7 +56,7 @@ local function degrees(rad)
|
||||||
return rad * 180.0 / math.pi
|
return rad * 180.0 / math.pi
|
||||||
end
|
end
|
||||||
|
|
||||||
local dir_to_pitch = function(dir)
|
local function dir_to_pitch(dir)
|
||||||
--local dir2 = vector.normalize(dir)
|
--local dir2 = vector.normalize(dir)
|
||||||
local xz = math.abs(dir.x) + math.abs(dir.z)
|
local xz = math.abs(dir.x) + math.abs(dir.z)
|
||||||
return -math.atan2(-dir.y, xz)
|
return -math.atan2(-dir.y, xz)
|
||||||
|
|
|
@ -70,7 +70,7 @@ while true do
|
||||||
id = id + 1
|
id = id + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_skins.cycle_skin = function(player)
|
function mcl_skins.cycle_skin(player)
|
||||||
local skin_id = tonumber(player:get_meta():get_string("mcl_skins:skin_id"))
|
local skin_id = tonumber(player:get_meta():get_string("mcl_skins:skin_id"))
|
||||||
if not skin_id then
|
if not skin_id then
|
||||||
skin_id = 0
|
skin_id = 0
|
||||||
|
@ -82,7 +82,7 @@ mcl_skins.cycle_skin = function(player)
|
||||||
mcl_skins.set_player_skin(player, skin_id)
|
mcl_skins.set_player_skin(player, skin_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_skins.set_player_skin = function(player, skin_id)
|
function mcl_skins.set_player_skin(player, skin_id)
|
||||||
if not player then
|
if not player then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -124,7 +124,7 @@ mcl_skins.set_player_skin = function(player, skin_id)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_skins.update_player_skin = function(player)
|
function mcl_skins.update_player_skin(player)
|
||||||
if not player then
|
if not player then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -134,7 +134,6 @@ end
|
||||||
|
|
||||||
-- load player skin on join
|
-- load player skin on join
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local skin_id = player:get_meta():get_string("mcl_skins:skin_id")
|
local skin_id = player:get_meta():get_string("mcl_skins:skin_id")
|
||||||
local set_skin
|
local set_skin
|
||||||
|
@ -156,7 +155,7 @@ end)
|
||||||
|
|
||||||
mcl_skins.registered_on_set_skins = {}
|
mcl_skins.registered_on_set_skins = {}
|
||||||
|
|
||||||
mcl_skins.register_on_set_skin = function(func)
|
function mcl_skins.register_on_set_skin(func)
|
||||||
table.insert(mcl_skins.registered_on_set_skins, func)
|
table.insert(mcl_skins.registered_on_set_skins, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -231,7 +230,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
mcl_skins.show_formspec = function(playername)
|
function mcl_skins.show_formspec(playername)
|
||||||
local formspec = "size[7,8.5]"
|
local formspec = "size[7,8.5]"
|
||||||
|
|
||||||
formspec = formspec .. "label[2,2;" .. minetest.formspec_escape(minetest.colorize("#383838", S("Select player skin:"))) .. "]"
|
formspec = formspec .. "label[2,2;" .. minetest.formspec_escape(minetest.colorize("#383838", S("Select player skin:"))) .. "]"
|
||||||
|
|
|
@ -16,7 +16,7 @@ local players = {}
|
||||||
|
|
||||||
-- Returns true if the player with the given name is sprinting, false if not.
|
-- Returns true if the player with the given name is sprinting, false if not.
|
||||||
-- Returns nil if player does not exist.
|
-- Returns nil if player does not exist.
|
||||||
mcl_sprint.is_sprinting = function(playername)
|
function mcl_sprint.is_sprinting(playername)
|
||||||
if players[playername] then
|
if players[playername] then
|
||||||
return players[playername].sprinting
|
return players[playername].sprinting
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue