diff options
author | orwell <orwell@bleipb.de> | 2025-05-27 21:17:10 +0200 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2025-05-27 21:17:10 +0200 |
commit | 3470687be0af7254aca478ead1e9c72757edf070 (patch) | |
tree | 41781361c979cfda61a924d7471978037d68005e /ch_core/wielded_light.lua | |
parent | 8506dd2825b715293138976a5ad1fa11a46206a7 (diff) | |
download | advtrains-cesky-hvozd.tar.gz advtrains-cesky-hvozd.tar.bz2 advtrains-cesky-hvozd.zip |
Add CH dependencies temporarily.cesky-hvozd
Before merge to master should remove them again and split out util functions (e.g. formspec lib)
Diffstat (limited to 'ch_core/wielded_light.lua')
-rw-r--r-- | ch_core/wielded_light.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ch_core/wielded_light.lua b/ch_core/wielded_light.lua new file mode 100644 index 0000000..6059474 --- /dev/null +++ b/ch_core/wielded_light.lua @@ -0,0 +1,32 @@ +ch_core.open_submod("wielded_light", {data = true, lib = true, nodes = true}) + +local valid_numbers = {} + +for i = 0, minetest.LIGHT_MAX do + valid_numbers[i] = true +end + +function ch_core.set_player_light(player_name, slot, light_level) + local ll_1 = light_level or minetest.LIGHT_MAX + local ll = tonumber(ll_1) + if not ll then + minetest.log("warning", "Invalid light_level: "..ll_1) + return false + end + local online_charinfo = ch_data.online_charinfo[player_name] + if not online_charinfo or not valid_numbers[ll] then + return false + end + local slots = online_charinfo.wielded_lights + if not slots then + slots = {} + online_charinfo.wielded_lights = slots + end + if ll == 0 then + slots[slot] = nil + else + slots[slot] = ll + end +end + +ch_core.close_submod("wielded_light") |