Add multiple stasis chamber tiers
• Make the 'tiles' property on stasis chambers less long. • Allow stasis chambers to set a custom replace_with node. • Add two more stasis chamber tiers. • Add crafting recipes.
This commit is contained in:
parent
bd737f27b7
commit
bf90d745a2
20
README.md
20
README.md
|
@ -44,6 +44,26 @@ To transport a stasis chamber containing a player, you can use node breakers
|
|||
While in transit, players are shown a formspec with an option to leave, that
|
||||
teleports the player back to the original location of the stasis chamber.
|
||||
|
||||
## Crafting
|
||||
|
||||
### Stasis chamber Mk1
|
||||
|
||||
Single-use, requires one glass bottle per use.
|
||||
|
||||
![Crafting recipe](chamber mk1.png)
|
||||
|
||||
### Stasis chamber Mk2
|
||||
|
||||
Multiple uses, requires one mese crystal fragment per use.
|
||||
|
||||
![Crafting recipe](chamber mk2.png)
|
||||
|
||||
### Stasis chamber Mk3
|
||||
|
||||
Multiple uses, no additional items required.
|
||||
|
||||
![Crafting recipe](chamber mk3.png)
|
||||
|
||||
## TODO
|
||||
|
||||
- Crafting recipes and a wooden stasis chamber that requires some valuable item to use.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
71
chamber.lua
71
chamber.lua
|
@ -20,18 +20,59 @@ stasis.register_chamber = function(name, def)
|
|||
def.selection_box = def.node_box
|
||||
def.paramtype = 'light'
|
||||
def.paramtype2 = 'facedir'
|
||||
|
||||
-- Shorten tiles
|
||||
if not def.tiles[2] then
|
||||
local tile = def.tiles[1] ..
|
||||
'^[colorize:#0008^default_glass.png'
|
||||
def.tiles[2] = def.tiles[1]
|
||||
def.tiles[1] = tile
|
||||
end
|
||||
def.tiles = {
|
||||
def.tiles[1],
|
||||
def.tiles[2], def.tiles[2],
|
||||
def.tiles[2], def.tiles[2],
|
||||
def.tiles[2], def.tiles[2],
|
||||
def.tiles[2],
|
||||
}
|
||||
|
||||
-- Shorten active tiles
|
||||
if not def.tiles_active then
|
||||
def.tiles_active = {def.tiles[2]}
|
||||
end
|
||||
if not def.tiles_active[2] then
|
||||
local tile = def.tiles_active[1] ..
|
||||
'^[colorize:#0008^stasis_player.png^default_glass.png'
|
||||
def.tiles_active[2] = def.tiles_active[1]
|
||||
def.tiles_active[1] = tile
|
||||
end
|
||||
def.tiles_active = {
|
||||
def.tiles_active[1],
|
||||
def.tiles_active[2], def.tiles_active[2],
|
||||
def.tiles_active[2], def.tiles_active[2],
|
||||
def.tiles_active[2], def.tiles_active[2],
|
||||
def.tiles_active[2],
|
||||
}
|
||||
end
|
||||
|
||||
local on_rightclick = def.on_rightclick
|
||||
local replace_with
|
||||
if def.replace_with then
|
||||
replace_with = def.replace_with
|
||||
else
|
||||
replace_with = name
|
||||
end
|
||||
|
||||
def.on_rightclick = function(pos, node, player)
|
||||
if player.is_fake_player then return end
|
||||
if on_rightclick and on_rightclick(pos, node, player) then
|
||||
return
|
||||
end
|
||||
|
||||
local victim = player:get_player_name()
|
||||
|
||||
if on_rightclick and not stasis.frozen_players[victim] then
|
||||
if on_rightclick(pos, node, player) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Knockout integration
|
||||
if knockout and knockout.carrying[victim] then
|
||||
victim = knockout.carrying[victim]
|
||||
|
@ -46,7 +87,7 @@ stasis.register_chamber = function(name, def)
|
|||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('victim', victim)
|
||||
|
||||
stasis.freeze_player(victim, pos, name)
|
||||
stasis.freeze_player(victim, pos, replace_with)
|
||||
end
|
||||
|
||||
minetest.register_node(':' .. name, def)
|
||||
|
@ -74,7 +115,7 @@ stasis.register_chamber = function(name, def)
|
|||
local meta = minetest.get_meta(pos)
|
||||
local victim = meta:get_string('victim')
|
||||
|
||||
minetest.swap_node(pos, {name = name, param2 = node.param2})
|
||||
minetest.swap_node(pos, {name = replace_with, param2 = node.param2})
|
||||
|
||||
if victim and #victim > 0 and cloaking.is_cloaked(victim) and
|
||||
stasis.frozen_players[victim] then
|
||||
|
@ -103,23 +144,17 @@ end
|
|||
|
||||
-- The default chamber
|
||||
stasis.register_chamber('stasis:chamber', {
|
||||
description = "Admin stasis chamber",
|
||||
tiles = {'default_steel_block.png^[colorize:#0008^default_glass.png',
|
||||
'default_steel_block.png', 'default_steel_block.png',
|
||||
'default_steel_block.png', 'default_steel_block.png',
|
||||
'default_steel_block.png', 'default_steel_block.png',
|
||||
'default_steel_block.png'},
|
||||
tiles_active = {'default_steel_block.png^[colorize:#0008^stasis_player.png^default_glass.png',
|
||||
'default_steel_block.png', 'default_steel_block.png',
|
||||
'default_steel_block.png', 'default_steel_block.png',
|
||||
'default_steel_block.png', 'default_steel_block.png',
|
||||
'default_steel_block.png'},
|
||||
description = "Stasis chamber Mk3",
|
||||
tiles = {
|
||||
'default_steel_block.png',
|
||||
},
|
||||
|
||||
groups = {dig_immediate = 2},
|
||||
drawtype = 'stasis_chamber',
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('infotext', 'Stasis chamber')
|
||||
meta:set_string('infotext', 'Stasis chamber Mk3')
|
||||
end,
|
||||
|
||||
--on_rightclick = function(pos, node, player)
|
||||
|
|
1
init.lua
1
init.lua
|
@ -7,3 +7,4 @@ stasis = {}
|
|||
local path = minetest.get_modpath(minetest.get_current_modname())
|
||||
dofile(path .. '/core.lua')
|
||||
dofile(path .. '/chamber.lua')
|
||||
dofile(path .. '/morechambers.lua')
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
--
|
||||
-- Minetest stasis mod - More chambers
|
||||
--
|
||||
|
||||
-- Take an item from the player's inventory
|
||||
local steal_item = function(player, required)
|
||||
local victim = player:get_player_name()
|
||||
local item = player:get_wielded_item()
|
||||
local required = ItemStack(required)
|
||||
local required_name = required:get_name()
|
||||
local required_count = required:get_count()
|
||||
|
||||
if item:get_name() == required_name and
|
||||
item:get_count() >= required_count then
|
||||
if item:get_count() == required_count then
|
||||
item = nil
|
||||
else
|
||||
item = item:take_item(required_count)
|
||||
end
|
||||
minetest.after(0, function()
|
||||
player:set_wielded_item(item)
|
||||
end)
|
||||
else
|
||||
local def = minetest.registered_items[required_name]
|
||||
if def and def.description then
|
||||
item = def.description:lower()
|
||||
else
|
||||
item = required_name
|
||||
end
|
||||
minetest.chat_send_player(victim,
|
||||
'You must hold ' .. tostring(required_count) .. 'x ' ..
|
||||
item .. ' to use this stasis chamber.')
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Mk1 chambers
|
||||
--
|
||||
-- Requires 1 glass bottle per use, SINGLE-USE ONLY
|
||||
--
|
||||
stasis.register_chamber('stasis:1_chamber', {
|
||||
description = "Stasis chamber Mk1",
|
||||
tiles = {'default_wood.png'},
|
||||
drawtype = 'stasis_chamber',
|
||||
groups = {dig_immediate = 2},
|
||||
replace_with = 'stairs:slab_wood',
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('infotext', 'Stasis chamber Mk1\nSINGLE USE ONLY')
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if steal_item(player, 'vessels:glass_bottle') then
|
||||
return true
|
||||
else
|
||||
meta:set_string('infotext', '')
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- Mk2 chambers
|
||||
--
|
||||
-- Requires 1 mese crystal fragment per use
|
||||
--
|
||||
stasis.register_chamber('stasis:2_chamber', {
|
||||
description = "Stasis chamber Mk2",
|
||||
tiles = {'default_brick.png'},
|
||||
drawtype = 'stasis_chamber',
|
||||
groups = {dig_immediate = 2},
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string('infotext', 'Stasis chamber Mk2')
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, player)
|
||||
return steal_item(player, 'default:mese_crystal_fragment')
|
||||
end,
|
||||
})
|
||||
|
||||
--
|
||||
-- Crafting
|
||||
--
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'stasis:1_chamber',
|
||||
recipe = {
|
||||
{'default:snow', 'doors:door_glass', 'default:snow'},
|
||||
{'group:wood', 'beds:fancy_bed', 'group:wood'},
|
||||
{'default:torch', 'group:wood', 'default:torch'},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'stasis:2_chamber',
|
||||
recipe = {
|
||||
{'default:ice', 'default:brick', 'default:ice'},
|
||||
{'default:brick', 'stasis:1_chamber', 'default:brick'},
|
||||
{'default:ice', 'default:mese_crystal', 'default:ice'},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'stasis:chamber',
|
||||
recipe = {
|
||||
{'default:ice', 'default:mese', 'default:ice'},
|
||||
{'default:steelblock', 'stasis:2_chamber', 'default:steelblock'},
|
||||
{'default:steelblock', 'default:mese', 'default:steelblock'},
|
||||
},
|
||||
replacements = {
|
||||
{'default:mese', 'default:diamondblock'},
|
||||
},
|
||||
})
|
Loading…
Reference in New Issue