Add files via upload

master
ElCeejo 2020-04-16 22:31:09 -07:00 committed by GitHub
parent 0fa8d9ea40
commit 56c8539946
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 53 deletions

View File

@ -3,9 +3,9 @@
-------------------------- --------------------------
------- Ver 1.1 ---------- ------- 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 minetest.register_craftitem("adv_lightsabers:lightsaber_internals", { -- Lightsaber Internals
description = "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 _,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 minetest.register_craftitem("adv_lightsabers:kyber_crystal_"..color, { -- Colored Kyber Crystal
description = "Kyber Crystal", description = "Kyber Crystal",
inventory_image = "adv_lightsabers_kyber_crystal_"..color..".png" inventory_image = "adv_lightsabers_kyber_crystal_"..color..".png"

View File

@ -3,11 +3,11 @@
-------------------------- --------------------------
------- Ver 1.1 ---------- ------- Ver 1.1 ----------
force_ability = {} local force_ability = {}
ability_cooldown = {} local ability_cooldown = {}
stunned = {} local stunned = {}
floating = {} local floating = {}
player_physics = {} local player_physics = {}
minetest.register_privilege("force_abilities", { minetest.register_privilege("force_abilities", {
description = "Allows player touse Force Abilities", description = "Allows player touse Force Abilities",
@ -29,7 +29,7 @@ minetest.register_on_leaveplayer(function(player)
stunned[player:get_player_name()] = nil stunned[player:get_player_name()] = nil
end) end)
function cooldown(player,duration) local function cooldown(player,duration)
local playername = player:get_player_name() local playername = player:get_player_name()
ability_cooldown[playername] = duration ability_cooldown[playername] = duration
minetest.after(duration,function() minetest.after(duration,function()
@ -44,7 +44,7 @@ end
-- Menu Formspec -- -- Menu Formspec --
------------------- -------------------
function adv_lightsabers.force_menu_form(player) local function force_menu_form()
local formspec = { local formspec = {
"size[6,3.476]", "size[6,3.476]",
"real_coordinates[true]", "real_coordinates[true]",
@ -61,8 +61,8 @@ function adv_lightsabers.force_menu_form(player)
return table.concat(formspec, "") return table.concat(formspec, "")
end end
function adv_lightsabers.show_force_menu(player) local function show_force_menu(player)
minetest.show_formspec(player, "adv_lightsabers:force_menu", adv_lightsabers.force_menu_form(player)) minetest.show_formspec(player, "adv_lightsabers:force_menu", force_menu_form(player))
end end
-------------------------------------- --------------------------------------
@ -89,14 +89,14 @@ end
-- Force Abilities -- -- 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 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}) player:add_player_velocity({x=0,y=8,z=0})
cooldown(player,20) cooldown(player,20)
end end
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) local pointedobject = ray_pointed_thing(player)
if player:get_player_control().sneak == true and player:get_player_control().LMB == true then if player:get_player_control().sneak == true and player:get_player_control().LMB == true then
if pointedobject and pointedobject:is_player() then if pointedobject and pointedobject:is_player() then
@ -107,7 +107,7 @@ function force_push(player) -- Push entities a far distance
end end
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) local pointedobject = ray_pointed_thing(player)
if player:get_player_control().sneak == true and player:get_player_control().LMB == true then if player:get_player_control().sneak == true and player:get_player_control().LMB == true then
if pointedobject and pointedobject:is_player() 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
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 if player:get_player_control().sneak == true
and player:get_player_control().up == true and player:get_player_control().up == true
and player:get_player_control().down == true then 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
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 if player:get_player_control().sneak == true and player:get_player_control().RMB then
local hp = player:get_hp() local hp = player:get_hp()
player:set_hp(hp + 8) player:set_hp(hp + 8)
@ -150,7 +150,7 @@ function force_heal(player) -- Heal yourself by 4 hearts
end end
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) local pointedobject = ray_pointed_thing(player)
if player:get_player_control().sneak == true and player:get_player_control().LMB == true then if player:get_player_control().sneak == true and player:get_player_control().LMB == true then
if pointedobject and pointedobject:is_player() then if pointedobject and pointedobject:is_player() then
@ -167,7 +167,7 @@ end
-- Overrides -- -- Overrides --
--------------- ---------------
function adv_lightsabers.stun() local function stun()
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
local playername = player:get_player_name() local playername = player:get_player_name()
if stunned[playername] == true then if stunned[playername] == true then
@ -180,7 +180,7 @@ function adv_lightsabers.stun()
end end
end end
function adv_lightsabers.levitate() local function levitate()
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
local playername = player:get_player_name() local playername = player:get_player_name()
if floating[playername] == true then if floating[playername] == true then
@ -199,14 +199,14 @@ end
-- Menu -- -- Menu --
---------- ----------
function adv_lightsabers.force_menu() local function force_menu()
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
if minetest.check_player_privs(player:get_player_name(), {force_abilities = true}) then if minetest.check_player_privs(player:get_player_name(), {force_abilities = true}) then
local playername = player:get_player_name() local playername = player:get_player_name()
if player:get_player_control().LMB == true if player:get_player_control().LMB == true
and player:get_player_control().up == true and player:get_player_control().up == true
and player:get_player_control().down == true then 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 end
if force_ability[playername] == "force_jump" and ability_cooldown[playername] == 0.0 then if force_ability[playername] == "force_jump" and ability_cooldown[playername] == 0.0 then
force_jump(player) force_jump(player)
@ -285,8 +285,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
end) end)
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function()
adv_lightsabers.force_menu() force_menu()
adv_lightsabers.stun() stun()
adv_lightsabers.levitate() levitate()
end) end)

View File

@ -5,10 +5,6 @@
local modpath = minetest.get_modpath("adv_lightsabers") local modpath = minetest.get_modpath("adv_lightsabers")
adv_lightsabers = {}
force_ability = {}
ability_cooldown = {}
dofile(modpath.."/force_api.lua") dofile(modpath.."/force_api.lua")
dofile(modpath.."/register_lightsabers.lua") dofile(modpath.."/register_lightsabers.lua")
dofile(modpath.."/lightsabers.lua") dofile(modpath.."/lightsabers.lua")

View File

@ -3,6 +3,8 @@
-------------------------- --------------------------
------- Ver 1.1 ---------- ------- Ver 1.1 ----------
local adv_lightsabers = {}
-- Red Single Blade Lightsaber -- -- Red Single Blade Lightsaber --
adv_lightsabers:register_lightsaber("single","red") adv_lightsabers:register_lightsaber("single","red")

View File

@ -3,6 +3,8 @@
-------------------------- --------------------------
------- Ver 1.1 ---------- ------- Ver 1.1 ----------
local default = {}
minetest.register_node("adv_lightsabers:kyber_ore", { minetest.register_node("adv_lightsabers:kyber_ore", {
description = "Kyber Ore", description = "Kyber Ore",
tiles = {"default_stone.png^adv_lightsabers_kyber_ore.png"}, tiles = {"default_stone.png^adv_lightsabers_kyber_ore.png"},

View File

@ -3,7 +3,9 @@
-------------------------- --------------------------
------- Ver 1.1 ---------- ------- Ver 1.1 ----------
player_armor = {} local adv_lightsabers = {}
local force_ability = {}
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()
@ -36,12 +38,12 @@ function adv_lightsabers.lightsaber_attack(player,pointed_thing,swing,clash)
end end
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 _,color in ipairs(colors) do
for n,type in ipairs(hilts) do for _,type in ipairs(hilts) do
local t = 0 local t = 0
@ -62,7 +64,7 @@ end)
local armor_groups = { fleshy = 10 } 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 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
@ -203,7 +205,7 @@ minetest.register_entity("adv_lightsabers:lightsaber_"..type.."_"..color.."_ent"
end end
end end
function adv_lightsabers: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()
@ -213,7 +215,7 @@ function adv_lightsabers:saber_throw(itemstack,player,type,color)
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
@ -223,7 +225,7 @@ function adv_lightsabers:register_lightsaber(type,color)
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,pointed_thing) 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)
@ -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_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(itemstack,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,pointed_thing) on_secondary_use = function(itemstack,player)
if player:get_player_control().sneak == true then if player:get_player_control().sneak == true then
local playername = player:get_player_name() local playername = player:get_player_name()
if force_ability[playername] == "saber_throw" then if force_ability[playername] == "saber_throw" then
adv_lightsabers:saber_throw(itemstack,player,type,color) saber_throw(itemstack,player,type,color)
return itemstack return itemstack
end end
else else
@ -256,7 +258,7 @@ function adv_lightsabers:register_lightsaber(type,color)
return itemstack return itemstack
end end
end, end,
on_place = function(itemstack,player,pointed_thing) 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)
@ -274,7 +276,7 @@ function adv_lightsabers:register_lightsaber(type,color)
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,pointed_thing) 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)
@ -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_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(itemstack,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,pointed_thing) on_secondary_use = function(itemstack,player)
if player:get_player_control().sneak == true then if player:get_player_control().sneak == true then
local playername = player:get_player_name() local playername = player:get_player_name()
if force_ability[playername] == "saber_throw" then if force_ability[playername] == "saber_throw" then
adv_lightsabers:saber_throw(itemstack,player,type,color) saber_throw(itemstack,player,type,color)
return itemstack return itemstack
end end
else else
@ -307,7 +309,7 @@ function adv_lightsabers:register_lightsaber(type,color)
return itemstack return itemstack
end end
end, end,
on_place = function(itemstack,player,pointed_thing) 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)
@ -325,7 +327,7 @@ function adv_lightsabers:register_lightsaber(type,color)
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,pointed_thing) 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)
@ -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_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(itemstack,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,pointed_thing) on_secondary_use = function(itemstack,player)
if player:get_player_control().sneak == true then if player:get_player_control().sneak == true then
local playername = player:get_player_name() local playername = player:get_player_name()
if force_ability[playername] == "saber_throw" then if force_ability[playername] == "saber_throw" then
adv_lightsabers:saber_throw(itemstack,player,type,color) saber_throw(itemstack,player,type,color)
ability_cooldown[playername] = 5
return itemstack return itemstack
end end
else else
@ -359,7 +360,7 @@ function adv_lightsabers:register_lightsaber(type,color)
return itemstack return itemstack
end end
end, end,
on_place = function(itemstack,player,pointed_thing) 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)