mirror of
https://github.com/technix/ham_radio.git
synced 2024-08-18 20:24:07 +02:00
add beacons (self-configurable transmitters)
This commit is contained in:
parent
59e29f5e3a
commit
3a1b5cde9d
38
beacon.lua
Normal file
38
beacon.lua
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
minetest.register_node("ham_radio:beacon", {
|
||||||
|
description = "Ham Radio Beacon",
|
||||||
|
tiles = {
|
||||||
|
"ham_radio_transmitter_top.png",
|
||||||
|
"ham_radio_transmitter_top.png",
|
||||||
|
"ham_radio_transmitter_side.png",
|
||||||
|
"ham_radio_transmitter_side.png",
|
||||||
|
"ham_radio_transmitter_side.png",
|
||||||
|
"ham_radio_beacon_front.png"
|
||||||
|
},
|
||||||
|
groups = {cracky=2,oddly_breakable_by_hand=2},
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drawtype = "nodebox",
|
||||||
|
paramtype = "light",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||||
|
},
|
||||||
|
light_source = 5,
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local name = placer:get_player_name()
|
||||||
|
meta:set_string('operated_by', name)
|
||||||
|
meta:set_string("frequency", ham_radio.find_free_frequency(ham_radio.settings.beacon_frequency))
|
||||||
|
ham_radio.transmitter_update_infotext(meta)
|
||||||
|
ham_radio.save_transmitter(pos, meta)
|
||||||
|
end,
|
||||||
|
can_dig = function(pos,player)
|
||||||
|
local meta = minetest.get_meta(pos);
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
local name = player:get_player_name()
|
||||||
|
return inv:is_empty("main") and not minetest.is_protected(pos, name)
|
||||||
|
end,
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, player)
|
||||||
|
ham_radio.delete_transmitter(pos)
|
||||||
|
end,
|
||||||
|
});
|
@ -18,10 +18,10 @@ function ham_radio.find_transmitters(frequency)
|
|||||||
return transmitter_list
|
return transmitter_list
|
||||||
end
|
end
|
||||||
|
|
||||||
function ham_radio.find_free_frequency()
|
function ham_radio.find_free_frequency(range)
|
||||||
local frequency = -1
|
local frequency = -1
|
||||||
while frequency == -1 do
|
while frequency == -1 do
|
||||||
frequency = tostring(math.floor(math.random(ham_radio.settings.frequency.min, ham_radio.settings.frequency.max)));
|
frequency = tostring(math.floor(math.random(range.min, range.max)));
|
||||||
local are_there_transmitters = ham_radio.find_transmitters(frequency)
|
local are_there_transmitters = ham_radio.find_transmitters(frequency)
|
||||||
if next(are_there_transmitters) then
|
if next(are_there_transmitters) then
|
||||||
frequency = -1
|
frequency = -1
|
||||||
|
10
init.lua
10
init.lua
@ -16,6 +16,10 @@ ham_radio = {
|
|||||||
min = 0,
|
min = 0,
|
||||||
max = 9999999
|
max = 9999999
|
||||||
},
|
},
|
||||||
|
beacon_frequency = { -- sub-range of frequency range
|
||||||
|
min = 1000000,
|
||||||
|
max = 9999999
|
||||||
|
},
|
||||||
digiline_channel = "ham_radio",
|
digiline_channel = "ham_radio",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,6 +52,7 @@ dofile(modpath.."/craft.lua")
|
|||||||
dofile(modpath.."/digiline.lua")
|
dofile(modpath.."/digiline.lua")
|
||||||
dofile(modpath.."/transmitter.lua")
|
dofile(modpath.."/transmitter.lua")
|
||||||
dofile(modpath.."/receiver.lua")
|
dofile(modpath.."/receiver.lua")
|
||||||
|
dofile(modpath.."/beacon.lua")
|
||||||
dofile(modpath.."/broadcast.lua")
|
dofile(modpath.."/broadcast.lua")
|
||||||
dofile(modpath.."/hud.lua")
|
dofile(modpath.."/hud.lua")
|
||||||
|
|
||||||
@ -82,8 +87,3 @@ minetest.register_globalstep(function(dtime)
|
|||||||
broadcasttimer = 0
|
broadcasttimer = 0
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- TODO: craft transmitter
|
|
||||||
-- TODO: configure transmitter
|
|
||||||
-- TODO: craft pelengator
|
|
||||||
-- TODO: set pelengator frequency
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.2 KiB |
Loading…
Reference in New Issue
Block a user