mirror of
https://gitlab.com/echoes91/throwing.git
synced 2025-01-09 07:20:17 +01:00
0.9.7 Reload!
This commit is contained in:
parent
3fc8db2ac0
commit
31e4dea2b6
125
bows.lua
125
bows.lua
@ -1,10 +1,22 @@
|
||||
local stiffness=0
|
||||
local bow_idle=true
|
||||
local reload=0
|
||||
local stiffness= 0
|
||||
local reload = 0
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local playername = player:get_player_name()
|
||||
local privs = minetest.get_player_privs(playername)
|
||||
privs.throw = true
|
||||
minetest.set_player_privs(playername, privs)
|
||||
end)
|
||||
|
||||
local throwing_shoot_arrow = function(itemstack, player)
|
||||
if bow_idle then
|
||||
bow_idle=false
|
||||
local playername = player:get_player_name()
|
||||
if minetest.get_player_privs(playername).throw then
|
||||
local privs = minetest.get_player_privs(playername)
|
||||
privs.throw = nil
|
||||
minetest.chat_send_player(playername, tostring(privs.throw))
|
||||
minetest.set_player_privs(playername, privs)
|
||||
local privs = minetest.get_player_privs(playername)
|
||||
minetest.chat_send_player(playername, tostring(privs.throw))
|
||||
for _,arrow in ipairs(arrows) do
|
||||
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
@ -30,11 +42,33 @@ local throwing_shoot_arrow = function(itemstack, player)
|
||||
return false
|
||||
end
|
||||
|
||||
local function reloading (user)
|
||||
minetest.after(reload, function()
|
||||
bow_idle=true
|
||||
--~ minetest.chat_send_player(user:get_player_name(), "Reloaded!")
|
||||
local function reloaded (player, id)
|
||||
local playername = player:get_player_name()
|
||||
local privs = minetest.get_player_privs(playername)
|
||||
privs.throw = true
|
||||
minetest.set_player_privs(playername, privs)
|
||||
player:hud_change(id, "number", 0x00FF00)
|
||||
player:hud_change(id, "text", "Ready!")
|
||||
player:hud_change(id, "position", {x=0.6,y=0.515})
|
||||
minetest.after(0.5, function(player, id)
|
||||
player:hud_remove(id)
|
||||
end, player, id)
|
||||
end
|
||||
|
||||
local function reloading (player)
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local playername = player:get_player_name()
|
||||
local privs = minetest.get_player_privs(playername)
|
||||
privs.throw = true
|
||||
minetest.set_player_privs(playername, privs)
|
||||
end)
|
||||
local throwing_hud = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x=0.6,y=0.5},
|
||||
text = "Reloading...",
|
||||
number = 0xFF0000,
|
||||
})
|
||||
minetest.after(reload, reloaded, player, throwing_hud)
|
||||
end
|
||||
|
||||
if not disable_wooden_bow then
|
||||
@ -45,11 +79,11 @@ if not disable_wooden_bow then
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
stiffness = 13
|
||||
reload = 1.1
|
||||
reload = 1.2
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
reloading(user)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/80)
|
||||
itemstack:add_wear(65535/50)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
@ -75,17 +109,17 @@ if not disable_wooden_bow then
|
||||
})
|
||||
end
|
||||
|
||||
if not disable_steel_bow then
|
||||
minetest.register_tool("throwing:bow_steel", {
|
||||
description = "Steel Bow",
|
||||
inventory_image = "throwing_bow_steel.png",
|
||||
if not disable_golden_bow then -- To become longbow soon
|
||||
minetest.register_tool("throwing:bow_gold", {
|
||||
description = "Golden Bow",
|
||||
inventory_image = "throwing_bow_gold.png",
|
||||
wield_scale = {x=1, y=1, z=0.5},
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
stiffness = 19
|
||||
stiffness = 16
|
||||
reload = 1.6
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
reloading()
|
||||
reloading(user)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/400)
|
||||
end
|
||||
@ -95,20 +129,20 @@ if not disable_steel_bow then
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:bow_steel',
|
||||
output = 'throwing:bow_gold',
|
||||
recipe = {
|
||||
{'farming:string', 'default:steel_ingot', ''},
|
||||
{'farming:string', '', 'default:steel_ingot'},
|
||||
{'farming:string', 'default:steel_ingot', ''},
|
||||
{'farming:string', 'default:gold_ingot', ''},
|
||||
{'farming:string', '', 'default:gold_ingot'},
|
||||
{'farming:string', 'default:gold_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:bow_steel',
|
||||
output = 'throwing:bow_gold',
|
||||
recipe = {
|
||||
{'', 'default:steel_ingot', 'farming:string'},
|
||||
{'default:steel_ingot', '', 'farming:string'},
|
||||
{'', 'default:steel_ingot', 'farming:string'},
|
||||
{'', 'default:gold_ingot', 'farming:string'},
|
||||
{'default:gold_ingot', '', 'farming:string'},
|
||||
{'', 'default:gold_ingot', 'farming:string'},
|
||||
}
|
||||
})
|
||||
end
|
||||
@ -121,11 +155,11 @@ if not disable_composite_bow then
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
stiffness = 18
|
||||
reload = 1.3
|
||||
reload = 1.4
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
reloading()
|
||||
reloading(user)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/150)
|
||||
itemstack:add_wear(65535/100)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
@ -151,19 +185,19 @@ if not disable_composite_bow then
|
||||
})
|
||||
end
|
||||
|
||||
if not disable_golden_bow then
|
||||
minetest.register_tool("throwing:bow_gold", {
|
||||
description = "Golden Bow",
|
||||
inventory_image = "throwing_bow_gold.png",
|
||||
if not disable_steel_bow then
|
||||
minetest.register_tool("throwing:bow_steel", {
|
||||
description = "Steel Bow",
|
||||
inventory_image = "throwing_bow_steel.png",
|
||||
wield_scale = {x=1, y=1, z=0.5},
|
||||
stack_max = 1,
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
stiffness = 16
|
||||
stiffness = 19
|
||||
reload = 1.6
|
||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||
reloading()
|
||||
reloading(user)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535/1000)
|
||||
itemstack:add_wear(65535/200)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
@ -171,21 +205,20 @@ if not disable_golden_bow then
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:bow_gold',
|
||||
output = 'throwing:bow_steel',
|
||||
recipe = {
|
||||
{'farming:string', 'default:gold_ingot', ''},
|
||||
{'farming:string', '', 'default:gold_ingot'},
|
||||
{'farming:string', 'default:gold_ingot', ''},
|
||||
{'farming:string', 'default:steel_ingot', ''},
|
||||
{'farming:string', '', 'default:steel_ingot'},
|
||||
{'farming:string', 'default:steel_ingot', ''},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:bow_gold',
|
||||
output = 'throwing:bow_steel',
|
||||
recipe = {
|
||||
{'', 'default:gold_ingot', 'farming:string'},
|
||||
{'default:gold_ingot', '', 'farming:string'},
|
||||
{'', 'default:gold_ingot', 'farming:string'},
|
||||
{'', 'default:steel_ingot', 'farming:string'},
|
||||
{'default:steel_ingot', '', 'farming:string'},
|
||||
{'', 'default:steel_ingot', 'farming:string'},
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 594 B After Width: | Height: | Size: 595 B |
Binary file not shown.
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 510 B |
Binary file not shown.
Before Width: | Height: | Size: 576 B After Width: | Height: | Size: 577 B |
Loading…
Reference in New Issue
Block a user