54 lines
1.7 KiB
Lua
54 lines
1.7 KiB
Lua
cores={"green","blue","red"}
|
|
function on_off(cor)
|
|
for _,player in ipairs(minetest.get_connected_players()) do
|
|
if player:get_player_control().RMB == true then
|
|
if player:get_wielded_item():get_name() == "starwars:lightsaberon"..cor then
|
|
player:set_wielded_item("starwars:lightsaberoff"..cor)
|
|
elseif player:get_wielded_item():get_name() == "starwars:lightsaberoff"..cor then
|
|
player:set_wielded_item("starwars:lightsaberon"..cor)
|
|
minetest.sound_play("on0", {object = minetest.get_player_by_name(player:get_player_name()), gain = 1.0, max_hear_distance = 32, loop = false })
|
|
end
|
|
end
|
|
end
|
|
end
|
|
for n,cor in ipairs(cores) do
|
|
minetest.register_tool("starwars:lightsaberoff"..cor, {
|
|
description = "Light Saber "..cor,
|
|
inventory_image = "lightsaberon"..cor..".png",
|
|
wield_image = "lightsaberoff.png",
|
|
tool_capabilities = {
|
|
full_punch_interval = 1.0,
|
|
max_drop_level=0,
|
|
},
|
|
})
|
|
minetest.register_tool("starwars:lightsaberon"..cor, {
|
|
description = "Light Saber "..cor,
|
|
inventory_image = "lightsaberon"..cor..".png",
|
|
wield_image = "lightsaberon"..cor..".png",
|
|
groups = {
|
|
not_in_creative_inventory=1,
|
|
},
|
|
tool_capabilities = {
|
|
full_punch_interval = 1.0,
|
|
max_drop_level=10,
|
|
groupcaps={
|
|
cracky={times={[1]=1.0, [2]=0.5, [3]=0.5}, uses=30, maxlevel=10},
|
|
crumbly={times={[1]=1.0, [2]=0.5, [3]=0.5}, uses=30, maxlevel=10},
|
|
snappy={times={[1]=1.0, [2]=0.5, [3]=0.5}, uses=30, maxlevel=10},
|
|
choppy={times={[1]=1.0, [2]=0.5, [3]=0.5}, uses=30, maxlevel=10},
|
|
},
|
|
damage_groups = {fleshy=8}
|
|
},
|
|
})
|
|
end
|
|
local t=0
|
|
minetest.register_globalstep(function(dtime)
|
|
t=t+dtime
|
|
if t>=0.25 then
|
|
on_off("green")
|
|
on_off("blue")
|
|
on_off("red")
|
|
t=0
|
|
end
|
|
end)
|