Move "light_api" mod to "ikea_light"

master
benrob0329 2019-07-11 01:06:34 -04:00
parent f7950d5c30
commit dae4992665
5 changed files with 17 additions and 14 deletions

View File

@ -1,8 +1,9 @@
light = {} ikea.light = {}
ikea.light.sound_gain = 0.1
-- Set node to the base light node if the name ends in "_off" -- Set node to the base light node if the name ends in "_off"
-- Otherwise set it to the name + "_off" -- Otherwise set it to the name + "_off"
function light.toggle_light(pos, node, play_sound) function ikea.light.toggle_light(pos, node, play_sound)
local store_tod = ikea.time.get_storetime() local store_tod = ikea.time.get_storetime()
local is_off = false local is_off = false
if node.name:sub(-4) == "_off" then if node.name:sub(-4) == "_off" then
@ -13,11 +14,11 @@ function light.toggle_light(pos, node, play_sound)
minetest.swap_node(pos, {name = node.name:sub(0,-5)}) minetest.swap_node(pos, {name = node.name:sub(0,-5)})
if play_sound then if play_sound then
minetest.sound_play("light_api_toggle", { minetest.sound_play({
name = "light_api_toggle", name = "ikea_light_toggle",
pos = pos, pos = pos,
max_hear_distance = 150, max_hear_distance = 150,
gain = 1.0, gain = ikea.light.sound_gain,
pitch = 1.0, pitch = 1.0,
}) })
end end
@ -26,11 +27,11 @@ function light.toggle_light(pos, node, play_sound)
minetest.swap_node(pos, {name = node.name.."_off"}) minetest.swap_node(pos, {name = node.name.."_off"})
if play_sound then if play_sound then
minetest.sound_play("light_api_toggle", { minetest.sound_play({
name = "light_api_toggle", name = "ikea_light_toggle",
pos = pos, pos = pos,
max_hear_distance = 150, max_hear_distance = 150,
gain = 1.0, gain = ikea.light.sound_gain,
pitch = 1.0, pitch = 1.0,
}) })
end end
@ -48,7 +49,7 @@ local light_default = {
light_source = minetest.LIGHT_MAX, light_source = minetest.LIGHT_MAX,
} }
function light.register_light(name, def) function ikea.light.register_light(name, def)
local def = { local def = {
description = (def.description or light_default.description), description = (def.description or light_default.description),
paramtype = "light", paramtype = "light",
@ -78,18 +79,18 @@ minetest.register_abm({
chance = 2, chance = 2,
catch_up = false, catch_up = false,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
light.toggle_light(pos, node, true) ikea.light.toggle_light(pos, node, true)
end end
}) })
-- Toggle the lights loaded in without sound -- Toggle the lights loaded in without sound
minetest.register_lbm({ minetest.register_lbm({
label = "Light Updater LBM", label = "Light Updater LBM",
name = "light_api:light_toggle", name = "ikea_light:light_toggle",
nodenames = {"group:light"}, nodenames = {"group:light"},
run_at_every_load = true, run_at_every_load = true,
action = function(pos, node) action = function(pos, node)
light.toggle_light(pos, node, false) ikea.light.toggle_light(pos, node, false)
end, end,
}) })

2
mods/ikea_light/mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = ikea_light
depends = ikea

View File

@ -1,2 +1,2 @@
name = warehouse name = warehouse
depends = mapgen,light_api depends = mapgen,ikea_light

View File

@ -16,7 +16,7 @@ minetest.register_node("warehouse:rack", {
sunlight_propagates = true, sunlight_propagates = true,
}) })
light.register_light("warehouse:light", { ikea.light.register_light("warehouse:light", {
description = "Lights That Light The Warehouse", description = "Lights That Light The Warehouse",
mesh = "warehouse_light.obj", mesh = "warehouse_light.obj",
tiles = {name = "warehouse_light.png"}, tiles = {name = "warehouse_light.png"},