mirror of
https://github.com/pandorabox-io/spacecannon.git
synced 2025-01-02 02:57:29 +01:00
Adds pipeworks support for the railguns (#22)
Author: Luke aka SwissalpS <Luke@SwissalpS.ws>
This commit is contained in:
parent
6737757471
commit
798e4ecb78
@ -8,7 +8,7 @@ read_globals = {
|
|||||||
table = {fields = {"copy", "getn"}},
|
table = {fields = {"copy", "getn"}},
|
||||||
|
|
||||||
-- mod deps
|
-- mod deps
|
||||||
"technic", "default", "digilines",
|
"default", "digilines", "pipeworks", "technic",
|
||||||
|
|
||||||
-- Minetest
|
-- Minetest
|
||||||
"minetest",
|
"minetest",
|
||||||
|
55
cannon.lua
55
cannon.lua
@ -1,7 +1,23 @@
|
|||||||
-- vi: noexpandtab
|
-- vi: noexpandtab
|
||||||
|
|
||||||
|
--local has_digilines = minetest.get_modpath("digilines") and true
|
||||||
|
local has_pipeworks = minetest.get_modpath("pipeworks") and true
|
||||||
|
|
||||||
local cable_entry = "^technic_cable_connection_overlay.png"
|
local cable_entry = "^technic_cable_connection_overlay.png"
|
||||||
|
|
||||||
|
local groups_base = {
|
||||||
|
cracky = 3,
|
||||||
|
oddly_breakable_by_hand = 3,
|
||||||
|
technic_machine = 1,
|
||||||
|
technic_hv = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local groups_rail = table.copy(groups_base)
|
||||||
|
if has_pipeworks then
|
||||||
|
groups_rail.tubedevice = 1
|
||||||
|
groups_rail.tubedevice_receiver = 1
|
||||||
|
end
|
||||||
|
|
||||||
local register_spacecannon = function(def)
|
local register_spacecannon = function(def)
|
||||||
|
|
||||||
local entity_texture = "energycube_" .. def.color .. ".png"
|
local entity_texture = "energycube_" .. def.color .. ".png"
|
||||||
@ -112,11 +128,10 @@ local register_spacecannon = function(def)
|
|||||||
textures = def.textures
|
textures = def.textures
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("spacecannon:cannon_" .. def.color, {
|
local def_cannon = {
|
||||||
description = def.name .. " (" .. def.desc .. ")",
|
description = def.name .. " (" .. def.desc .. ")",
|
||||||
tiles = textures,
|
tiles = textures,
|
||||||
|
groups = def.is_th and groups_base or groups_rail,
|
||||||
groups = {cracky=3,oddly_breakable_by_hand=3,technic_machine = 1, technic_hv = 1},
|
|
||||||
drop = "spacecannon:cannon_" .. def.color,
|
drop = "spacecannon:cannon_" .. def.color,
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@ -147,6 +162,9 @@ local register_spacecannon = function(def)
|
|||||||
after_place_node = function(pos, placer)
|
after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("owner", placer:get_player_name() or "")
|
meta:set_string("owner", placer:get_player_name() or "")
|
||||||
|
if has_pipeworks then
|
||||||
|
pipeworks.after_place(pos)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
@ -219,8 +237,35 @@ local register_spacecannon = function(def)
|
|||||||
if meta.inventory and meta.inventory.src and meta.inventory.src[1] then
|
if meta.inventory and meta.inventory.src and meta.inventory.src[1] then
|
||||||
minetest.add_item(pos, ItemStack(meta.inventory.src[1]))
|
minetest.add_item(pos, ItemStack(meta.inventory.src[1]))
|
||||||
end
|
end
|
||||||
|
if has_pipeworks then
|
||||||
|
pipeworks.after_dig(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if has_pipeworks and not def.is_th then
|
||||||
|
def_cannon.tube = {
|
||||||
|
insert_object = function(pos, _, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return inv:add_item("src", stack)
|
||||||
|
end,
|
||||||
|
can_insert = function(pos, _, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
stack = stack:peek_item(1)
|
||||||
|
|
||||||
|
return inv:room_for_item("src", stack)
|
||||||
|
end,
|
||||||
|
input_inventory = "src",
|
||||||
|
connect_sides = {
|
||||||
|
left = 1, back = 1, top = 1,
|
||||||
|
right = 1, front = 1, bottom = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("spacecannon:cannon_" .. def.color, def_cannon)
|
||||||
|
|
||||||
technic.register_machine("HV", "spacecannon:cannon_" .. def.color, technic.receiver)
|
technic.register_machine("HV", "spacecannon:cannon_" .. def.color, technic.receiver)
|
||||||
|
|
||||||
@ -233,8 +278,6 @@ local register_spacecannon = function(def)
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
register_spacecannon({
|
register_spacecannon({
|
||||||
|
1
init.lua
1
init.lua
@ -21,3 +21,4 @@ dofile(MP.."/ammo.lua")
|
|||||||
dofile(MP.."/node_resilience.lua")
|
dofile(MP.."/node_resilience.lua")
|
||||||
|
|
||||||
print("[OK] Spacecannon")
|
print("[OK] Spacecannon")
|
||||||
|
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
|||||||
name = spacecannon
|
name = spacecannon
|
||||||
description = Adds five scifi/space cannons with various properties
|
description = Adds five scifi/space cannons with various properties
|
||||||
depends = default, technic
|
depends = default, technic
|
||||||
optional_depends = mesecons, digilines
|
optional_depends = digilines, mesecons, pipeworks
|
||||||
|
5
util.lua
5
util.lua
@ -15,6 +15,7 @@ spacecannon.update_formspec = function(meta, is_th)
|
|||||||
"list[current_name;src;0.375,0.5;1,1;]" ..
|
"list[current_name;src;0.375,0.5;1,1;]" ..
|
||||||
"list[current_player;main;0.375,4;8,4;]" ..
|
"list[current_player;main;0.375,4;8,4;]" ..
|
||||||
"listring[]" ..
|
"listring[]" ..
|
||||||
|
"item_image[0.375,0.5;1,1;spacecannon:railgun_slug]" ..
|
||||||
"label[1.75,1;Ammunition]"
|
"label[1.75,1;Ammunition]"
|
||||||
|
|
||||||
-- Manual "fire" button
|
-- Manual "fire" button
|
||||||
@ -102,9 +103,9 @@ spacecannon.fire = function(pos, playername, color, speed, is_th, storage_requir
|
|||||||
|
|
||||||
-- use ammo
|
-- use ammo
|
||||||
if not is_th then
|
if not is_th then
|
||||||
local src_stack = (meta:get_inventory()):get_list("src")[1]
|
local src_stack = meta:get_inventory():get_list("src")[1]
|
||||||
src_stack:take_item();
|
src_stack:take_item();
|
||||||
(meta:get_inventory()):set_stack("src", 1, src_stack)
|
meta:get_inventory():set_stack("src", 1, src_stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.sound_play("spacecannon_shoot", {
|
minetest.sound_play("spacecannon_shoot", {
|
||||||
|
Loading…
Reference in New Issue
Block a user