Small Fixes, mostly testing out an editor

master
Benrob0329 2020-02-01 03:32:53 -05:00
parent 1475d27ebb
commit d5778ca58e
4 changed files with 12 additions and 16 deletions

View File

@ -1,8 +1,4 @@
function ikea.is_open()
local tod = minetest.get_timeofday()
if tod >= (7 / 24) and tod <= (23 / 24) then
return true
else
return false
end
return tod >= (7 / 24) and tod <= (23 / 24)
end

View File

@ -5,9 +5,9 @@ local ceiling_schematic = schematic.new({x = 16, y = 1, z = 16}, "ikea:ceiling")
-- Originally Written By Warr1024
-- Wait until mapgen initializes to get the noise
local pn
local Perlin
minetest.after(0, function()
pn = minetest.get_perlin(0, 1, 0, 1)
Perlin = minetest.get_perlin(0, 1, 0, 1)
end)
-- Store functions in a table so that they're all in scope of each other without being made global
@ -25,7 +25,7 @@ function bsp.split(r, min, max, val, bd)
end
function bsp.pick_department(options, x_min, x_max, z_min, z_max, x, z, check_inner)
local department = options.departments[util.bound_perlin(pn, #options.departments, x_min, 2, z_min)]
local department = options.departments[util.bound_perlin(Perlin, #options.departments, x_min, 2, z_min)]
local edges = {w = x <= x_min, e = x >= x_max, s = z <= z_min, n = z >= z_max}
edges.inner = {w = false, e = false, n = false, s = false}
@ -64,9 +64,9 @@ function bsp.subdivide(options, x_min, x_max, z_min, z_max, x, z, check_inner)
local width = x_max - x_min + 1
local height = z_max - z_min + 1
if (width > options.max_size) or (height > options.max_size) or (util.tail_perlin(pn, x_min, 0, z_min) == 1) then
if (width > options.max_size) or (height > options.max_size) or (util.tail_perlin(Perlin, x_min, 0, z_min) == 1) then
if height > width then
local z_min2, z_max2 = bsp.split(util.tail_perlin(pn, x_min, 1, z_min), z_min, z_max, z, options.min_size)
local z_min2, z_max2 = bsp.split(util.tail_perlin(Perlin, x_min, 1, z_min), z_min, z_max, z, options.min_size)
local height2 = z_max2 - z_min2 + 1
if (height2 < options.min_size) or ((height - height2) < options.min_size) then
@ -75,7 +75,7 @@ function bsp.subdivide(options, x_min, x_max, z_min, z_max, x, z, check_inner)
return bsp.subdivide(options, x_min, x_max, z_min2, z_max2, x, z, check_inner)
else
local x_min2, x_max2 = bsp.split(util.tail_perlin(pn, x_min, 1, z_min), x_min, x_max, x, options.min_size)
local x_min2, x_max2 = bsp.split(util.tail_perlin(Perlin, x_min, 1, z_min), x_min, x_max, x, options.min_size)
local width2 = x_max2 - x_min2 + 1
if (width2 < options.min_size) or ((width - width2) < options.min_size) then

View File

@ -247,7 +247,7 @@ minetest.register_entity("ikea_staff:member", {
end
end
self.hostile = ikea.is_open()
self.hostile = not ikea.is_open()
-- BUG: When it becomes day, if a staff member is following a player, they just walk in a line forever
local pos = self.object:get_pos()

View File

@ -1,3 +1,7 @@
local modpath = minetest.get_modpath("ikea_warehouse")
dofile(modpath .. "/nodes.lua")
local schems = dofile(modpath .. "/schematics.lua")
local applicable_furniture
local should_place_aisle = util.every_n_mapblocks(4)
local Perlin = PerlinNoise({
@ -11,10 +15,6 @@ local Perlin = PerlinNoise({
flags = "defaults, absvalue",
})
local modpath = minetest.get_modpath("ikea_warehouse")
dofile(modpath .. "/nodes.lua")
local schems = dofile(modpath .. "/schematics.lua")
minetest.register_on_mods_loaded(function()
applicable_furniture = table.search(ikea.registered_furniture, {includes = {size_x = 1, size_y = 1, size_z = 1}})
end)