Remove bucket and flaregun
This commit is contained in:
parent
9f5168a918
commit
c31a94b9e0
9 changed files with 0 additions and 354 deletions
|
@ -1,26 +0,0 @@
|
||||||
Minetest 0.4 mod: bucket
|
|
||||||
=========================
|
|
||||||
|
|
||||||
License of source code:
|
|
||||||
-----------------------
|
|
||||||
Copyright (C) 2011-2012 Kahrl <kahrl@gmx.net>
|
|
||||||
Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
|
||||||
|
|
||||||
License of media (textures and sounds)
|
|
||||||
--------------------------------------
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
|
||||||
http://creativecommons.org/licenses/by-sa/3.0/
|
|
||||||
|
|
||||||
Authors of media files
|
|
||||||
-----------------------
|
|
||||||
Everything not listed in here:
|
|
||||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
default
|
|
||||||
|
|
|
@ -1,176 +0,0 @@
|
||||||
-- Minetest 0.4 mod: bucket
|
|
||||||
-- See README.txt for licensing and other information.
|
|
||||||
|
|
||||||
minetest.register_alias("bucket", "bucket:bucket_empty")
|
|
||||||
minetest.register_alias("bucket_water", "bucket:bucket_water")
|
|
||||||
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = 'bucket:bucket_empty 1',
|
|
||||||
recipe = {
|
|
||||||
{'default:steel_ingot', '', 'default:steel_ingot'},
|
|
||||||
{'', 'default:steel_ingot', ''},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
bucket = {}
|
|
||||||
bucket.liquids = {}
|
|
||||||
|
|
||||||
local function check_protection(pos, name, text)
|
|
||||||
if minetest.is_protected(pos, name) then
|
|
||||||
minetest.log("action", (name ~= "" and name or "A mod")
|
|
||||||
.. " tried to " .. text
|
|
||||||
.. " at protected position "
|
|
||||||
.. minetest.pos_to_string(pos)
|
|
||||||
.. " with a bucket")
|
|
||||||
minetest.record_protection_violation(pos, name)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Register a new liquid
|
|
||||||
-- source = name of the source node
|
|
||||||
-- flowing = name of the flowing node
|
|
||||||
-- itemname = name of the new bucket item (or nil if liquid is not takeable)
|
|
||||||
-- inventory_image = texture of the new bucket item (ignored if itemname == nil)
|
|
||||||
-- name = text description of the bucket item
|
|
||||||
-- groups = (optional) groups of the bucket item, for example {water_bucket = 1}
|
|
||||||
-- This function can be called from any mod (that depends on bucket).
|
|
||||||
function bucket.register_liquid(source, flowing, itemname, inventory_image, name, groups)
|
|
||||||
bucket.liquids[source] = {
|
|
||||||
source = source,
|
|
||||||
flowing = flowing,
|
|
||||||
itemname = itemname,
|
|
||||||
}
|
|
||||||
bucket.liquids[flowing] = bucket.liquids[source]
|
|
||||||
|
|
||||||
if itemname ~= nil then
|
|
||||||
minetest.register_craftitem(itemname, {
|
|
||||||
description = name,
|
|
||||||
inventory_image = inventory_image,
|
|
||||||
stack_max = 1,
|
|
||||||
liquids_pointable = true,
|
|
||||||
groups = groups,
|
|
||||||
on_place = function(itemstack, user, pointed_thing)
|
|
||||||
-- Must be pointing to node
|
|
||||||
if pointed_thing.type ~= "node" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
|
||||||
local ndef
|
|
||||||
if node then
|
|
||||||
ndef = minetest.registered_nodes[node.name]
|
|
||||||
end
|
|
||||||
-- Call on_rightclick if the pointed node defines it
|
|
||||||
if ndef and ndef.on_rightclick and
|
|
||||||
user and not user:get_player_control().sneak then
|
|
||||||
return ndef.on_rightclick(
|
|
||||||
pointed_thing.under,
|
|
||||||
node, user,
|
|
||||||
itemstack) or itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
local place_liquid = function(pos, node, source, flowing)
|
|
||||||
if check_protection(pos,
|
|
||||||
user and user:get_player_name() or "",
|
|
||||||
"place "..source) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
minetest.add_node(pos, {name=source})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if pointing to a buildable node
|
|
||||||
if ndef and ndef.buildable_to then
|
|
||||||
-- buildable; replace the node
|
|
||||||
place_liquid(pointed_thing.under, node,
|
|
||||||
source, flowing)
|
|
||||||
else
|
|
||||||
-- not buildable to; place the liquid above
|
|
||||||
-- check if the node above can be replaced
|
|
||||||
local node = minetest.get_node_or_nil(pointed_thing.above)
|
|
||||||
if node and minetest.registered_nodes[node.name].buildable_to then
|
|
||||||
place_liquid(pointed_thing.above,
|
|
||||||
node, source,
|
|
||||||
flowing)
|
|
||||||
else
|
|
||||||
-- do not remove the bucket with the liquid
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return {name="bucket:bucket_empty"}
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_craftitem("bucket:bucket_empty", {
|
|
||||||
description = "Empty Bucket",
|
|
||||||
inventory_image = "bucket.png",
|
|
||||||
stack_max = 99,
|
|
||||||
liquids_pointable = true,
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
|
||||||
-- Must be pointing to node
|
|
||||||
if pointed_thing.type ~= "node" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
-- Check if pointing to a liquid source
|
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
|
||||||
local liquiddef = bucket.liquids[node.name]
|
|
||||||
local item_count = user:get_wielded_item():get_count()
|
|
||||||
|
|
||||||
if liquiddef ~= nil
|
|
||||||
and liquiddef.itemname ~= nil
|
|
||||||
and node.name == liquiddef.source then
|
|
||||||
if check_protection(pointed_thing.under,
|
|
||||||
user:get_player_name(),
|
|
||||||
"take ".. node.name) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- default set to return filled bucket
|
|
||||||
local giving_back = liquiddef.itemname
|
|
||||||
|
|
||||||
-- check if holding more than 1 empty bucket
|
|
||||||
if item_count > 1 then
|
|
||||||
|
|
||||||
-- if space in inventory add filled bucked, otherwise drop as item
|
|
||||||
local inv = user:get_inventory()
|
|
||||||
if inv:room_for_item("main", {name=liquiddef.itemname}) then
|
|
||||||
inv:add_item("main", liquiddef.itemname)
|
|
||||||
else
|
|
||||||
local pos = user:getpos()
|
|
||||||
pos.y = math.floor(pos.y + 0.5)
|
|
||||||
core.add_item(pos, liquiddef.itemname)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set to return empty buckets minus 1
|
|
||||||
giving_back = "bucket:bucket_empty "..tostring(item_count-1)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.add_node(pointed_thing.under, {name="air"})
|
|
||||||
|
|
||||||
return ItemStack(giving_back)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
bucket.register_liquid(
|
|
||||||
"default:water_source",
|
|
||||||
"default:water_flowing",
|
|
||||||
"bucket:bucket_water",
|
|
||||||
"bucket_water.png",
|
|
||||||
"Water Bucket",
|
|
||||||
{water_bucket = 1}
|
|
||||||
)
|
|
||||||
|
|
||||||
bucket.register_liquid(
|
|
||||||
"default:river_water_source",
|
|
||||||
"default:river_water_flowing",
|
|
||||||
"bucket:bucket_river_water",
|
|
||||||
"bucket_river_water.png",
|
|
||||||
"River Water Bucket",
|
|
||||||
{water_bucket = 1}
|
|
||||||
)
|
|
Binary file not shown.
Before Width: | Height: | Size: 163 B |
Binary file not shown.
Before Width: | Height: | Size: 167 B |
Binary file not shown.
Before Width: | Height: | Size: 316 B |
Binary file not shown.
Before Width: | Height: | Size: 169 B |
|
@ -1,147 +0,0 @@
|
||||||
minetest.register_craftitem("shooter:flare", {
|
|
||||||
description = "Flare",
|
|
||||||
inventory_image = "shooter_flare_inv.png",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("shooter:flare_light", {
|
|
||||||
drawtype = "glasslike",
|
|
||||||
tiles = {"shooter_flare_light.png"},
|
|
||||||
paramtype = "light",
|
|
||||||
groups = {not_in_creative_inventory=1},
|
|
||||||
drop = "",
|
|
||||||
walkable = false,
|
|
||||||
buildable_to = true,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
light_source = LIGHT_MAX,
|
|
||||||
pointable = false,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = "shooter:flare_light",
|
|
||||||
interval = 5,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node)
|
|
||||||
local time = os.time()
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local init_time = meta:get_int("init_time") or 0
|
|
||||||
if time > init_time + 30 then
|
|
||||||
local id = meta:get_int("particle_id")
|
|
||||||
if id then
|
|
||||||
minetest.delete_particlespawner(id)
|
|
||||||
end
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_entity("shooter:flare_entity", {
|
|
||||||
physical = true,
|
|
||||||
timer = 0,
|
|
||||||
visual = "cube",
|
|
||||||
visual_size = {x=1/8, y=1/8},
|
|
||||||
textures = {
|
|
||||||
"shooter_flare.png",
|
|
||||||
"shooter_flare.png",
|
|
||||||
"shooter_flare.png",
|
|
||||||
"shooter_flare.png",
|
|
||||||
"shooter_flare.png",
|
|
||||||
"shooter_flare.png",
|
|
||||||
},
|
|
||||||
player = nil,
|
|
||||||
collisionbox = {-1/16,-1/16,-1/16, 1/16,1/16,1/16},
|
|
||||||
on_activate = function(self, staticdata)
|
|
||||||
if staticdata == "expired" then
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_step = function(self, dtime)
|
|
||||||
self.timer = self.timer + dtime
|
|
||||||
if self.timer > 0.2 then
|
|
||||||
local pos = self.object:getpos()
|
|
||||||
local below = {x=pos.x, y=pos.y - 1, z=pos.z}
|
|
||||||
local node = minetest.get_node(below)
|
|
||||||
if node.name ~= "air" then
|
|
||||||
self.object:setvelocity({x=0, y=-10, z=0})
|
|
||||||
self.object:setacceleration({x=0, y=0, z=0})
|
|
||||||
if minetest.get_node(pos).name == "air" and
|
|
||||||
node.name ~= "default:water_source" and
|
|
||||||
node.name ~= "default:water_flowing" then
|
|
||||||
minetest.place_node(pos, {name="shooter:flare_light"})
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_int("particle_id", id)
|
|
||||||
meta:set_int("init_time", os.time())
|
|
||||||
pos.y = pos.y - 0.1
|
|
||||||
local id = minetest.add_particlespawner(
|
|
||||||
1000, 30, pos, pos,
|
|
||||||
{x=-1, y=1, z=-1}, {x=1, y=1, z=1},
|
|
||||||
{x=2, y=-2, z=-2}, {x=2, y=-2, z=2},
|
|
||||||
0.1, 0.75, 1, 8, false, "shooter_flare_particle.png"
|
|
||||||
)
|
|
||||||
local sound = minetest.sound_play("shooter_flare_burn", {
|
|
||||||
object = self.player,
|
|
||||||
loop = true,
|
|
||||||
})
|
|
||||||
minetest.after(30, function(sound)
|
|
||||||
minetest.sound_stop(sound)
|
|
||||||
end, sound)
|
|
||||||
end
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
self.timer = 0
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
get_staticdata = function(self)
|
|
||||||
return "expired"
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_tool("shooter:flaregun", {
|
|
||||||
description = "Flare Gun",
|
|
||||||
inventory_image = "shooter_flaregun.png",
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
|
||||||
local inv = user:get_inventory()
|
|
||||||
if not inv:contains_item("main", "shooter:flare") then
|
|
||||||
minetest.sound_play("shooter_click", {object=user})
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
|
||||||
inv:remove_item("main", "shooter:flare 1")
|
|
||||||
itemstack:add_wear(65535/100)
|
|
||||||
end
|
|
||||||
local pos = user:getpos()
|
|
||||||
local dir = user:get_look_dir()
|
|
||||||
local yaw = user:get_look_yaw()
|
|
||||||
if pos and dir and yaw then
|
|
||||||
pos.y = pos.y + 1.5
|
|
||||||
local obj = minetest.add_entity(pos, "shooter:flare_entity")
|
|
||||||
if obj then
|
|
||||||
minetest.sound_play("shooter_flare_fire", {object=obj})
|
|
||||||
obj:setvelocity({x=dir.x * 16, y=dir.y * 16, z=dir.z * 16})
|
|
||||||
obj:setacceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
|
|
||||||
obj:setyaw(yaw + math.pi)
|
|
||||||
local ent = obj:get_luaentity()
|
|
||||||
if ent then
|
|
||||||
ent.player = ent.player or user
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
if SHOOTER_ENABLE_CRAFTING == true then
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "shooter:flare",
|
|
||||||
recipe = {
|
|
||||||
{"tnt:gunpowder", "wool:red"},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "shooter:flaregun",
|
|
||||||
recipe = {
|
|
||||||
{"wool:red", "wool:red", "wool:red"},
|
|
||||||
{"", "", "default:steel_ingot"}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
|
@ -8,9 +8,6 @@ end
|
||||||
if SHOOTER_ENABLE_GUNS == true then
|
if SHOOTER_ENABLE_GUNS == true then
|
||||||
dofile(modpath.."/guns.lua")
|
dofile(modpath.."/guns.lua")
|
||||||
end
|
end
|
||||||
if SHOOTER_ENABLE_FLARES == true then
|
|
||||||
dofile(modpath.."/flaregun.lua")
|
|
||||||
end
|
|
||||||
if SHOOTER_ENABLE_HOOK == true then
|
if SHOOTER_ENABLE_HOOK == true then
|
||||||
dofile(modpath.."/grapple.lua")
|
dofile(modpath.."/grapple.lua")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue