Update 'mods/adv_lightsabers/register_lightsabers.lua'

This commit is contained in:
thunderdog1138 2020-07-16 15:44:03 +00:00
parent d52076bc88
commit dc1390da76
1 changed files with 446 additions and 398 deletions

View File

@ -1,398 +1,446 @@
-------------------------- --------------------------
-- Advanced Lightsabers -- -- Advanced Lightsabers --
-------------------------- --------------------------
------- Ver 1.1 ---------- ------- Ver 1.1 ----------
local adv_lightsabers = {} local adv_lightsabers = {}
local player_armor = {} local player_armor = {}
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
player_armor[player:get_player_name()] = player:get_armor_groups() player_armor[player:get_player_name()] = player:get_armor_groups()
end) end)
function adv_lightsabers.play_sound(player,soundfile) function adv_lightsabers.play_sound(player,soundfile)
minetest.sound_play(soundfile,{ minetest.sound_play(soundfile,{
object = minetest.get_player_by_name(player:get_player_name()), object = minetest.get_player_by_name(player:get_player_name()),
gain = 1.0, gain = 1.0,
max_hear_distance = 24, max_hear_distance = 24,
loop = false, loop = false,
}) })
end end
function adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash) function adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
adv_lightsabers.play_sound(player,swing) adv_lightsabers.play_sound(player,swing)
if pointed_thing.type == "object" and pointed_thing.ref:is_player() then if pointed_thing.type == "object" and pointed_thing.ref:is_player() then
local pointed_weapon = pointed_thing.ref:get_wielded_item():get_name() local pointed_weapon = pointed_thing.ref:get_wielded_item():get_name()
if minetest.registered_items[pointed_weapon].groups.lightsaber == 1 if minetest.registered_items[pointed_weapon].groups.lightsaber == 1
and pointed_thing.ref:get_player_control().LMB == true then and pointed_thing.ref:get_player_control().LMB == true then
adv_lightsabers.play_sound(player,clash) adv_lightsabers.play_sound(player,clash)
else else
pointed_thing.ref:punch(player,1.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 8}},nil) pointed_thing.ref:punch(player,1.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 8}},nil)
local dir = player:get_look_dir() local dir = player:get_look_dir()
dir.y = dir.y * 1.5 dir.y = dir.y * 1.5
pointed_thing.ref:add_player_velocity(vector.multiply(dir,5)) pointed_thing.ref:add_player_velocity(vector.multiply(dir,5))
end end
elseif pointed_thing.type == "object" and not pointed_thing.ref:is_player() then elseif pointed_thing.type == "object" and not pointed_thing.ref:is_player() then
pointed_thing.ref:punch(player,1.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 8}},nil) pointed_thing.ref:punch(player,1.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 8}},nil)
end end
end end
local colors={"green","blue","red"} local colors={"green","blue","yellow","purple","red","white","black"}
local hilts={"single","cross","double"} local hilts={"single","cross","double"}
for _,color in ipairs(colors) do for _,color in ipairs(colors) do
for _,type in ipairs(hilts) do for _,type in ipairs(hilts) do
local t = 0 local t = 0
minetest.register_globalstep(function(dtime) -- Idle Hum/Crackle minetest.register_globalstep(function(dtime) -- Idle Hum/Crackle
t=t+dtime t=t+dtime
if t>1.3 then if t>1.3 then
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
if player:get_wielded_item():get_name() == "adv_lightsabers:lightsaber_cross_"..color.."_on" then if player:get_wielded_item():get_name() == "adv_lightsabers:lightsaber_cross_"..color.."_on" then
adv_lightsabers.play_sound(player,"adv_lightsabers_idle_cross") adv_lightsabers.play_sound(player,"adv_lightsabers_idle_cross")
elseif player:get_wielded_item():get_name() == "adv_lightsabers:lightsaber_single_"..color.."_on" elseif player:get_wielded_item():get_name() == "adv_lightsabers:lightsaber_single_"..color.."_on"
or player:get_wielded_item():get_name() == "adv_lightsabers:lightsaber_double_"..color.."_on" then or player:get_wielded_item():get_name() == "adv_lightsabers:lightsaber_double_"..color.."_on" then
adv_lightsabers.play_sound(player,"adv_lightsabers_idle") adv_lightsabers.play_sound(player,"adv_lightsabers_idle")
end end
end end
t=0 t=0
end end
end) end)
local armor_groups = { fleshy = 10 } local armor_groups = { fleshy = 10 }
minetest.register_globalstep(function() -- Blocking minetest.register_globalstep(function() -- Blocking
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
if player:get_wielded_item():get_name() == "adv_lightsabers:lightsaber_"..type.."_"..color.."_on" then if player:get_wielded_item():get_name() == "adv_lightsabers:lightsaber_"..type.."_"..color.."_on" then
if player:get_player_control().LMB == true then if player:get_player_control().LMB == true then
player:set_armor_groups(armor_groups) player:set_armor_groups(armor_groups)
else else
player:set_armor_groups({fleshy=player_armor[player:get_player_name()].fleshy}) player:set_armor_groups({fleshy=player_armor[player:get_player_name()].fleshy})
end end
end end
end end
end) end)
local function remove_self(self,pos) -- Remove lightsaber local function remove_self(self,pos) -- Remove lightsaber
self.removing = true self.removing = true
self.object:remove() self.object:remove()
if not self.returned then if not self.returned then
minetest.add_item(pos,"adv_lightsabers:lightsaber_"..type.."_"..color.."_off") minetest.add_item(pos,"adv_lightsabers:lightsaber_"..type.."_"..color.."_off")
end end
end end
local function is_owner_at_pos(self,pos) -- Check if Lightsaber owner is at current position local function is_owner_at_pos(self,pos) -- Check if Lightsaber owner is at current position
for _,player in pairs(minetest.get_objects_inside_radius(pos,1.5)) do for _,player in pairs(minetest.get_objects_inside_radius(pos,1.5)) do
if player:is_player() and player:get_player_name() == self.owner then if player:is_player() and player:get_player_name() == self.owner then
return true, player return true, player
end end
end end
end end
local function return_to_owner(self,pos,vel) -- Return to Owner local function return_to_owner(self,pos,vel) -- Return to Owner
local owner = minetest.get_player_by_name(self.owner) local owner = minetest.get_player_by_name(self.owner)
if not owner or self.owner == nil then remove_self(self,pos) return end if not owner or self.owner == nil then remove_self(self,pos) return end
local owner_pos = owner:get_pos() local owner_pos = owner:get_pos()
owner_pos.y = owner_pos.y + 1 owner_pos.y = owner_pos.y + 1
local dir = vector.direction(pos,owner_pos) local dir = vector.direction(pos,owner_pos)
for _,entity in pairs(minetest.get_objects_inside_radius(pos,2)) do for _,entity in pairs(minetest.get_objects_inside_radius(pos,2)) do
if entity:is_player() and entity:get_player_name() ~= self.owner then -- Punch Player if entity:is_player() and entity:get_player_name() ~= self.owner then -- Punch Player
entity:punch(self.object,2.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 6}},nil) entity:punch(self.object,2.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 6}},nil)
end end
local luaentity = entity:get_luaentity() -- Punch Mob local luaentity = entity:get_luaentity() -- Punch Mob
if luaentity and not self.removing then if luaentity and not self.removing then
if luaentity.name ~= self.object:get_luaentity().name then if luaentity.name ~= self.object:get_luaentity().name then
if entity:get_armor_groups().fleshy then if entity:get_armor_groups().fleshy then
entity:punch(self.object,2.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 6}},nil) entity:punch(self.object,2.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 6}},nil)
end end
end end
end end
end end
self.returning_to_owner = true self.returning_to_owner = true
self.object:set_velocity(vector.multiply(dir,vel or 15)) self.object:set_velocity(vector.multiply(dir,vel or 15))
local get_owner, player = is_owner_at_pos(self,pos) local get_owner, player = is_owner_at_pos(self,pos)
if get_owner then if get_owner then
self.removing = true self.removing = true
if player:get_wielded_item():get_name() == "" then if player:get_wielded_item():get_name() == "" then
player:set_wielded_item("adv_lightsabers:lightsaber_"..type.."_"..color.."_on") player:set_wielded_item("adv_lightsabers:lightsaber_"..type.."_"..color.."_on")
self.returned = true self.returned = true
self.object:remove() self.object:remove()
elseif player:get_wielded_item():get_name() ~= "" then elseif player:get_wielded_item():get_name() ~= "" then
remove_self(self,pos) remove_self(self,pos)
end end
end end
end end
local function punch_entities(self,pos,dist) -- Punch Players and Entities local function punch_entities(self,pos,dist) -- Punch Players and Entities
for _,entity in pairs(minetest.get_objects_inside_radius(pos,2)) do for _,entity in pairs(minetest.get_objects_inside_radius(pos,2)) do
if entity:is_player() and entity:get_player_name() ~= self.owner then -- Punch Player if entity:is_player() and entity:get_player_name() ~= self.owner then -- Punch Player
entity:punch(self.object,2.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 6}},nil) entity:punch(self.object,2.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 6}},nil)
if dist > 10 then if dist > 10 then
return_to_owner(self,pos,15) return_to_owner(self,pos,15)
else else
return_to_owner(self,pos,7.5) return_to_owner(self,pos,7.5)
end end
return return
end end
local luaentity = entity:get_luaentity() local luaentity = entity:get_luaentity()
if luaentity and not self.removing then -- Punch Mob if luaentity and not self.removing then -- Punch Mob
if luaentity.name ~= self.object:get_luaentity().name then if luaentity.name ~= self.object:get_luaentity().name then
if entity:get_armor_groups().fleshy then if entity:get_armor_groups().fleshy then
entity:punch(self.object,2.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 6}},nil) entity:punch(self.object,2.0,{full_punch_interval = 0.1,damage_groups = {fleshy = 6}},nil)
if dist > 10 then if dist > 10 then
return_to_owner(self,pos,15) return_to_owner(self,pos,15)
else else
return_to_owner(self,pos,7.5) return_to_owner(self,pos,7.5)
end end
return return
end end
end end
end end
end end
end end
minetest.register_entity("adv_lightsabers:lightsaber_"..type.."_"..color.."_ent", { -- Register entity minetest.register_entity("adv_lightsabers:lightsaber_"..type.."_"..color.."_ent", { -- Register entity
physical = false, physical = false,
visual = "wielditem", visual = "wielditem",
visual_size = {x=.25,y=.25,z=.25}, visual_size = {x=.25,y=.25,z=.25},
textures = {"adv_lightsabers:lightsaber_"..type.."_"..color.."_on"}, textures = {"adv_lightsabers:lightsaber_"..type.."_"..color.."_on"},
collisionbox = {-0.125,-0.125,-0.125,0.125,0.125,0.125}, collisionbox = {-0.125,-0.125,-0.125,0.125,0.125,0.125},
glow = 10, glow = 10,
owner = "", owner = "",
timer = 0, timer = 0,
on_activate = function(self) on_activate = function(self)
self.object:set_armor_groups({immortal=1}) self.object:set_armor_groups({immortal=1})
local pos = self.object:get_pos() local pos = self.object:get_pos()
for _,player in pairs(minetest.get_objects_inside_radius(pos,1.0)) do for _,player in pairs(minetest.get_objects_inside_radius(pos,1.0)) do
if player:is_player() then if player:is_player() then
local name = player:get_player_name() local name = player:get_player_name()
self.owner = name self.owner = name
end end
end end
local rot = self.object:get_rotation() local rot = self.object:get_rotation()
self.object:set_rotation({x=rot.x,y=rot.y,z=-40}) self.object:set_rotation({x=rot.x,y=rot.y,z=-40})
if self.owner == nil then remove_self(self,pos) return end if self.owner == nil then remove_self(self,pos) return end
end, end,
on_step = function(self) on_step = function(self)
local pos = self.object:get_pos() local pos = self.object:get_pos()
local owner = minetest.get_player_by_name(self.owner) local owner = minetest.get_player_by_name(self.owner)
if not owner or self.owner == nil then remove_self(self,pos) return end if not owner or self.owner == nil then remove_self(self,pos) return end
self.timer = self.timer + 1 self.timer = self.timer + 1
local rot = self.object:get_rotation() local rot = self.object:get_rotation()
local dist = vector.distance(pos,owner:get_pos()) local dist = vector.distance(pos,owner:get_pos())
self.object:set_rotation({x=rot.x,y=rot.y+1,z=rot.z}) self.object:set_rotation({x=rot.x,y=rot.y+1,z=rot.z})
if self.timer >= 35 and self.owner ~= nil then if self.timer >= 35 and self.owner ~= nil then
if dist > 10 then if dist > 10 then
return_to_owner(self,pos,15) return_to_owner(self,pos,15)
else else
return_to_owner(self,pos,7.5) return_to_owner(self,pos,7.5)
end end
end end
punch_entities(self,pos,dist) punch_entities(self,pos,dist)
local node = minetest.get_node_or_nil(pos) local node = minetest.get_node_or_nil(pos)
if node and minetest.registered_nodes[node.name].walkable then if node and minetest.registered_nodes[node.name].walkable then
if dist > 10 then if dist > 10 then
return_to_owner(self,pos,15) return_to_owner(self,pos,15)
else else
return_to_owner(self,pos,7.5) return_to_owner(self,pos,7.5)
end end
end end
end, end,
}) })
end end
end end
local function saber_throw(itemstack,player,type,color) local function saber_throw(itemstack,player,type,color)
local pos = player:get_pos() local pos = player:get_pos()
pos.y = pos.y + 1 pos.y = pos.y + 1
local dir = player:get_look_dir() local dir = player:get_look_dir()
local saber = minetest.add_entity(pos,"adv_lightsabers:lightsaber_"..type.."_"..color.."_ent") local saber = minetest.add_entity(pos,"adv_lightsabers:lightsaber_"..type.."_"..color.."_ent")
itemstack:take_item(1) itemstack:take_item(1)
saber:set_velocity(vector.multiply(dir,20)) saber:set_velocity(vector.multiply(dir,20))
return itemstack return itemstack
end end
function adv_lightsabers.register_lightsaber(type,color) function adv_lightsabers.register_lightsaber(type,color)
-- Single Blade Lightsaber -- Single Blade Lightsaber
if type == "single" then if type == "single" then
minetest.register_craftitem("adv_lightsabers:lightsaber_single_"..color.."_off", { minetest.register_craftitem("adv_lightsabers:lightsaber_single_"..color.."_off", {
description = "Lightsaber", description = "Lightsaber",
inventory_image = "adv_lightsabers_hilt_single_inv.png", inventory_image = "adv_lightsabers_hilt_single_inv.png",
stack_max = 1, stack_max = 1,
on_use = function(itemstack,player) on_use = function(itemstack,player)
local activate = "adv_lightsabers_activate" local activate = "adv_lightsabers_activate"
itemstack:replace("adv_lightsabers:lightsaber_single_"..color.."_on") itemstack:replace("adv_lightsabers:lightsaber_single_"..color.."_on")
adv_lightsabers.play_sound(player,activate) adv_lightsabers.play_sound(player,activate)
return itemstack return itemstack
end, end,
}) })
minetest.register_craftitem("adv_lightsabers:lightsaber_single_"..color.."_on", { minetest.register_craftitem("adv_lightsabers:lightsaber_single_"..color.."_on", {
description = "Lightsaber", description = "Lightsaber",
inventory_image = "adv_lightsabers_hilt_single_inv.png", inventory_image = "adv_lightsabers_hilt_single_inv.png",
wield_image = "adv_lightsabers_blade_single_"..color..".png^adv_lightsabers_hilt_single.png", wield_image = "adv_lightsabers_blade_single_"..color..".png^adv_lightsabers_hilt_single.png",
wield_scale = {x = 2,y = 2,z = 1}, wield_scale = {x = 2,y = 2,z = 1},
stack_max = 1, stack_max = 1,
on_use = function(_,player,pointed_thing) on_use = function(_,player,pointed_thing)
local swing = "adv_lightsabers_swing" local swing = "adv_lightsabers_swing"
local clash = "adv_lightsabers_clash" local clash = "adv_lightsabers_clash"
adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash) adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
end, end,
on_secondary_use = function(itemstack,player) on_secondary_use = function(itemstack,player)
if player:get_player_control().sneak == true then if player:get_player_control().sneak == true then
saber_throw(itemstack,player,type,color) saber_throw(itemstack,player,type,color)
return itemstack return itemstack
else else
local deactivate = "adv_lightsabers_deactivate" local deactivate = "adv_lightsabers_deactivate"
itemstack:replace("adv_lightsabers:lightsaber_single_"..color.."_off") itemstack:replace("adv_lightsabers:lightsaber_single_"..color.."_off")
adv_lightsabers.play_sound(player,deactivate) adv_lightsabers.play_sound(player,deactivate)
return itemstack return itemstack
end end
end, end,
on_place = function(itemstack,player) on_place = function(itemstack,player)
local deactivate = "adv_lightsabers_deactivate" local deactivate = "adv_lightsabers_deactivate"
itemstack:replace("adv_lightsabers:lightsaber_single_"..color.."_off") itemstack:replace("adv_lightsabers:lightsaber_single_"..color.."_off")
adv_lightsabers.play_sound(player,deactivate) adv_lightsabers.play_sound(player,deactivate)
return itemstack return itemstack
end, end,
groups = {not_in_creative_inventory=1,lightsaber=1}, groups = {not_in_creative_inventory=1,lightsaber=1},
}) })
end end
-- Crossguarded Lightsaber -- Crossguarded Lightsaber
if type == "cross" then if type == "cross" then
minetest.register_craftitem("adv_lightsabers:lightsaber_cross_"..color.."_off", { minetest.register_craftitem("adv_lightsabers:lightsaber_cross_"..color.."_off", {
description = "Crossguarded Lightsaber", description = "Crossguarded Lightsaber",
inventory_image = "adv_lightsabers_hilt_cross_inv.png", inventory_image = "adv_lightsabers_hilt_cross_inv.png",
stack_max = 1, stack_max = 1,
on_use = function(itemstack,player) on_use = function(itemstack,player)
local activate = "adv_lightsabers_activate_cross" local activate = "adv_lightsabers_activate_cross"
itemstack:replace("adv_lightsabers:lightsaber_cross_"..color.."_on") itemstack:replace("adv_lightsabers:lightsaber_cross_"..color.."_on")
adv_lightsabers.play_sound(player,activate) adv_lightsabers.play_sound(player,activate)
return itemstack return itemstack
end, end,
}) })
minetest.register_craftitem("adv_lightsabers:lightsaber_cross_"..color.."_on", { minetest.register_craftitem("adv_lightsabers:lightsaber_cross_"..color.."_on", {
description = "Crossguarded Lightsaber", description = "Crossguarded Lightsaber",
inventory_image = "adv_lightsabers_hilt_cross_inv.png", inventory_image = "adv_lightsabers_hilt_cross_inv.png",
wield_image = "adv_lightsabers_blade_cross_"..color..".png^adv_lightsabers_hilt_cross.png", wield_image = "adv_lightsabers_blade_cross_"..color..".png^adv_lightsabers_hilt_cross.png",
wield_scale = {x = 2,y = 2,z = 1}, wield_scale = {x = 2,y = 2,z = 1},
stack_max = 1, stack_max = 1,
on_use = function(_,player,pointed_thing) on_use = function(_,player,pointed_thing)
local swing = "adv_lightsabers_swing_cross" local swing = "adv_lightsabers_swing_cross"
local clash = "adv_lightsabers_clash_cross" local clash = "adv_lightsabers_clash_cross"
adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash) adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
end, end,
on_secondary_use = function(itemstack,player) on_secondary_use = function(itemstack,player)
if player:get_player_control().sneak == true then if player:get_player_control().sneak == true then
saber_throw(itemstack,player,type,color) saber_throw(itemstack,player,type,color)
return itemstack return itemstack
else else
local deactivate = "adv_lightsabers_deactivate_cross" local deactivate = "adv_lightsabers_deactivate_cross"
itemstack:replace("adv_lightsabers:lightsaber_cross_"..color.."_off") itemstack:replace("adv_lightsabers:lightsaber_cross_"..color.."_off")
adv_lightsabers.play_sound(player,deactivate) adv_lightsabers.play_sound(player,deactivate)
return itemstack return itemstack
end end
end, end,
on_place = function(itemstack,player) on_place = function(itemstack,player)
local deactivate = "adv_lightsabers_deactivate_cross" local deactivate = "adv_lightsabers_deactivate_cross"
itemstack:replace("adv_lightsabers:lightsaber_cross_"..color.."_off") itemstack:replace("adv_lightsabers:lightsaber_cross_"..color.."_off")
adv_lightsabers.play_sound(player,deactivate) adv_lightsabers.play_sound(player,deactivate)
return itemstack return itemstack
end, end,
groups = {not_in_creative_inventory=1,lightsaber=1}, groups = {not_in_creative_inventory=1,lightsaber=1},
}) })
end end
-- Double Bladed Lightsaber -- Double Bladed Lightsaber
if type == "double" then if type == "double" then
minetest.register_craftitem("adv_lightsabers:lightsaber_double_"..color.."_off", { minetest.register_craftitem("adv_lightsabers:lightsaber_double_"..color.."_off", {
description = "Double Bladed Lightsaber", description = "Double Bladed Lightsaber",
inventory_image = "adv_lightsabers_hilt_double_inv.png", inventory_image = "adv_lightsabers_hilt_double_inv.png",
stack_max = 1, stack_max = 1,
on_use = function(itemstack,player) on_use = function(itemstack,player)
local activate = "adv_lightsabers_activate" local activate = "adv_lightsabers_activate"
itemstack:replace("adv_lightsabers:lightsaber_double_"..color.."_on") itemstack:replace("adv_lightsabers:lightsaber_double_"..color.."_on")
adv_lightsabers.play_sound(player,activate) adv_lightsabers.play_sound(player,activate)
return itemstack return itemstack
end, end,
}) })
minetest.register_craftitem("adv_lightsabers:lightsaber_double_"..color.."_on", { minetest.register_craftitem("adv_lightsabers:lightsaber_double_"..color.."_on", {
description = "Lightsaber", description = "Lightsaber",
inventory_image = "adv_lightsabers_hilt_double_inv.png", inventory_image = "adv_lightsabers_hilt_double_inv.png",
wield_image = "adv_lightsabers_hilt_double.png^adv_lightsabers_blade_double_"..color..".png", wield_image = "adv_lightsabers_hilt_double.png^adv_lightsabers_blade_double_"..color..".png",
wield_scale = {x = 4,y = 4,z = 1}, wield_scale = {x = 4,y = 4,z = 1},
stack_max = 1, stack_max = 1,
on_use = function(_,player,pointed_thing) on_use = function(_,player,pointed_thing)
local swing = "adv_lightsabers_swing" local swing = "adv_lightsabers_swing"
local clash = "adv_lightsabers_clash" local clash = "adv_lightsabers_clash"
adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash) adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
end, end,
on_secondary_use = function(itemstack,player) on_secondary_use = function(itemstack,player)
if player:get_player_control().sneak == true then if player:get_player_control().sneak == true then
saber_throw(itemstack,player,type,color) saber_throw(itemstack,player,type,color)
return itemstack return itemstack
else else
local deactivate = "adv_lightsabers_deactivate" local deactivate = "adv_lightsabers_deactivate"
itemstack:replace("adv_lightsabers:lightsaber_double_"..color.."_off") itemstack:replace("adv_lightsabers:lightsaber_double_"..color.."_off")
adv_lightsabers.play_sound(player,deactivate) adv_lightsabers.play_sound(player,deactivate)
return itemstack return itemstack
end end
end, end,
on_place = function(itemstack,player) on_place = function(itemstack,player)
local deactivate = "adv_lightsabers_deactivate" local deactivate = "adv_lightsabers_deactivate"
itemstack:replace("adv_lightsabers:lightsaber_double_"..color.."_off") itemstack:replace("adv_lightsabers:lightsaber_double_"..color.."_off")
adv_lightsabers.play_sound(player,deactivate) adv_lightsabers.play_sound(player,deactivate)
return itemstack return itemstack
end, end,
groups = {not_in_creative_inventory=1,lightsaber=1}, groups = {not_in_creative_inventory=1,lightsaber=1},
}) })
end end
end end
-- Red Single Blade Lightsaber -- -- Red Single Blade Lightsaber --
adv_lightsabers.register_lightsaber("single","red") adv_lightsabers.register_lightsaber("single","red")
-- Green Single Blade Lightsaber -- -- Green Single Blade Lightsaber --
adv_lightsabers.register_lightsaber("single","green") adv_lightsabers.register_lightsaber("single","green")
-- Blue Single Blade Lightsaber -- -- Blue Single Blade Lightsaber --
adv_lightsabers.register_lightsaber("single","blue") adv_lightsabers.register_lightsaber("single","blue")
-- Red Crossguarded Lightsaber -- -- Yellow Single Blade Lightsaber --
adv_lightsabers.register_lightsaber("cross","red") adv_lightsabers.register_lightsaber("single","yellow")
-- Green Crossguarded Lightsaber -- -- Purple Single Blade Lightsaber --
adv_lightsabers.register_lightsaber("cross","green") adv_lightsabers.register_lightsaber("single","purple")
-- Blue Crossguarded Lightsaber -- -- White Single Blade Lightsaber --
adv_lightsabers.register_lightsaber("cross","blue") adv_lightsabers.register_lightsaber("single","white")
-- Red Double Bladed Lightsaber -- -- Darksaber --
adv_lightsabers.register_lightsaber("double","red") adv_lightsabers.register_lightsaber("single","black")
-- Green Double Bladed Lightsaber -- minetest.override_item("adv_lightsabers:lightsaber_single_black_off", {
description = "Darksaber"
adv_lightsabers.register_lightsaber("double","green") })
-- Blue Double Bladed Lightsaber -- minetest.override_item("adv_lightsabers:lightsaber_single_black_on", {
description = "Darksaber"
adv_lightsabers.register_lightsaber("double","blue") })
-- Red Crossguarded Lightsaber --
adv_lightsabers.register_lightsaber("cross","red")
-- Green Crossguarded Lightsaber --
adv_lightsabers.register_lightsaber("cross","green")
-- Blue Crossguarded Lightsaber --
adv_lightsabers.register_lightsaber("cross","blue")
-- Yellow Crossguarded Lightsaber --
adv_lightsabers.register_lightsaber("cross","yellow")
-- Purple Crossguarded Lightsaber --
adv_lightsabers.register_lightsaber("cross","purple")
-- White Crossguarded Lightsaber --
adv_lightsabers.register_lightsaber("cross","white")
-- Red Double Bladed Lightsaber --
adv_lightsabers.register_lightsaber("double","red")
-- Green Double Bladed Lightsaber --
adv_lightsabers.register_lightsaber("double","green")
-- Blue Double Bladed Lightsaber --
adv_lightsabers.register_lightsaber("double","blue")
-- Yellow Double Bladed Lightsaber --
adv_lightsabers.register_lightsaber("double","yellow")
-- Purple Double Bladed Lightsaber --
adv_lightsabers.register_lightsaber("double","purple")
-- White Double Bladed Lightsaber --
adv_lightsabers.register_lightsaber("double","white")