Add files via upload
parent
0fa8d9ea40
commit
56c8539946
|
@ -3,9 +3,9 @@
|
|||
--------------------------
|
||||
------- Ver 1.1 ----------
|
||||
|
||||
colors={"green","blue","red"}
|
||||
local colors={"green","blue","red"}
|
||||
|
||||
hilts={"single","cross","double"}
|
||||
local hilts={"single","cross","double"}
|
||||
|
||||
minetest.register_craftitem("adv_lightsabers:lightsaber_internals", { -- Lightsaber Internals
|
||||
description = "Lightsaber Internals",
|
||||
|
@ -19,7 +19,7 @@ minetest.register_craftitem("adv_lightsabers:kyber_crystal", { -- Uncolored Ligh
|
|||
})
|
||||
|
||||
for _,color in ipairs(colors) do
|
||||
for n,hilt in ipairs(hilts) do
|
||||
for _,hilt in ipairs(hilts) do
|
||||
minetest.register_craftitem("adv_lightsabers:kyber_crystal_"..color, { -- Colored Kyber Crystal
|
||||
description = "Kyber Crystal",
|
||||
inventory_image = "adv_lightsabers_kyber_crystal_"..color..".png"
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
--------------------------
|
||||
------- Ver 1.1 ----------
|
||||
|
||||
force_ability = {}
|
||||
ability_cooldown = {}
|
||||
stunned = {}
|
||||
floating = {}
|
||||
player_physics = {}
|
||||
local force_ability = {}
|
||||
local ability_cooldown = {}
|
||||
local stunned = {}
|
||||
local floating = {}
|
||||
local player_physics = {}
|
||||
|
||||
minetest.register_privilege("force_abilities", {
|
||||
description = "Allows player touse Force Abilities",
|
||||
|
@ -29,7 +29,7 @@ minetest.register_on_leaveplayer(function(player)
|
|||
stunned[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
function cooldown(player,duration)
|
||||
local function cooldown(player,duration)
|
||||
local playername = player:get_player_name()
|
||||
ability_cooldown[playername] = duration
|
||||
minetest.after(duration,function()
|
||||
|
@ -44,7 +44,7 @@ end
|
|||
-- Menu Formspec --
|
||||
-------------------
|
||||
|
||||
function adv_lightsabers.force_menu_form(player)
|
||||
local function force_menu_form()
|
||||
local formspec = {
|
||||
"size[6,3.476]",
|
||||
"real_coordinates[true]",
|
||||
|
@ -61,8 +61,8 @@ function adv_lightsabers.force_menu_form(player)
|
|||
return table.concat(formspec, "")
|
||||
end
|
||||
|
||||
function adv_lightsabers.show_force_menu(player)
|
||||
minetest.show_formspec(player, "adv_lightsabers:force_menu", adv_lightsabers.force_menu_form(player))
|
||||
local function show_force_menu(player)
|
||||
minetest.show_formspec(player, "adv_lightsabers:force_menu", force_menu_form(player))
|
||||
end
|
||||
|
||||
--------------------------------------
|
||||
|
@ -89,14 +89,14 @@ end
|
|||
-- Force Abilities --
|
||||
---------------------
|
||||
|
||||
function force_jump(player) -- Heightened Jump
|
||||
local function force_jump(player) -- Heightened Jump
|
||||
if player:get_player_control().sneak == true and player:get_player_control().jump == true then
|
||||
player:add_player_velocity({x=0,y=8,z=0})
|
||||
cooldown(player,20)
|
||||
end
|
||||
end
|
||||
|
||||
function force_push(player) -- Push entities a far distance
|
||||
local function force_push(player) -- Push entities a far distance
|
||||
local pointedobject = ray_pointed_thing(player)
|
||||
if player:get_player_control().sneak == true and player:get_player_control().LMB == true then
|
||||
if pointedobject and pointedobject:is_player() then
|
||||
|
@ -107,7 +107,7 @@ function force_push(player) -- Push entities a far distance
|
|||
end
|
||||
end
|
||||
|
||||
function force_choke(player) -- Lift a Player off the ground and slowly choke them
|
||||
local function force_choke(player) -- Lift a Player off the ground and slowly choke them
|
||||
local pointedobject = ray_pointed_thing(player)
|
||||
if player:get_player_control().sneak == true and player:get_player_control().LMB == true then
|
||||
if pointedobject and pointedobject:is_player() then
|
||||
|
@ -131,7 +131,7 @@ function force_choke(player) -- Lift a Player off the ground and slowly choke th
|
|||
end
|
||||
end
|
||||
|
||||
function force_dash(player) -- Give yourself a short but quick burst of speed
|
||||
local function force_dash(player) -- Give yourself a short but quick burst of speed
|
||||
if player:get_player_control().sneak == true
|
||||
and player:get_player_control().up == true
|
||||
and player:get_player_control().down == true then
|
||||
|
@ -142,7 +142,7 @@ function force_dash(player) -- Give yourself a short but quick burst of speed
|
|||
end
|
||||
end
|
||||
|
||||
function force_heal(player) -- Heal yourself by 4 hearts
|
||||
local function force_heal(player) -- Heal yourself by 4 hearts
|
||||
if player:get_player_control().sneak == true and player:get_player_control().RMB then
|
||||
local hp = player:get_hp()
|
||||
player:set_hp(hp + 8)
|
||||
|
@ -150,7 +150,7 @@ function force_heal(player) -- Heal yourself by 4 hearts
|
|||
end
|
||||
end
|
||||
|
||||
function force_stun(player) -- Freeze Players in place for 5 seconds
|
||||
local function force_stun(player) -- Freeze Players in place for 5 seconds
|
||||
local pointedobject = ray_pointed_thing(player)
|
||||
if player:get_player_control().sneak == true and player:get_player_control().LMB == true then
|
||||
if pointedobject and pointedobject:is_player() then
|
||||
|
@ -167,7 +167,7 @@ end
|
|||
-- Overrides --
|
||||
---------------
|
||||
|
||||
function adv_lightsabers.stun()
|
||||
local function stun()
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local playername = player:get_player_name()
|
||||
if stunned[playername] == true then
|
||||
|
@ -180,7 +180,7 @@ function adv_lightsabers.stun()
|
|||
end
|
||||
end
|
||||
|
||||
function adv_lightsabers.levitate()
|
||||
local function levitate()
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
local playername = player:get_player_name()
|
||||
if floating[playername] == true then
|
||||
|
@ -199,14 +199,14 @@ end
|
|||
-- Menu --
|
||||
----------
|
||||
|
||||
function adv_lightsabers.force_menu()
|
||||
local function force_menu()
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
if minetest.check_player_privs(player:get_player_name(), {force_abilities = true}) then
|
||||
local playername = player:get_player_name()
|
||||
if player:get_player_control().LMB == true
|
||||
and player:get_player_control().up == true
|
||||
and player:get_player_control().down == true then
|
||||
adv_lightsabers.show_force_menu(player:get_player_name())
|
||||
show_force_menu(player:get_player_name())
|
||||
end
|
||||
if force_ability[playername] == "force_jump" and ability_cooldown[playername] == 0.0 then
|
||||
force_jump(player)
|
||||
|
@ -285,8 +285,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
end
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
adv_lightsabers.force_menu()
|
||||
adv_lightsabers.stun()
|
||||
adv_lightsabers.levitate()
|
||||
minetest.register_globalstep(function()
|
||||
force_menu()
|
||||
stun()
|
||||
levitate()
|
||||
end)
|
4
init.lua
4
init.lua
|
@ -5,10 +5,6 @@
|
|||
|
||||
local modpath = minetest.get_modpath("adv_lightsabers")
|
||||
|
||||
adv_lightsabers = {}
|
||||
force_ability = {}
|
||||
ability_cooldown = {}
|
||||
|
||||
dofile(modpath.."/force_api.lua")
|
||||
dofile(modpath.."/register_lightsabers.lua")
|
||||
dofile(modpath.."/lightsabers.lua")
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
--------------------------
|
||||
------- Ver 1.1 ----------
|
||||
|
||||
local adv_lightsabers = {}
|
||||
|
||||
-- Red Single Blade Lightsaber --
|
||||
|
||||
adv_lightsabers:register_lightsaber("single","red")
|
||||
|
|
2
ores.lua
2
ores.lua
|
@ -3,6 +3,8 @@
|
|||
--------------------------
|
||||
------- Ver 1.1 ----------
|
||||
|
||||
local default = {}
|
||||
|
||||
minetest.register_node("adv_lightsabers:kyber_ore", {
|
||||
description = "Kyber Ore",
|
||||
tiles = {"default_stone.png^adv_lightsabers_kyber_ore.png"},
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
--------------------------
|
||||
------- Ver 1.1 ----------
|
||||
|
||||
player_armor = {}
|
||||
local adv_lightsabers = {}
|
||||
local force_ability = {}
|
||||
local player_armor = {}
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
player_armor[player:get_player_name()] = player:get_armor_groups()
|
||||
|
@ -36,12 +38,12 @@ function adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
|
|||
end
|
||||
end
|
||||
|
||||
colors={"green","blue","red"}
|
||||
local colors={"green","blue","red"}
|
||||
|
||||
hilts={"single","cross","double"}
|
||||
local hilts={"single","cross","double"}
|
||||
|
||||
for _,color in ipairs(colors) do
|
||||
for n,type in ipairs(hilts) do
|
||||
for _,type in ipairs(hilts) do
|
||||
|
||||
local t = 0
|
||||
|
||||
|
@ -62,7 +64,7 @@ end)
|
|||
|
||||
local armor_groups = { fleshy = 10 }
|
||||
|
||||
minetest.register_globalstep(function(dtime) -- Blocking
|
||||
minetest.register_globalstep(function() -- Blocking
|
||||
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_player_control().LMB == true then
|
||||
|
@ -203,7 +205,7 @@ minetest.register_entity("adv_lightsabers:lightsaber_"..type.."_"..color.."_ent"
|
|||
end
|
||||
end
|
||||
|
||||
function adv_lightsabers:saber_throw(itemstack,player,type,color)
|
||||
local function saber_throw(itemstack,player,type,color)
|
||||
local pos = player:get_pos()
|
||||
pos.y = pos.y + 1
|
||||
local dir = player:get_look_dir()
|
||||
|
@ -213,7 +215,7 @@ function adv_lightsabers:saber_throw(itemstack,player,type,color)
|
|||
return itemstack
|
||||
end
|
||||
|
||||
function adv_lightsabers:register_lightsaber(type,color)
|
||||
function adv_lightsabers.register_lightsaber(type,color)
|
||||
|
||||
-- Single Blade Lightsaber
|
||||
|
||||
|
@ -223,7 +225,7 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
description = "Lightsaber",
|
||||
inventory_image = "adv_lightsabers_hilt_single_inv.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack,player,pointed_thing)
|
||||
on_use = function(itemstack,player)
|
||||
local activate = "adv_lightsabers_activate"
|
||||
itemstack:replace("adv_lightsabers:lightsaber_single_"..color.."_on")
|
||||
adv_lightsabers.play_sound(player,activate)
|
||||
|
@ -237,16 +239,16 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
wield_image = "adv_lightsabers_blade_single_"..color..".png^adv_lightsabers_hilt_single.png",
|
||||
wield_scale = {x = 2,y = 2,z = 1},
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack,player,pointed_thing)
|
||||
on_use = function(player,pointed_thing)
|
||||
local swing = "adv_lightsabers_swing"
|
||||
local clash = "adv_lightsabers_clash"
|
||||
adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
|
||||
end,
|
||||
on_secondary_use = function(itemstack,player,pointed_thing)
|
||||
on_secondary_use = function(itemstack,player)
|
||||
if player:get_player_control().sneak == true then
|
||||
local playername = player:get_player_name()
|
||||
if force_ability[playername] == "saber_throw" then
|
||||
adv_lightsabers:saber_throw(itemstack,player,type,color)
|
||||
saber_throw(itemstack,player,type,color)
|
||||
return itemstack
|
||||
end
|
||||
else
|
||||
|
@ -256,7 +258,7 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
return itemstack
|
||||
end
|
||||
end,
|
||||
on_place = function(itemstack,player,pointed_thing)
|
||||
on_place = function(itemstack,player)
|
||||
local deactivate = "adv_lightsabers_deactivate"
|
||||
itemstack:replace("adv_lightsabers:lightsaber_single_"..color.."_off")
|
||||
adv_lightsabers.play_sound(player,deactivate)
|
||||
|
@ -274,7 +276,7 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
description = "Crossguarded Lightsaber",
|
||||
inventory_image = "adv_lightsabers_hilt_cross_inv.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack,player,pointed_thing)
|
||||
on_use = function(itemstack,player)
|
||||
local activate = "adv_lightsabers_activate_cross"
|
||||
itemstack:replace("adv_lightsabers:lightsaber_cross_"..color.."_on")
|
||||
adv_lightsabers.play_sound(player,activate)
|
||||
|
@ -288,16 +290,16 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
wield_image = "adv_lightsabers_blade_cross_"..color..".png^adv_lightsabers_hilt_cross.png",
|
||||
wield_scale = {x = 2,y = 2,z = 1},
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack,player,pointed_thing)
|
||||
on_use = function(player,pointed_thing)
|
||||
local swing = "adv_lightsabers_swing_cross"
|
||||
local clash = "adv_lightsabers_clash_cross"
|
||||
adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
|
||||
end,
|
||||
on_secondary_use = function(itemstack,player,pointed_thing)
|
||||
on_secondary_use = function(itemstack,player)
|
||||
if player:get_player_control().sneak == true then
|
||||
local playername = player:get_player_name()
|
||||
if force_ability[playername] == "saber_throw" then
|
||||
adv_lightsabers:saber_throw(itemstack,player,type,color)
|
||||
saber_throw(itemstack,player,type,color)
|
||||
return itemstack
|
||||
end
|
||||
else
|
||||
|
@ -307,7 +309,7 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
return itemstack
|
||||
end
|
||||
end,
|
||||
on_place = function(itemstack,player,pointed_thing)
|
||||
on_place = function(itemstack,player)
|
||||
local deactivate = "adv_lightsabers_deactivate_cross"
|
||||
itemstack:replace("adv_lightsabers:lightsaber_cross_"..color.."_off")
|
||||
adv_lightsabers.play_sound(player,deactivate)
|
||||
|
@ -325,7 +327,7 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
description = "Double Bladed Lightsaber",
|
||||
inventory_image = "adv_lightsabers_hilt_double_inv.png",
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack,player,pointed_thing)
|
||||
on_use = function(itemstack,player)
|
||||
local activate = "adv_lightsabers_activate"
|
||||
itemstack:replace("adv_lightsabers:lightsaber_double_"..color.."_on")
|
||||
adv_lightsabers.play_sound(player,activate)
|
||||
|
@ -339,17 +341,16 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
wield_image = "adv_lightsabers_hilt_double.png^adv_lightsabers_blade_double_"..color..".png",
|
||||
wield_scale = {x = 4,y = 4,z = 1},
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack,player,pointed_thing)
|
||||
on_use = function(player,pointed_thing)
|
||||
local swing = "adv_lightsabers_swing"
|
||||
local clash = "adv_lightsabers_clash"
|
||||
adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
|
||||
end,
|
||||
on_secondary_use = function(itemstack,player,pointed_thing)
|
||||
on_secondary_use = function(itemstack,player)
|
||||
if player:get_player_control().sneak == true then
|
||||
local playername = player:get_player_name()
|
||||
if force_ability[playername] == "saber_throw" then
|
||||
adv_lightsabers:saber_throw(itemstack,player,type,color)
|
||||
ability_cooldown[playername] = 5
|
||||
saber_throw(itemstack,player,type,color)
|
||||
return itemstack
|
||||
end
|
||||
else
|
||||
|
@ -359,7 +360,7 @@ function adv_lightsabers:register_lightsaber(type,color)
|
|||
return itemstack
|
||||
end
|
||||
end,
|
||||
on_place = function(itemstack,player,pointed_thing)
|
||||
on_place = function(itemstack,player)
|
||||
local deactivate = "adv_lightsabers_deactivate"
|
||||
itemstack:replace("adv_lightsabers:lightsaber_double_"..color.."_off")
|
||||
adv_lightsabers.play_sound(player,deactivate)
|
||||
|
|
Loading…
Reference in New Issue