clean up deprecated vector tables

master
francisco athens 2022-08-27 09:30:55 -07:00
parent 322c684edc
commit 4366acd973
9 changed files with 96 additions and 178 deletions

View File

@ -1,3 +1,4 @@
2022/08/27: clean up deprecated vector tables
2022/02/23: Fixes and formatting
2022/02/22: Restored Cottages spawning over dungeons (!) and some related settings.
2022/02/19: Require only default and mobs now, additional checks, cottage generation now optional from game Settings tab > All Settings > Mods > witches

View File

@ -95,12 +95,7 @@ function witches.grounding(pos, vol_vec, required_list, exception_list,
replacement_node)
local r_tweak = math.random(-1, 1)
local area = vol_vec or
{
x = math.random(5 + r_tweak, 9),
y = 1,
z = math.random(5 - r_tweak, 9)
}
local area = vol_vec or vector.new(math.random(5 + r_tweak, 9), 1, math.random(5 - r_tweak, 9))
if not pos then
print("error: grounding failed pos checks")
@ -113,12 +108,8 @@ function witches.grounding(pos, vol_vec, required_list, exception_list,
-- local yaw = self.object:get_yaw()
-- print(mts(self.object:get_yaw()))
local pos1 = {
x = pos.x - (area.x / 2),
y = pos.y - area.y,
z = pos.z - (area.z / 2)
}
local pos2 = {x = pos.x + (area.x / 2), y = pos.y, z = pos.z + (area.z / 2)}
local pos1 = vector.new(pos.x - (area.x / 2), pos.y - area.y, pos.z - (area.z / 2))
local pos2 = vector.new(pos.x + (area.x / 2), pos.y, pos.z + (area.z / 2))
local ck_pos1 = vector.subtract(pos1, 4)
local ck_pos2 = vector.add(pos2, 4)
@ -138,7 +129,8 @@ function witches.grounding(pos, vol_vec, required_list, exception_list,
local protected_area = minetest.is_area_protected(ck_pos1, ck_pos2, "", 2)
if #exceptions and #exceptions >= 1 then
witches.debug("exceptions count = " .. #exceptions)
witches.debug("exceptions count = " .. #exceptions.." at "..vector.to_string(pos))
return
elseif protected_area then
witches.debug("protected area found at " .. mtpts(protected_area))
@ -223,22 +215,22 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
-- local od = vector.subtract(pos2,pos1)
local lower_corner_nodes = {
{x = pos1.x, y = pos1.y, z = pos1.z},
{x = pos1.x, y = pos1.y, z = pos2.z},
{x = pos2.x, y = pos1.y, z = pos2.z},
{x = pos2.x, y = pos1.y, z = pos1.z}
vector.new(pos1.x, pos1.y, pos1.z),
vector.new(pos1.x, pos1.y, pos2.z),
vector.new(pos2.x, pos1.y, pos2.z),
vector.new(pos2.x, pos1.y, pos1.z)
}
local upper_corner_nodes = {
{x = pos1.x, y = pos2.y, z = pos1.z},
{x = pos1.x, y = pos2.y, z = pos2.z},
{x = pos2.x, y = pos2.y, z = pos2.z},
{x = pos2.x, y = pos2.y, z = pos1.z}
vector.new(pos1.x, pos2.y, pos1.z),
vector.new(pos1.x, pos2.y, pos2.z),
vector.new(pos2.x, pos2.y, pos2.z),
vector.new(pos2.x, pos2.y, pos1.z)
}
local ucn = upper_corner_nodes
for h = 1, wp.foundation_depth do
for i = 1, #ucn do
local pos = {x = ucn[i].x, y = ucn[i].y - h + 1, z = ucn[i].z}
local pos = vector.new(ucn[i].x, ucn[i].y - h + 1, ucn[i].z)
minetest.set_node(pos, {
name = wp.foundation_nodes[math.random(#wp.foundation_nodes)]
})
@ -247,7 +239,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
for h = 1, wp.foundation_depth do
for i = 1, #ucn do
local pos = {x = ucn[i].x, y = ucn[i].y - h + 1, z = ucn[i].z}
local pos = vector.new(ucn[i].x, ucn[i].y - h + 1, ucn[i].z)
-- minetest.set_node(pos, {name = wp.foundation_nodes[math.random(#wp.foundation_nodes)]})
local pos_ck = vector.new(pos.x, pos.y - 10, pos.z)
local pillars = minetest.find_nodes_in_area(pos, pos_ck,
@ -259,20 +251,14 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
end
-- clear the area
local cpos1 = {x = pos1.x - ps, y = pos2.y, z = pos1.z - ps}
local cpos2 = {x = pos2.x + ps, y = pos2.y + 13, z = pos2.z + ps}
local cpos1 = vector.new(pos1.x - ps, pos2.y, pos1.z - ps)
local cpos2 = vector.new(pos2.x + ps, pos2.y + 13, pos2.z + ps)
local carea = vector.subtract(cpos2, cpos1)
for h = 1, carea.y + 2 do
for i = 1, carea.z + 1 do
for j = 1, carea.x + 1 do
local pos = {
x = cpos1.x + j - 1,
y = cpos1.y + h,
z = cpos1.z + i - 1
}
local pos = vector.new(cpos1.x + j - 1, cpos1.y + h, cpos1.z + i - 1)
minetest.set_node(pos, {name = "air"})
end
end
end
@ -280,13 +266,13 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
-- porch
local prnodes = wp.porch_nodes[math.random(#wp.porch_nodes)]
local ppos1 = {x = pos1.x - ps, y = pos2.y, z = pos1.z - ps}
local ppos2 = {x = pos2.x + ps, y = pos2.y, z = pos2.z + ps}
local ppos1 = vector.new(pos1.x - ps, pos2.y, pos1.z - ps)
local ppos2 = vector.new(pos2.x + ps, pos2.y, pos2.z + ps)
local parea = vector.subtract(ppos2, ppos1)
for i = 1, parea.z + 1 do
for j = 1, parea.x + 1 do
local pos = {x = ppos1.x + j - 1, y = ppos1.y, z = ppos1.z + i - 1}
local pos = vector.new(ppos1.x + j - 1, ppos1.y, ppos1.z + i - 1)
minetest.set_node(pos, {
name = prnodes,
paramtype2 = "facedir",
@ -298,10 +284,10 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
local pcn = {
{x = pos1.x - ps, y = pos2.y, z = pos1.z - ps},
{x = pos1.x - ps, y = pos2.y, z = pos2.z + ps},
{x = pos2.x + ps, y = pos2.y, z = pos2.z + ps},
{x = pos2.x + ps, y = pos2.y, z = pos1.z - ps}
vector.new(pos1.x - ps, pos2.y, pos1.z - ps),
vector.new(pos1.x - ps, pos2.y, pos2.z + ps),
vector.new(pos2.x + ps, pos2.y, pos2.z + ps),
vector.new(pos2.x + ps, pos2.y, pos1.z - ps)
}
local pcn_height = wp.foundation_depth + 1
@ -309,7 +295,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
for i = 1, #pcn do
local pos = vector.new(pcn[i].x, pcn[i].y + 2 - h, pcn[i].z)
-- minetest.set_node(pos, {name = wall_node})
-- minetest.set_node({x = pos.x, y = pos.y - 1, z = pos.z}, {name = root_node})
-- minetest.set_node(vector.new(pos.x, pos.y - 1, pos.z), {name = root_node})
local pos_ck = vector.new(pos.x, pos.y - 10, pos.z)
local pillars = minetest.find_nodes_in_area(pos, pos_ck,
{"group:liquid", "air"})
@ -325,27 +311,11 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
local treecn = {
{
x = pcn[1].x - ps + mr(-1, 1),
y = pos2.y - 1,
z = pcn[1].z - ps + mr(-1, 1)
},
{
x = pcn[2].x - ps + mr(-1, 1),
y = pos2.y - 1,
z = pcn[2].z + ps + mr(-1, 1)
},
{
x = pcn[3].x + ps + mr(-1, 1),
y = pos2.y - 1,
z = pcn[3].z + ps + mr(-1, 1)
},
{
x = pcn[4].x + ps + mr(-1, 1),
y = pos2.y - 1,
z = pcn[4].z - ps + mr(-1, 1)
}
}
vector.new(pcn[1].x - ps + mr(-1, 1), pos2.y - 1, pcn[1].z - ps + mr(-1, 1)),
vector.new(pcn[2].x - ps + mr(-1, 1), pos2.y - 1, pcn[2].z + ps + mr(-1, 1)),
vector.new(pcn[3].x + ps + mr(-1, 1), pos2.y - 1, pcn[3].z + ps + mr(-1, 1)),
vector.new(pcn[4].x + ps + mr(-1, 1), pos2.y - 1, pcn[4].z - ps + mr(-1, 1))
}
if wp.tree_types and #wp.tree_types >= 1 then
---this check fails without "minetest" game, why!?
local tree_pos = treecn[math.random(#treecn)]
@ -364,18 +334,14 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
-- first floor!
local ffnodes = wp.first_floor_nodes[math.random(#wp.first_floor_nodes)]
local ffpos1 = {x = pos1.x, y = pos2.y, z = pos1.z}
local ffpos2 = {x = pos2.x, y = pos2.y, z = pos2.z}
local ffpos1 = vector.new(pos1.x, pos2.y, pos1.z)
local ffpos2 = vector.new(pos2.x, pos2.y, pos2.z)
local area = vector.subtract(pos2, pos1)
for i = 1, area.z + 1 do
for j = 1, area.x + 1 do
local pos = {
x = ffpos1.x + j - 1,
y = ffpos1.y,
z = ffpos1.z + i - 1
}
local pos = vector.new(ffpos1.x + j - 1, ffpos1.y, ffpos1.z + i - 1)
minetest.set_node(pos, {
name = ffnodes,
paramtype2 = "facedir",
@ -391,14 +357,14 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
for h = 1, wp.wall_height do
for i = 1, #ucn do
if h % 2 == 0 then
local pos = {x = ucn[i].x, y = ucn[i].y + h, z = ucn[i].z}
local pos = vector.new(ucn[i].x, ucn[i].y + h, ucn[i].z)
minetest.set_node(pos, {
name = wall_node,
paramtype2 = "facedir",
param2 = 5
})
else
local pos = {x = ucn[i].x, y = ucn[i].y + h, z = ucn[i].z}
local pos = vector.new(ucn[i].x, ucn[i].y + h, ucn[i].z)
minetest.set_node(pos, {
name = wall_node,
paramtype2 = "facedir",
@ -411,7 +377,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
-- wall corners stone
for h = 1, wp.wall_height do
for i = 1, #ucn do
local pos = {x = ucn[i].x, y = ucn[i].y + h, z = ucn[i].z}
local pos = vector.new(ucn[i].x, ucn[i].y + h, ucn[i].z)
minetest.set_node(pos, {
name = wp.foundation_nodes[math.random(#wp.foundation_nodes)]
})
@ -422,8 +388,8 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
-- create first floor wall plan!
local wall_plan = {}
for i = 1, area.z - 1 do -- west wall
local pos = {x = ffpos1.x, y = ffpos1.y + 1, z = ffpos1.z + i}
local fpos = {x = ffpos1.x, y = ffpos1.y + 1, z = ffpos1.z - 1}
local pos = vector.new(ffpos1.x, ffpos1.y + 1, ffpos1.z + i)
local fpos = vector.new(ffpos1.x, ffpos1.y + 1, ffpos1.z - 1)
local dir = vector.direction(fpos, pos) -- the raw dir we can manipulate later
local facedir = minetest.dir_to_facedir(dir) -- this facedir
-- walldir is for placing tree nodes in wall direction
@ -433,8 +399,8 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
end
for i = 1, area.x - 1 do -- north wall
local pos = {x = ffpos1.x + i, y = ffpos1.y + 1, z = ffpos1.z}
local fpos = {x = ffpos1.x - 1, y = ffpos1.y + 1, z = ffpos1.z}
local pos = vector.new(ffpos1.x + i, ffpos1.y + 1, ffpos1.z)
local fpos = vector.new(ffpos1.x - 1, ffpos1.y + 1, ffpos1.z)
local dir = vector.direction(fpos, pos)
local facedir = minetest.dir_to_facedir(dir)
table.insert(wall_plan,
@ -442,8 +408,8 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
end
for i = 1, area.z - 1 do -- east wall
local pos = {x = ffpos1.x + area.x, y = ffpos1.y + 1, z = ffpos1.z + i}
local fpos = {x = ffpos1.x + area.x, y = ffpos1.y + 1, z = ffpos1.z - 1}
local pos = vector.new(ffpos1.x + area.x, ffpos1.y + 1, ffpos1.z + i)
local fpos = vector.new(ffpos1.x + area.x, ffpos1.y + 1, ffpos1.z - 1)
local dir = vector.direction(fpos, pos)
local facedir = minetest.dir_to_facedir(dir)
table.insert(wall_plan,
@ -451,8 +417,8 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
end
for i = 1, area.x - 1 do -- south wall
local pos = {x = ffpos1.x + i, y = ffpos1.y + 1, z = ffpos1.z + area.z}
local fpos = {x = ffpos1.x - 1, y = ffpos1.y + 1, z = ffpos1.z + area.z}
local pos = vector.new(ffpos1.x + i, ffpos1.y + 1, ffpos1.z + area.z)
local fpos = vector.new(ffpos1.x - 1, ffpos1.y + 1, ffpos1.z + area.z)
local dir = vector.direction(fpos, pos)
local facedir = minetest.dir_to_facedir(dir)
table.insert(wall_plan,
@ -641,7 +607,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
for i = 1, window_height do
witches.debug("window set: " .. mtpts(v))
minetest.set_node({x = v.x, y = v.y - 1 + i, z = v.z},
minetest.set_node(vector.new(v.x, v.y - 1 + i, v.z),
{name = window_node})
end
@ -808,18 +774,14 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
-- second_floor!
local sfnodes = wp.second_floor_nodes[math.random(#wp.second_floor_nodes)]
local sfpos1 = {x = ffpos1.x, y = ffpos2.y + wp.wall_height, z = ffpos1.z}
local sfpos2 = {x = ffpos2.x, y = ffpos2.y + wp.wall_height, z = ffpos2.z}
local sfpos1 = vector.new(ffpos1.x, ffpos2.y + wp.wall_height, ffpos1.z)
local sfpos2 = vector.new(ffpos2.x, ffpos2.y + wp.wall_height, ffpos2.z)
local sfarea = vector.subtract(sfpos2, sfpos1)
--
for i = 1, sfarea.z + 1 do
for j = 1, sfarea.x + 1 do
local pos = {
x = sfpos1.x + j - 1,
y = sfpos1.y + 1,
z = sfpos1.z + i - 1
}
local pos = vector.new(sfpos1.x + j - 1, sfpos1.y + 1, sfpos1.z + i - 1)
minetest.set_node(pos, {
name = sfnodes,
paramtype2 = "facedir",
@ -854,12 +816,12 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
local gbnodes = wp.gable_nodes[rfnum]
local orientations = {{"x", "z"}, {"z", "x"}}
local o = orientations[math.random(#orientations)]
local gbpos1 = vector.new({x = sfpos1.x, y = sfpos2.y + 1, z = sfpos1.z})
local gbpos2 = vector.new({x = sfpos2.x, y = sfpos2.y + 1, z = sfpos2.z}) -- this is going to change while building
local gbpos1 = vector.new(sfpos1.x, sfpos2.y + 1, sfpos1.z)
local gbpos2 = vector.new(sfpos2.x, sfpos2.y + 1, sfpos2.z) -- this is going to change while building
local rfpos1 =
vector.new({x = sfpos1.x - 1, y = sfpos2.y, z = sfpos1.z - 1})
vector.new(sfpos1.x - 1, sfpos2.y, sfpos1.z - 1)
local rfpos2 =
vector.new({x = sfpos2.x + 1, y = sfpos2.y, z = sfpos2.z + 1}) -- this is going to change while building
vector.new(sfpos2.x + 1, sfpos2.y, sfpos2.z + 1) -- this is going to change while building
local rfarea = vector.subtract(rfpos2, rfpos1)
local gbarea = vector.subtract(gbpos2, gbpos1)
@ -872,11 +834,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
local gmp = rfarea.z - 1
for i = 1, midpoint do
for j = 1, rfarea.x + 1 do
local pos = {
x = rfpos1.x + j - 1,
y = rfpos2.y + 1,
z = rfpos1.z + i - 1
}
local pos = vector.new(rfpos1.x + j - 1, rfpos2.y + 1, rfpos1.z + i - 1)
minetest.set_node(pos, {
name = rf_nodes,
paramtype2 = "facedir",
@ -886,16 +844,8 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
-- both gables are made at the same time
for g = 1, gmp do
local gpos = {
x = gbpos1.x,
y = rfpos2.y + 2,
z = gbpos1.z + gmp - g
}
local gpos2 = {
x = gbpos1.x + gbarea.x,
y = rfpos2.y + 2,
z = gbpos1.z + gmp - g
}
local gpos = vector.new(gbpos1.x, rfpos2.y + 2, gbpos1.z + gmp - g)
local gpos2 = vector.new(gbpos1.x + gbarea.x, rfpos2.y + 2, gbpos1.z + gmp - g)
minetest.bulk_set_node({gpos, gpos2}, {
name = gbnodes,
paramtype2 = "facedir",
@ -911,17 +861,13 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
rfpos2.y = rfpos2.y + 1
end
rfpos2 = vector.new({x = sfpos2.x + 1, y = sfpos2.y, z = sfpos2.z + 1}) -- reset rfpos2 for other side of roof
rfpos2 = vector.new(sfpos2.x + 1, sfpos2.y, sfpos2.z + 1) -- reset rfpos2 for other side of roof
rfarea = vector.subtract(rfpos2, rfpos1)
local rfamid = math.floor((rfarea.z + 1) / 2)
for i = rfarea.z + 1, rfamid + 1, -1 do
for j = 1, rfarea.x + 1 do
local pos = {
x = rfpos1.x + j - 1,
y = rfpos2.y + 1,
z = rfpos1.z + i - 1
}
local pos = vector.new(rfpos1.x + j - 1, rfpos2.y + 1, rfpos1.z + i - 1)
minetest.set_node(pos, {
name = rf_nodes,
paramtype2 = "facedir",
@ -935,11 +881,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
if rfarea.z % 2 == 0 then
for j = 1, rfarea.x + 1 do
local pos = {
x = rfpos1.x + j - 1,
y = rfpos2.y,
z = rfpos1.z + (rfarea.z / 2)
}
local pos = vector.new(rfpos1.x + j - 1, rfpos2.y, rfpos1.z + (rfarea.z / 2))
minetest.set_node(pos, {name = rf_slabs})
end
-- p is positional axis along which it is made
@ -1006,11 +948,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
for j = 1, (rfarea.x + 1) / 2 do
for i = 1, rfarea.z + 1 do
local pos = {
x = rfpos1.x + j - 1,
y = rfpos2.y + 1,
z = rfpos1.z + i - 1
}
local pos = vector.new(rfpos1.x + j - 1, rfpos2.y + 1, rfpos1.z + i - 1)
minetest.set_node(pos, {
name = rf_nodes,
paramtype2 = "facedir",
@ -1020,16 +958,8 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
for g = 1, gmp do
local gpos = {
x = gbpos1.x + gmp - g,
y = rfpos2.y + 2,
z = gbpos1.z
}
local gpos2 = {
x = gbpos1.x + gmp - g,
y = rfpos2.y + 2,
z = gbpos1.z + gbarea.z
}
local gpos = vector.new(gbpos1.x + gmp - g, rfpos2.y + 2, gbpos1.z)
local gpos2 = vector.new(gbpos1.x + gmp - g, rfpos2.y + 2, gbpos1.z + gbarea.z)
minetest.bulk_set_node({gpos, gpos2}, {
name = gbnodes,
paramtype2 = "facedir",
@ -1042,17 +972,13 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
rfpos2.y = rfpos2.y + 1
end
rfpos2 = vector.new({x = sfpos2.x + 1, y = sfpos2.y, z = sfpos2.z + 1}) -- reset rfpos2 for other side of roof
rfpos2 = vector.new(sfpos2.x + 1, sfpos2.y, sfpos2.z + 1) -- reset rfpos2 for other side of roof
rfarea = vector.subtract(rfpos2, rfpos1)
local rfamid = math.floor((rfarea.x + 1) / 2)
for j = rfarea.x + 1, rfamid + 1, -1 do
for i = 1, rfarea.z + 1 do
local pos = {
x = rfpos1.x + j - 1,
y = rfpos2.y + 1,
z = rfpos1.z + i - 1
}
local pos = vector.new(rfpos1.x + j - 1, rfpos2.y + 1, rfpos1.z + i - 1)
minetest.set_node(pos, {
name = rf_nodes,
paramtype2 = "facedir",
@ -1065,11 +991,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
if rfarea.x % 2 == 0 then
for i = 1, rfarea.z + 1 do
local pos = {
x = rfpos1.x + (rfarea.x / 2),
y = rfpos2.y,
z = rfpos1.z + i - 1
}
local pos = vector.new(rfpos1.x + (rfarea.x / 2), rfpos2.y, rfpos1.z + i - 1)
minetest.set_node(pos, {name = rf_slabs})
end
local wpos1 = {
@ -1173,6 +1095,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
local lpn = math.random(#l_pos)
local lpc = l_pos[lpn]
local ladder_length = nil
--for a dungeon beneath cottage, extend ladder below cottage
if d_ladder_pos and d_ladder_pos.y then
ladder_length = lpc.y - 1 - d_ladder_pos.y
else
@ -1200,19 +1123,15 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
end
witches.debug("ladder: " .. mtpts(lpc))
else
local loftpos1 = {x = sfpos1.x + 2, y = sfpos1.y + 1, z = sfpos1.z + 1}
local loftpos2 = {x = sfpos2.x - 2, y = sfpos1.y + 1, z = sfpos2.z - 1}
local loftpos1 = vector.new(sfpos1.x + 2, sfpos1.y + 1, sfpos1.z + 1)
local loftpos2 = vector.new(sfpos2.x - 2, sfpos1.y + 1, sfpos2.z - 1)
local loftarea = vector.subtract(loftpos2, loftpos1)
witches.debug(dump(loftpos1))
witches.debug(dump(loftpos2))
witches.debug(dump(loftarea))
for i = 1, loftarea.z + 1 do
for j = 1, loftarea.x + 1 do
local pos = {
x = loftpos1.x - 1 + j,
y = loftpos1.y,
z = loftpos1.z - 1 + i
}
local pos = vector.new(loftpos1.x - 1 + j, loftpos1.y, loftpos1.z - 1 + i)
witches.debug(mts(pos))
minetest.set_node(pos, {name = "air"})
end

View File

@ -1,10 +1,10 @@
-- Witches is copyright 2020 Francisco Athens, Ramona Athens, Damon Athens and Simone Athens
-- Witches is copyright 2022 Francisco Athens, Ramona Athens, Damon Athens and Simone Athens
-- The MIT License (MIT)
-- local mod_name = "witches"
local path = minetest.get_modpath("witches")
witches = {}
witches.version = "20220223"
witches.version = "202200827"
print("This is Witches " .. witches.version .. "!")
-- Strips any kind of escape codes (translation, colors) from a string

View File

@ -150,7 +150,7 @@ for i,v in pairs(witches.witch_hair_styles) do
collisionbox = {0,0,0,0,0,0},
visual = "mesh",
mesh = "witches_witch-hair_"..v..".b3d",
visual_size = {x = 1, y = 1, z = 1},
visual_size = vector.new(1, 1, 1),
textures = {"witches_witch_hair.png"},
},
message = "Default message",
@ -201,7 +201,7 @@ for i,v in pairs(witches.witch_hat_styles) do
collisionbox = {0,0,0,0,0,0},
visual = "mesh",
mesh = "witches_witch-hat_"..v..".b3d",
visual_size = {x = 1, y = 1, z = 1},
visual_size = vector.new(1, 1, 1),
textures = {"witches_witch_hat.png"},
},
message = "Default message",

View File

@ -34,10 +34,10 @@ minetest.add_particlespawner({
time=.1,
minpos= pos1,
maxpos= pos2,
minvel={x=0, y=0, z=0},
maxvel={x=0, y=1, z=0},
minacc={x=0, y=0, z=0},
maxacc={x=0, y=1, z=0},
minvel=vector.new(0, 0, 0),
maxvel=vector.new(0, 1, 0),
minacc=vector.new(0, 0, 0),
maxacc=vector.new(0, 1, 0),
minexptime=.01,
maxexptime=.5,
minsize=1,
@ -67,10 +67,10 @@ function witches.magic.effect_line01(pos1,pos2,density)
time=.1,
minpos= v_pos1,
maxpos= v_pos2,
minvel={x=0, y=0, z=0},
maxvel={x=0, y=1, z=0},
minacc={x=0, y=0, z=0},
maxacc={x=0, y=1, z=0},
minvel= vector.new(0, 0, 0),
maxvel= vector.new(0, 1, 0),
minacc= vector.new(0, 0, 0),
maxacc= vector.new(0, 1, 0),
minexptime=.01,
maxexptime=.5,
minsize=1,
@ -120,7 +120,7 @@ function witches.magic.teleport(self,target,strength,height)
target:set_pos(new_target_pos)
witches.magic.effect_line01(caster_pos,new_target_pos,50)
local vol = pos_to_vol(caster_pos,{x=2,y=2,z=2})
local vol = pos_to_vol(caster_pos,vector.new(2,2,2))
--print(minetest.pos_to_string(caster_pos))
--print(minetest.pos_to_string(vol[1]))
@ -151,7 +151,7 @@ function witches.magic.polymorph(self, target, mob, duration)
witches.magic.effect_line01(caster_pos,ent_pos,50)
ent.object:remove()
local vol_ent = pos_to_vol(ent_pos,{x=2,y=2,z=2})
local vol_ent = pos_to_vol(ent_pos,vector.new(2,2,2))
--print(minetest.pos_to_string(caster_pos))
--print(minetest.pos_to_string(vol[1]))
@ -167,13 +167,13 @@ function witches.magic.polymorph(self, target, mob, duration)
end
--volume is a vector!
function witches.magic.splash(self,target,volume,height,node)
volume = volume or {x=3,y=3,z=3}
volume = volume or vector.new(3,3,3)
height = height or 0
node = node or "default:water_flowing"
local caster_pos = self.object:get_pos()
local ent = target:get_luaentity()
local ent_pos = ent.object:get_pos()
local ent_pos_yoff = vector.add(ent_pos,{x=0,y=height,z=0})
local ent_pos_yoff = vector.add(ent_pos,vector.new(0,height,0))
local vol = pos_to_vol(ent_pos_yoff,volume)
minetest.sound_play(self.sounds.drench or "witches_water", {
pos = ent_pos,

View File

@ -127,19 +127,19 @@ function witches.flower_patch(pos)
-- print(r_flower)
local check = minetest.get_node(pos)
if string.find(check.name, "dirt") then
minetest.place_node({x = fpos.x, y = fpos.y + 1, z = fpos.z},
minetest.place_node(vector.new(fpos.x, fpos.y + 1, fpos.z),
{name = r_flower})
-- flowers.flower_spread(fpos, {name = r_flower})
return r_flower
elseif string.find(check.name, "sand") then
if math.random() < 0.20 then
minetest.set_node({x = fpos.x, y = fpos.y + 1, z = fpos.z},
minetest.set_node(vector.new(fpos.x, fpos.y + 1, fpos.z),
{name = "default:large_cactus_seedling"})
elseif minetest.get_modpath("farming") then
minetest.set_node({x = fpos.x, y = fpos.y + 1, z = fpos.z},
minetest.set_node(vector.new(fpos.x, fpos.y + 1, fpos.z),
{name = "farming:cotton_wild"})
else
minetest.set_node({x = fpos.x, y = fpos.y + 1, z = fpos.z},
minetest.set_node(vector.new(fpos.x, fpos.y + 1, fpos.z),
{name = "default:dry_shrub"})
end

View File

@ -81,7 +81,7 @@ for _, col in ipairs(all_colours) do
on_spawn = function(self)
if not self.size then
local overall = variance(100,200)
self.size = {x = overall*variance(90,110), y = overall*variance(90,110), z = overall*variance(90,110)}
self.size = vector.new(overall*variance(90,110), overall*variance(90,110), overall*variance(90,110))
end
local self_properties = self.object:get_properties()

View File

@ -399,8 +399,7 @@ function witches.claim_witches_chest(self)
witches.debug("unbound chest: " .. sn)
meta:set_string("owner", self.secret_name)
meta:set_string("infotext",
self.secret_name .. "'s sealed chest")
S("Sealed chest of @1",self.secret_name))
self.witches_chest = sn
self.witches_chest_owner = self.secret_name
self.witches_chest_pos = meta_table[i]

View File

@ -29,7 +29,7 @@ local spawning = {
min_light = 5,
max_light = 15,
interval = 300,
chance = 100,
chance = 1000,
active_object_count = 1,
min_height = 0,
max_height = 200,
@ -112,8 +112,8 @@ witches.witch_types = {
},
do_custom_addendum = function(self)
if witches.cottages then
if not self.built_house and math.random() < 0.01 then
if not self.built_house and math.random() < 0.001 then
witches.debug(self.secret_name.." grounding...")
local volume = witches.grounding(self.object:get_pos())
if volume then
witches.debug("volume passed: " .. dump(volume))
@ -248,8 +248,7 @@ witches.witch_template = { -- your average witch,
witches.magic.teleport(self, objs[n],
math.random(3, 5),
math.random(1, 2))
witches.magic.splash(self, objs[n],
{x = 2, y = 2, z = 2},
witches.magic.splash(self, objs[n], vector.new(2, 2, 2),
math.random(0, 1))
-- witches.magic.splash(self,target,volume,height,node)
else