mirror of
https://github.com/minetest-mods/drawers.git
synced 2024-11-22 14:43:45 +01:00
Fix "uninitialized global variable" warnings
This commit is contained in:
parent
69cad92b3e
commit
8009743d8d
16
lua/api.lua
16
lua/api.lua
@ -46,7 +46,7 @@ function drawers.drawer_on_construct(pos)
|
|||||||
-- meta
|
-- meta
|
||||||
local meta = core.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
|
|
||||||
i = 1
|
local i = 1
|
||||||
while i <= drawerType do
|
while i <= drawerType do
|
||||||
local vid = i
|
local vid = i
|
||||||
-- 1x1 drawers don't have numbers in the meta fields
|
-- 1x1 drawers don't have numbers in the meta fields
|
||||||
@ -84,7 +84,7 @@ function drawers.drawer_on_dig(pos, node, player)
|
|||||||
|
|
||||||
local meta = core.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
|
|
||||||
k = 1
|
local k = 1
|
||||||
while k <= drawerType do
|
while k <= drawerType do
|
||||||
-- don't add a number in meta fields for 1x1 drawers
|
-- don't add a number in meta fields for 1x1 drawers
|
||||||
local vid = tostring(k)
|
local vid = tostring(k)
|
||||||
@ -98,7 +98,7 @@ function drawers.drawer_on_dig(pos, node, player)
|
|||||||
local j = math.floor(count / stack_max) + 1
|
local j = math.floor(count / stack_max) + 1
|
||||||
local i = 1
|
local i = 1
|
||||||
while i <= j do
|
while i <= j do
|
||||||
rndpos = drawers.randomize_pos(pos)
|
local rndpos = drawers.randomize_pos(pos)
|
||||||
if not (i == j) then
|
if not (i == j) then
|
||||||
core.add_item(rndpos, name .. " " .. stack_max)
|
core.add_item(rndpos, name .. " " .. stack_max)
|
||||||
else
|
else
|
||||||
@ -141,11 +141,11 @@ function drawers.register_drawer(name, def)
|
|||||||
def.on_destruct = drawers.drawer_on_destruct
|
def.on_destruct = drawers.drawer_on_destruct
|
||||||
def.on_dig = drawers.drawer_on_dig
|
def.on_dig = drawers.drawer_on_dig
|
||||||
|
|
||||||
if screwdriver then
|
if minetest.get_modpath("screwdriver") and screwdriver then
|
||||||
def.on_rotate = def.on_rotate or screwdriver.disallow
|
def.on_rotate = def.on_rotate or screwdriver.disallow
|
||||||
end
|
end
|
||||||
|
|
||||||
if pipeworks then
|
if minetest.get_modpath("pipeworks") and pipeworks then
|
||||||
def.groups.tubedevice = 1
|
def.groups.tubedevice = 1
|
||||||
def.groups.tubedevice_receiver = 1
|
def.groups.tubedevice_receiver = 1
|
||||||
def.tube = def.tube or {}
|
def.tube = def.tube or {}
|
||||||
@ -159,7 +159,7 @@ function drawers.register_drawer(name, def)
|
|||||||
|
|
||||||
if drawers.enable_1x1 then
|
if drawers.enable_1x1 then
|
||||||
-- normal drawer 1x1 = 1
|
-- normal drawer 1x1 = 1
|
||||||
def1 = table.copy(def)
|
local def1 = table.copy(def)
|
||||||
def1.description = def.description .. " Drawer"
|
def1.description = def.description .. " Drawer"
|
||||||
def1.tiles = def.tiles or def.tiles1
|
def1.tiles = def.tiles or def.tiles1
|
||||||
def1.tiles1 = nil
|
def1.tiles1 = nil
|
||||||
@ -172,7 +172,7 @@ function drawers.register_drawer(name, def)
|
|||||||
|
|
||||||
if drawers.enable_1x2 then
|
if drawers.enable_1x2 then
|
||||||
-- 1x2 = 2
|
-- 1x2 = 2
|
||||||
def2 = table.copy(def)
|
local def2 = table.copy(def)
|
||||||
def2.description = def.description .. " Drawers (1x2)"
|
def2.description = def.description .. " Drawers (1x2)"
|
||||||
def2.tiles = def.tiles2
|
def2.tiles = def.tiles2
|
||||||
def2.tiles1 = nil
|
def2.tiles1 = nil
|
||||||
@ -184,7 +184,7 @@ function drawers.register_drawer(name, def)
|
|||||||
|
|
||||||
if drawers.enable_2x2 then
|
if drawers.enable_2x2 then
|
||||||
-- 2x2 = 4
|
-- 2x2 = 4
|
||||||
def4 = table.copy(def)
|
local def4 = table.copy(def)
|
||||||
def4.description = def.description .. " Drawers (2x2)"
|
def4.description = def.description .. " Drawers (2x2)"
|
||||||
def4.tiles = def.tiles4
|
def4.tiles = def.tiles4
|
||||||
def4.tiles1 = nil
|
def4.tiles1 = nil
|
||||||
|
@ -83,7 +83,7 @@ function drawers.spawn_visuals(pos)
|
|||||||
local fdir = vector.new(-bdir.x, 0, -bdir.z)
|
local fdir = vector.new(-bdir.x, 0, -bdir.z)
|
||||||
local pos2 = vector.add(pos, vector.multiply(fdir, 0.438))
|
local pos2 = vector.add(pos, vector.multiply(fdir, 0.438))
|
||||||
|
|
||||||
obj = core.add_entity(pos2, "drawers:visual")
|
local obj = core.add_entity(pos2, "drawers:visual")
|
||||||
|
|
||||||
if bdir.x < 0 then obj:setyaw(0.5 * math.pi) end
|
if bdir.x < 0 then obj:setyaw(0.5 * math.pi) end
|
||||||
if bdir.z < 0 then obj:setyaw(math.pi) end
|
if bdir.z < 0 then obj:setyaw(math.pi) end
|
||||||
@ -103,7 +103,7 @@ function drawers.spawn_visuals(pos)
|
|||||||
fdir2 = vector.new(-bdir.x, -0.5, -bdir.z)
|
fdir2 = vector.new(-bdir.x, -0.5, -bdir.z)
|
||||||
end
|
end
|
||||||
|
|
||||||
objs = {}
|
local objs = {}
|
||||||
|
|
||||||
drawers.last_visual_id = 1
|
drawers.last_visual_id = 1
|
||||||
drawers.last_texture = drawers.get_inv_image(core.get_meta(pos):get_string("name1"))
|
drawers.last_texture = drawers.get_inv_image(core.get_meta(pos):get_string("name1"))
|
||||||
@ -149,7 +149,7 @@ function drawers.spawn_visuals(pos)
|
|||||||
fdir4 = vector.new(-bdir.x, -0.5, -bdir.z + 0.5)
|
fdir4 = vector.new(-bdir.x, -0.5, -bdir.z + 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
objs = {}
|
local objs = {}
|
||||||
|
|
||||||
drawers.last_visual_id = 1
|
drawers.last_visual_id = 1
|
||||||
drawers.last_texture = drawers.get_inv_image(core.get_meta(pos):get_string("name1"))
|
drawers.last_texture = drawers.get_inv_image(core.get_meta(pos):get_string("name1"))
|
||||||
|
@ -51,7 +51,7 @@ core.register_entity("drawers:visual", {
|
|||||||
|
|
||||||
on_activate = function(self, staticdata, dtime_s)
|
on_activate = function(self, staticdata, dtime_s)
|
||||||
-- Restore data
|
-- Restore data
|
||||||
data = core.deserialize(staticdata)
|
local data = core.deserialize(staticdata)
|
||||||
if data then
|
if data then
|
||||||
self.drawer_pos = {
|
self.drawer_pos = {
|
||||||
x = data.drawer_posx,
|
x = data.drawer_posx,
|
||||||
|
Loading…
Reference in New Issue
Block a user