update throwing

master
cornernote 2012-08-18 12:28:39 +09:30
parent 76cc373dfe
commit 36ae40a884
32 changed files with 578 additions and 91 deletions

47
mods/throwing/README Normal file
View File

@ -0,0 +1,47 @@
=== THROWING-MOD for MINETEST-C55 ===
by PilzAdam
Inroduction:
This mod adds bows and arrows to Minetest.
How to install:
Unzip the archive an place it in minetest-base-directory/mods/minetest/
if you have a windows client or a linux run-in-place client. If you have
a linux system-wide instalation place it in ~/.minetest/mods/minetest/.
If you want to install this mod only in one world create the folder
worldmods/ in your worlddirectory.
For further information or help see:
http://wiki.minetest.com/wiki/Installing_Mods
How to use the mod:
Craft a bow with the strings from the farming mod:
string wood
string wood
string wood
Craft arrows with:
stick stick steel
Select the bow and shoot with left mouse click. Every shoot will take 1
arrow from your inventory and wears out the bow (you have around 50
shoots).
License:
This mod was originally published by Jeija.
Sourcecode: WTFPL (see below)
Grahpics: WTFPL (see below)
See also:
http://minetest.net/
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

81
mods/throwing/arrow.lua Normal file
View File

@ -0,0 +1,81 @@
minetest.register_craftitem("throwing:arrow", {
description = "Arrow",
inventory_image = "throwing_arrow.png",
})
minetest.register_node("throwing:arrow_box", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-- Shaft
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
--Spitze
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
--Federn
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = {"throwing_arrow.png", "throwing_arrow.png", "throwing_arrow_back.png", "throwing_arrow_front.png", "throwing_arrow_2.png", "throwing_arrow.png"},
groups = {not_in_creative_inventory=1},
})
local THROWING_ARROW_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.1, y=0.1},
textures = {"throwing:arrow_box"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.env:get_node(pos)
if self.timer>0.2 then
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
obj:set_hp(obj:get_hp()-2)
if obj:get_hp() <= 0 then
obj:remove()
end
self.object:remove()
end
else
obj:set_hp(obj:get_hp()-2)
self.object:remove()
end
end
end
if self.lastpos.x~=nil then
if node.name ~= "air" then
minetest.env:add_item(self.lastpos, 'throwing:arrow')
self.object:remove()
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("throwing:arrow_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow 16',
recipe = {
{'default:stick', 'default:stick', 'default:steel_ingot'},
}
})

View File

@ -0,0 +1,85 @@
minetest.register_craftitem("throwing:arrow_build", {
description = "Build Arrow",
inventory_image = "throwing_arrow_build.png",
})
minetest.register_node("throwing:arrow_build_box", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-- Shaft
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
--Spitze
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
--Federn
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = {"throwing_arrow_build.png", "throwing_arrow_build.png", "throwing_arrow_build_back.png", "throwing_arrow_build_front.png", "throwing_arrow_build_2.png", "throwing_arrow_build.png"},
groups = {not_in_creative_inventory=1},
})
local THROWING_ARROW_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.1, y=0.1},
textures = {"throwing:arrow_build_box"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
node = "",
}
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.env:get_node(pos)
if self.timer>0.2 then
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_build_entity" and obj:get_luaentity().name ~= "__builtin:item" then
if self.node ~= "" then
minetest.env:set_node(self.lastpos, {name=self.node})
end
self.object:remove()
end
else
if self.node ~= "" then
minetest.env:set_node(self.lastpos, {name=self.node})
end
self.object:remove()
end
end
end
if self.lastpos.x~=nil then
if node.name ~= "air" then
if self.node ~= "" then
minetest.env:set_node(self.lastpos, {name=self.node})
end
self.object:remove()
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("throwing:arrow_build_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_build',
recipe = {
{'default:stick', 'default:stick', 'default:shovel_steel'},
}
})

View File

@ -0,0 +1,4 @@
default
bucket
fire
farming

View File

@ -0,0 +1,81 @@
minetest.register_craftitem("throwing:arrow_dig", {
description = "Dig Arrow",
inventory_image = "throwing_arrow_dig.png",
})
minetest.register_node("throwing:arrow_dig_box", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-- Shaft
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
--Spitze
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
--Federn
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = {"throwing_arrow_dig.png", "throwing_arrow_dig.png", "throwing_arrow_dig_back.png", "throwing_arrow_dig_front.png", "throwing_arrow_dig_2.png", "throwing_arrow_dig.png"},
groups = {not_in_creative_inventory=1},
})
local THROWING_ARROW_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.1, y=0.1},
textures = {"throwing:arrow_dig_box"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.env:get_node(pos)
if self.timer>0.2 then
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_dig_entity" and obj:get_luaentity().name ~= "__builtin:item" then
minetest.env:add_item(pos, 'throwing:arrow_dig')
minetest.env:remove_node(pos)
self.object:remove()
end
else
minetest.env:add_item(pos, 'throwing:arrow_dig')
minetest.env:remove_node(pos)
self.object:remove()
end
end
end
if self.lastpos.x~=nil then
if node.name ~= "air" then
minetest.env:add_item(self.lastpos, 'throwing:arrow_dig')
minetest.env:remove_node(pos)
self.object:remove()
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("throwing:arrow_dig_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_dig',
recipe = {
{'default:stick', 'default:stick', 'default:pick_steel'},
}
})

View File

@ -0,0 +1,114 @@
minetest.register_craftitem("throwing:arrow_fire", {
description = "Fire Arrow",
inventory_image = "throwing_arrow_fire.png",
})
minetest.register_node("throwing:arrow_fire_box", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-- Shaft
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
--Spitze
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
--Federn
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = {"throwing_arrow_fire.png", "throwing_arrow_fire.png", "throwing_arrow_fire_back.png", "throwing_arrow_fire_front.png", "throwing_arrow_fire_2.png", "throwing_arrow_fire.png"},
groups = {not_in_creative_inventory=1},
})
local THROWING_ARROW_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.1, y=0.1},
textures = {"throwing:arrow_fire_box"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
}
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.env:get_node(pos)
if self.timer>0.2 then
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_fire_entity" and obj:get_luaentity().name ~= "__builtin:item" then
obj:set_hp(obj:get_hp()-3)
if obj:get_hp() <= 0 then
obj:remove()
end
self.object:remove()
end
else
obj:set_hp(obj:get_hp()-3)
self.object:remove()
end
end
end
if self.lastpos.x~=nil then
if node.name ~= "air" and node.name ~= "throwing:light" then
minetest.env:set_node(self.lastpos, {name="fire:basic_flame"})
self.object:remove()
end
if math.floor(self.lastpos.x+0.5) ~= math.floor(pos.x+0.5) or math.floor(self.lastpos.y+0.5) ~= math.floor(pos.y+0.5) or math.floor(self.lastpos.z+0.5) ~= math.floor(pos.z+0.5) then
if minetest.env:get_node(self.lastpos).name == "throwing:light" then
minetest.env:remove_node(self.lastpos)
end
if minetest.env:get_node(pos).name == "air" then
minetest.env:set_node(pos, {name="throwing:light"})
end
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("throwing:arrow_fire_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_fire 4',
recipe = {
{'default:stick', 'default:stick', 'bucket:bucket_lava'},
},
replacements = {
{"bucket:bucket_lava", "bucket:bucket_empty"}
}
})
minetest.register_node("throwing:light", {
drawtype = "glasslike",
tiles = {"throwing_empty.png"},
light_source = LIGHT_MAX-4,
selection_box = {
type = "fixed",
fixed = {
{0,0,0,0,0,0}
}
},
groups = {not_in_creative_inventory=1}
})
minetest.register_abm({
nodenames = {"throwing:light"},
interval = 10,
chance = 1,
action = function(pos, node)
minetest.env:remove_node(pos)
end
})

View File

@ -1,111 +1,98 @@
-- Bow and arrow mod
-- Topic on the forum: http://c55.me/minetest/forum/viewtopic.php?id=687
ARROW_DAMAGE=1
ARROW_GRAVITY=9
ARROW_VELOCITY=19
throwing_shoot_arrow=function (item, player, pointed_thing)
-- Check if arrows in Inventory and remove one of them
local i=1
if player:get_inventory():contains_item("main", "throwing:arrow") then
player:get_inventory():remove_item("main", "throwing:arrow")
-- Shoot Arrow
local playerpos=player:getpos()
local obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "throwing:arrow_entity")
local dir=player:get_look_dir()
obj:setvelocity({x=dir.x*ARROW_VELOCITY, y=dir.y*ARROW_VELOCITY, z=dir.z*ARROW_VELOCITY})
obj:setacceleration({x=dir.x*-3, y=-ARROW_GRAVITY, z=dir.z*-3})
end
return
end
minetest.register_craftitem("throwing:string", {
image = "throwing_string.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craftitem("throwing:bow", {
image = "throwing_bow.png",
on_place_on_ground = minetest.craftitem_place_item,
on_use = throwing_shoot_arrow,
})
minetest.register_craftitem("throwing:arrow", {
image = "throwing_arrow.png",
on_place_on_ground = minetest.craftitem_place_item,
})
-- The Arrow Entity
THROWING_ARROW_ENTITY={
physical = false,
timer=0,
textures = {"throwing_arrow_back.png"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
arrows = {
{"throwing:arrow", "throwing:arrow_entity"},
{"throwing:arrow_fire", "throwing:arrow_fire_entity"},
{"throwing:arrow_teleport", "throwing:arrow_teleport_entity"},
{"throwing:arrow_dig", "throwing:arrow_dig_entity"},
{"throwing:arrow_build", "throwing:arrow_build_entity"}
}
-- Arrow_entity.on_step()--> called when arrow is moving
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.env:get_node(pos)
-- When arrow is away from player (after 0.2 seconds): Cause damage to mobs and players
if self.timer>0.2 then
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do
obj:set_hp(obj:get_hp()-ARROW_DAMAGE)
if obj:get_entity_name() ~= "throwing:arrow_entity" then
if obj:get_hp()<=0 then
obj:remove()
local throwing_shoot_arrow = function(itemstack, player, pointed_thing)
for _,stack in ipairs(player:get_inventory():get_list("main")) do
for _,arrow in ipairs(arrows) do
if stack:get_name() == arrow[1] then
player:get_inventory():remove_item("main", arrow[1])
local playerpos=player:getpos()
local obj=minetest.env:add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow[2])
local dir=player:get_look_dir()
obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19})
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
obj:setyaw(player:get_look_yaw()+math.pi)
if obj:get_luaentity().player == "" then
obj:get_luaentity().player = player
end
self.object:remove()
obj:get_luaentity().node = player:get_inventory():get_stack("main", 1):get_name()
return true
end
end
end
-- Become item when hitting a node
if self.lastpos.x~=nil then --If there is no lastpos for some reason
if node.name ~= "air" then
minetest.env:add_item(self.lastpos, 'craft "throwing:arrow" 1')
self.object:remove()
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z} -- Set lastpos-->Item will be added at last pos outside the node
return false
end
minetest.register_entity("throwing:arrow_entity", THROWING_ARROW_ENTITY)
--CRAFTS
minetest.register_craft({
output = 'craft "throwing:string" 1',
recipe = {
{"default:junglegrass"},
{"default:junglegrass"},
}
minetest.register_tool("throwing:bow_wood", {
description = "Wood Bow",
inventory_image = "throwing_bow_wood.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
itemstack:add_wear(65535/50)
end
return itemstack
end,
})
minetest.register_craft({
output = 'craft "throwing:bow" 1',
output = 'throwing:bow_wood',
recipe = {
{"throwing:string", "default:wood", ''},
{"throwing:string", '', "default:wood"},
{"throwing:string", "default:wood", ''},
{'farming:string', 'default:wood', ''},
{'farming:string', '', 'default:wood'},
{'farming:string', 'default:wood', ''},
}
})
minetest.register_tool("throwing:bow_stone", {
description = "Stone Bow",
inventory_image = "throwing_bow_stone.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if throwing_shoot_arrow(item, user, pointed_thing) then
itemstack:add_wear(65535/100)
end
return itemstack
end,
})
minetest.register_craft({
output = '"throwing:arrow" 16',
output = 'throwing:bow_stone',
recipe = {
{"default:stick", "default:stick", "default:steel_ingot"},
{'farming:string', 'default:cobble', ''},
{'farming:string', '', 'default:cobble'},
{'farming:string', 'default:cobble', ''},
}
})
print ("[Throwing_mod] Loaded!")
minetest.register_tool("throwing:bow_steel", {
description = "Steel Bow",
inventory_image = "throwing_bow_steel.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if throwing_shoot_arrow(item, user, pointed_thing) then
itemstack:add_wear(65535/200)
end
return itemstack
end,
})
minetest.register_craft({
output = 'throwing:bow_steel',
recipe = {
{'farming:string', 'default:steel_ingot', ''},
{'farming:string', '', 'default:steel_ingot'},
{'farming:string', 'default:steel_ingot', ''},
}
})
dofile(minetest.get_modpath("throwing").."/arrow.lua")
dofile(minetest.get_modpath("throwing").."/fire_arrow.lua")
dofile(minetest.get_modpath("throwing").."/teleport_arrow.lua")
dofile(minetest.get_modpath("throwing").."/dig_arrow.lua")
dofile(minetest.get_modpath("throwing").."/build_arrow.lua")

View File

@ -0,0 +1,88 @@
minetest.register_craftitem("throwing:arrow_teleport", {
description = "Teleport Arrow",
inventory_image = "throwing_arrow_teleport.png",
})
minetest.register_node("throwing:arrow_teleport_box", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-- Shaft
{-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
--Spitze
{-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
{-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
--Federn
{6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
{7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
}
},
tiles = {"throwing_arrow_teleport.png", "throwing_arrow_teleport.png", "throwing_arrow_teleport_back.png", "throwing_arrow_teleport_front.png", "throwing_arrow_teleport_2.png", "throwing_arrow_teleport.png"},
groups = {not_in_creative_inventory=1},
})
local THROWING_ARROW_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.1, y=0.1},
textures = {"throwing:arrow_teleport_box"},
lastpos={},
collisionbox = {0,0,0,0,0,0},
player = "",
}
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
local node = minetest.env:get_node(pos)
if self.timer>0.2 then
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "throwing:arrow_teleport_entity" and obj:get_luaentity().name ~= "__builtin:item" then
if self.player ~= "" then
self.player:setpos(pos)
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
end
self.object:remove()
end
else
if self.player ~= "" then
self.player:setpos(pos)
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
end
self.object:remove()
end
end
end
if self.lastpos.x~=nil then
if node.name ~= "air" then
if self.player ~= "" then
self.player:setpos(self.lastpos)
self.player:get_inventory():add_item("main", ItemStack("throwing:arrow_teleport"))
end
self.object:remove()
end
end
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
end
minetest.register_entity("throwing:arrow_teleport_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = 'throwing:arrow_teleport',
recipe = {
{'default:stick', 'default:stick', 'default:mese'},
}
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 492 B

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B