-
-
Save rubenwardy/353c39e6887884dcea81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function throwing_shoot_arrow (itemstack, player, stiffness, is_cross) | |
if not player then | |
return | |
end | |
local arrow = itemstack:get_metadata() | |
itemstack:set_metadata("") | |
player:set_wielded_item(itemstack) | |
local playerpos = player:getpos() | |
print(dump(minetest.luaentities)) | |
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow) | |
if not obj then | |
minetest.chat_send_player(player:get_player_name(), "Error! Failed to create arrow.") | |
return | |
end | |
print(dump(minetest.luaentities)) | |
local dir = player:get_look_dir() | |
obj:setvelocity({x=dir.x*stiffness, y=dir.y*stiffness, z=dir.z*stiffness}) | |
obj:setacceleration({x=dir.x*-3, y=-8.5, z=dir.z*-3}) | |
obj:setyaw(player:get_look_yaw()+math.pi) | |
if is_cross then | |
minetest.sound_play("throwing_crossbow_sound", {pos=playerpos}) | |
else | |
minetest.sound_play("throwing_bow_sound", {pos=playerpos}) | |
end | |
local le = obj:get_luaentity() | |
if le then | |
le.player = player | |
le.inventory = player:get_inventory() | |
le.stack = player:get_inventory():get_stack("main", player:get_wield_index()-1) | |
print("le") | |
else | |
print("no le") | |
end | |
return true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2015-11-19 17:38:27: ACTION[Server]: rubenwardy uses throwing:longbow_loaded, pointing at [nothing] | |
{ | |
[2] = { | |
object = <userdata>, | |
itemstring = "throwing:arrow_stone", | |
age = 222.19999898225, | |
physical_state = false | |
}, | |
[3] = { | |
object = <userdata>, | |
itemstring = "throwing:arrow_obsidian", | |
age = 496.99999548494, | |
physical_state = false | |
}, | |
[5] = { | |
object = <userdata>, | |
itemstring = "throwing:arrow_steel", | |
age = 8.400000333786, | |
physical_state = false | |
}, | |
[7] = { | |
object = <userdata>, | |
itemstring = "throwing:arrow_steel", | |
age = 3.6000002622604, | |
physical_state = false | |
}, | |
[8] = { | |
object = <userdata>, | |
stack = <userdata>, | |
player = <userdata>, | |
inventory = <userdata> | |
} | |
} | |
2015-11-19 17:38:27: ERROR[Server]: LuaEntity name "" not defined | |
{ | |
[2] = { | |
object = <userdata>, | |
itemstring = "throwing:arrow_stone", | |
age = 222.19999898225, | |
physical_state = false | |
}, | |
[3] = { | |
object = <userdata>, | |
itemstring = "throwing:arrow_obsidian", | |
age = 496.99999548494, | |
physical_state = false | |
}, | |
[5] = { | |
object = <userdata>, | |
itemstring = "throwing:arrow_steel", | |
age = 8.400000333786, | |
physical_state = false | |
}, | |
[7] = { | |
object = <userdata>, | |
itemstring = "throwing:arrow_steel", | |
age = 3.6000002622604, | |
physical_state = false | |
}, | |
[8] = { | |
object = <userdata>, | |
stack = <userdata>, | |
player = <userdata>, | |
inventory = <userdata> | |
} | |
} | |
no le |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment