Browse Source

1.0rc2, fixed nil value comparison

master
echoes91 5 years ago
parent
commit
96e2d0f799
9 changed files with 96 additions and 54 deletions
  1. +80
    -1
      bows.lua
  2. +2
    -2
      build_arrow.lua
  3. +3
    -3
      diamond_arrow.lua
  4. +2
    -2
      dig_arrow.lua
  5. +2
    -2
      obsidian_arrow.lua
  6. BIN
      sounds/throwing_bow_sound.ogg
  7. +2
    -2
      steel_arrow.lua
  8. +2
    -2
      stone_arrow.lua
  9. +3
    -40
      torch_arrow.lua

+ 80
- 1
bows.lua View File

@@ -36,7 +36,6 @@ local throwing_shoot_arrow = function(itemstack, player)
end
obj:get_luaentity().stack = player:get_inventory():get_stack("main", player:get_wield_index()+2)
obj:get_luaentity().inventory = player:get_inventory()
obj:get_luaentity().breaks = math.random()
return true
end
end
@@ -228,3 +227,83 @@ if not DISABLE_STEEL_BOW then
}
})
end

if not DISABLE_ROYAL_BOW then
minetest.register_tool("throwing:bow_royal", {
description = "Royal Bow",
inventory_image = "throwing_bow_royal.png",
wield_scale = {x=1, y=1.4, z=0.5},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
stiffness = 16
reload = 1.6
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
reloading(user)
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/1000)
end
end
return itemstack
end,
})
minetest.register_craft({
output = 'throwing:bow_royal',
recipe = {
{'farming:string', 'group:wood', 'default:diamond'},
{'farming:string', '', 'default:gold_ingot'},
{'farming:string', 'group:wood', 'default:diamond'},
}
})

minetest.register_craft({
output = 'throwing:bow_royal',
recipe = {
{'default:diamond', 'group:wood', 'farming:string'},
{'default:gold_ingot', '', 'farming:string'},
{'default:diamond', 'group:wood', 'farming:string'},
}
})
end

if not DISABLE_CROSSBOW then
minetest.register_tool("throwing:crossbow", {
description = "Crossbow",
inventory_image = "throwing_crossbow.png",
wield_scale = {x=1, y=1, z=1},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
minetest.sound_play("throwing_crossbow_sound", {pos=playerpos})
stiffness = 27
reload = 8
if throwing_shoot_arrow(itemstack, user, pointed_thing) then
if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/100)
end
end
return itemstack
end,
on_place = function(itemstack, placer, pointed_thing)
reloading(placer)
return itemstack
end,
})
minetest.register_craft({
output = 'throwing:crossbow',
recipe = {
{'group:wood', 'farming:string', ''},
{'default:steel_ingot', 'farming:string', 'group:wood'},
{'group:wood', 'farming:string', ''},
}
})

minetest.register_craft({
output = 'throwing:crossbow',
recipe = {
{'', 'farming:string', 'group:wood'},
{'group:wood', 'farming:string', 'default:steel_ingot'},
{'', 'farming:string', 'group:wood'},
}
})
end

+ 2
- 2
build_arrow.lua View File

@@ -46,7 +46,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
local node = minetest.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)
local objs = minetest.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
@@ -56,7 +56,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
end
minetest.add_item(self.lastpos, {name=self.stack:get_name()})
local toughness = 0.95
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_build')
else
minetest.add_item(self.lastpos, 'default:stick')


+ 3
- 3
diamond_arrow.lua View File

@@ -45,7 +45,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
local node = minetest.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)
local objs = minetest.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_diamond_entity" and obj:get_luaentity().name ~= "__builtin:item" then
@@ -57,7 +57,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
}, nil)
self.object:remove()
local toughness = 0.97
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_diamond')
else
minetest.add_item(self.lastpos, 'default:stick')
@@ -71,7 +71,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if node.name ~= "air" then
self.object:remove()
local toughness = 0.95
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_diamond')
else
minetest.add_item(self.lastpos, 'default:stick')


+ 2
- 2
dig_arrow.lua View File

@@ -56,7 +56,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
}, nil)
self.object:remove()
local toughness = 0.9
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_dig')
else
minetest.add_item(self.lastpos, 'default:stick')
@@ -73,7 +73,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
minetest.dig_node(pos)
end
local toughness = 0.65
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'default:pick_steel')
else
minetest.add_item(self.lastpos, 'default:stick')


+ 2
- 2
obsidian_arrow.lua View File

@@ -57,7 +57,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
}, nil)
self.object:remove()
local toughness = 0.94
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_obsidian')
else
minetest.add_item(self.lastpos, 'default:stick')
@@ -71,7 +71,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if node.name ~= "air" then
self.object:remove()
local toughness = 0.88
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_obsidian')
else
minetest.add_item(self.lastpos, 'default:stick')


BIN
sounds/throwing_bow_sound.ogg View File


+ 2
- 2
steel_arrow.lua View File

@@ -57,7 +57,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
}, nil)
self.object:remove()
local toughness = 0.95
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_steel')
else
minetest.add_item(self.lastpos, 'default:stick')
@@ -71,7 +71,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if node.name ~= "air" then
self.object:remove()
local toughness = 0.9
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_steel')
else
minetest.add_item(self.lastpos, 'default:stick')


+ 2
- 2
stone_arrow.lua View File

@@ -57,7 +57,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
}, nil)
self.object:remove()
local toughness = 0.94
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_stone')
else
minetest.add_item(self.lastpos, 'default:stick')
@@ -71,7 +71,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
if node.name ~= "air" then
self.object:remove()
local toughness = 0.88
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_stone')
else
minetest.add_item(self.lastpos, 'default:stick')


+ 3
- 40
torch_arrow.lua View File

@@ -57,8 +57,8 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
}, nil)
self.object:remove()
local toughness = 0.9
if self.breaks < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_diamond')
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_torch')
else
minetest.add_item(self.lastpos, 'default:stick')
end
@@ -74,46 +74,9 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
local dir=vector.direction(self.lastpos, pos)
local wall=minetest.dir_to_wallmounted(dir)
minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
--~ if wall == 0 then Check doesn't help :(
--~ local check_pos={self.lastpos.x, self.lastpos.y+0.5, self.lastpos.z}
--~ if minetest.get_node(check_pos).name ~= "air" then
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
--~ self.object:remove()
--~ end
--~ elseif wall == 1 then
--~ local check_pos={self.lastpos.x, self.lastpos.y-0.5, self.lastpos.z}
--~ if minetest.get_node(check_pos).name ~= "air" then
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
--~ self.object:remove()
--~ end
--~ elseif wall == 2 then
--~ local check_pos={self.lastpos.x+0.5, self.lastpos.y, self.lastpos.z}
--~ if minetest.get_node(check_pos).name ~= "air" then
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
--~ self.object:remove()
--~ end
--~ elseif wall == 3 then
--~ local check_pos={self.lastpos.x-0.5, self.lastpos.y, self.lastpos.z}
--~ if minetest.get_node(check_pos).name ~= "air" then
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
--~ self.object:remove()
--~ end
--~ elseif wall == 4 then
--~ local check_pos={self.lastpos.x, self.lastpos.y, self.lastpos.z+0.5}
--~ if minetest.get_node(check_pos).name ~= "air" then
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
--~ self.object:remove()
--~ end
--~ elseif wall == 5 then
--~ local check_pos={self.lastpos.x, self.lastpos.y, self.lastpos.z-0.5}
--~ if minetest.get_node(check_pos).name ~= "air" then
--~ minetest.add_node(self.lastpos, {name="default:torch", param2 = wall})
--~ self.object:remove()
--~ end
--~ end
else
local toughness = 0.9
if self.breaks < toughness then
if math.random() < toughness then
minetest.add_item(self.lastpos, 'throwing:arrow_torch')
else
minetest.add_item(self.lastpos, 'default:stick')


Loading…
Cancel
Save