forked from mtcontrib/throwing
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 stiffness= 0
|
||||||
local bow_idle=true
|
local reload = 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)
|
local throwing_shoot_arrow = function(itemstack, player)
|
||||||
if bow_idle then
|
local playername = player:get_player_name()
|
||||||
bow_idle=false
|
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
|
for _,arrow in ipairs(arrows) do
|
||||||
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
|
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
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
@ -30,11 +42,33 @@ local throwing_shoot_arrow = function(itemstack, player)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function reloading (user)
|
local function reloaded (player, id)
|
||||||
minetest.after(reload, function()
|
local playername = player:get_player_name()
|
||||||
bow_idle=true
|
local privs = minetest.get_player_privs(playername)
|
||||||
--~ minetest.chat_send_player(user:get_player_name(), "Reloaded!")
|
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)
|
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
|
end
|
||||||
|
|
||||||
if not disable_wooden_bow then
|
if not disable_wooden_bow then
|
||||||
@ -45,11 +79,11 @@ if not disable_wooden_bow then
|
|||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
stiffness = 13
|
stiffness = 13
|
||||||
reload = 1.1
|
reload = 1.2
|
||||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||||
reloading(user)
|
reloading(user)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:add_wear(65535/80)
|
itemstack:add_wear(65535/50)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
@ -75,17 +109,17 @@ if not disable_wooden_bow then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if not disable_steel_bow then
|
if not disable_golden_bow then -- To become longbow soon
|
||||||
minetest.register_tool("throwing:bow_steel", {
|
minetest.register_tool("throwing:bow_gold", {
|
||||||
description = "Steel Bow",
|
description = "Golden Bow",
|
||||||
inventory_image = "throwing_bow_steel.png",
|
inventory_image = "throwing_bow_gold.png",
|
||||||
wield_scale = {x=1, y=1, z=0.5},
|
wield_scale = {x=1, y=1, z=0.5},
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
stiffness = 19
|
stiffness = 16
|
||||||
reload = 1.6
|
reload = 1.6
|
||||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||||
reloading()
|
reloading(user)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:add_wear(65535/400)
|
itemstack:add_wear(65535/400)
|
||||||
end
|
end
|
||||||
@ -95,20 +129,20 @@ if not disable_steel_bow then
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'throwing:bow_steel',
|
output = 'throwing:bow_gold',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'farming:string', 'default:steel_ingot', ''},
|
{'farming:string', 'default:gold_ingot', ''},
|
||||||
{'farming:string', '', 'default:steel_ingot'},
|
{'farming:string', '', 'default:gold_ingot'},
|
||||||
{'farming:string', 'default:steel_ingot', ''},
|
{'farming:string', 'default:gold_ingot', ''},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'throwing:bow_steel',
|
output = 'throwing:bow_gold',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'', 'default:steel_ingot', 'farming:string'},
|
{'', 'default:gold_ingot', 'farming:string'},
|
||||||
{'default:steel_ingot', '', 'farming:string'},
|
{'default:gold_ingot', '', 'farming:string'},
|
||||||
{'', 'default:steel_ingot', 'farming:string'},
|
{'', 'default:gold_ingot', 'farming:string'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -121,11 +155,11 @@ if not disable_composite_bow then
|
|||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
stiffness = 18
|
stiffness = 18
|
||||||
reload = 1.3
|
reload = 1.4
|
||||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||||
reloading()
|
reloading(user)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:add_wear(65535/150)
|
itemstack:add_wear(65535/100)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
@ -151,19 +185,19 @@ if not disable_composite_bow then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if not disable_golden_bow then
|
if not disable_steel_bow then
|
||||||
minetest.register_tool("throwing:bow_gold", {
|
minetest.register_tool("throwing:bow_steel", {
|
||||||
description = "Golden Bow",
|
description = "Steel Bow",
|
||||||
inventory_image = "throwing_bow_gold.png",
|
inventory_image = "throwing_bow_steel.png",
|
||||||
wield_scale = {x=1, y=1, z=0.5},
|
wield_scale = {x=1, y=1, z=0.5},
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
stiffness = 16
|
stiffness = 19
|
||||||
reload = 1.6
|
reload = 1.6
|
||||||
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
|
||||||
reloading()
|
reloading(user)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:add_wear(65535/1000)
|
itemstack:add_wear(65535/200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
@ -171,21 +205,20 @@ if not disable_golden_bow then
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'throwing:bow_gold',
|
output = 'throwing:bow_steel',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'farming:string', 'default:gold_ingot', ''},
|
{'farming:string', 'default:steel_ingot', ''},
|
||||||
{'farming:string', '', 'default:gold_ingot'},
|
{'farming:string', '', 'default:steel_ingot'},
|
||||||
{'farming:string', 'default:gold_ingot', ''},
|
{'farming:string', 'default:steel_ingot', ''},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'throwing:bow_gold',
|
output = 'throwing:bow_steel',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'', 'default:gold_ingot', 'farming:string'},
|
{'', 'default:steel_ingot', 'farming:string'},
|
||||||
{'default:gold_ingot', '', 'farming:string'},
|
{'default:steel_ingot', '', 'farming:string'},
|
||||||
{'', 'default:gold_ingot', 'farming:string'},
|
{'', 'default:steel_ingot', 'farming:string'},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
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