Compare commits
5 Commits
7bab6df029
...
2d36ed439c
Author | SHA1 | Date |
---|---|---|
Fernando Zapata | 2d36ed439c | |
Fernando Zapata | 5cd5db1811 | |
Fernando Zapata | 46b62b79b3 | |
Fernando Zapata | 61d1f3829c | |
Fernando Zapata | 5112a66a81 |
|
@ -0,0 +1,3 @@
|
|||
default
|
||||
helper
|
||||
wool
|
|
@ -0,0 +1,132 @@
|
|||
--------------------------------------------------------------------------------
|
||||
-- Bed
|
||||
--------------------------------------------------------------------------------
|
||||
-- Beds which set spawn when placed
|
||||
--
|
||||
-- (c)2012 Fernando Zapata (ZLovesPancakes, Franz.ZPT)
|
||||
-- Code licensed under GNU GPLv2
|
||||
-- http://www.gnu.org/licenses/gpl-2.0.html
|
||||
-- Content licensed under CC BY-SA 3.0
|
||||
-- http://creativecommons.org/licenses/by-sa/3.0/
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
------------------------------------------------------------- Constants --------
|
||||
|
||||
bed = {}
|
||||
|
||||
bed.spnlst = {}
|
||||
bed.spndir = minetest.get_worldpath() .. '/spawn/'
|
||||
|
||||
------------------------------------------------------------- Functions --------
|
||||
|
||||
function bed.setHome( n, p )
|
||||
local f = io.open( bed.spndir .. n, 'w' )
|
||||
local t = 'return{x=' .. p.x .. ',y=' .. p.y .. ',z=' .. p.z .. '}'
|
||||
bed.spnlst[n] = p
|
||||
f:write( t )
|
||||
f:close()
|
||||
end
|
||||
|
||||
function bed.unsetHome( n )
|
||||
local f = io.open( bed.spndir .. n, 'w' )
|
||||
bed.spnlst[n] = nil
|
||||
f:write( 'return nil' )
|
||||
f:close()
|
||||
end
|
||||
|
||||
function bed.moveToHome( u )
|
||||
u:setpos( bed.spnlst[u:get_player_name()] )
|
||||
end
|
||||
|
||||
----------------------------------------------------------------- Nodes --------
|
||||
|
||||
minetest.register_node( 'bed:bed_a', {
|
||||
description = 'Bed',
|
||||
groups = {
|
||||
snappy = 1,
|
||||
choppy = 2,
|
||||
oddly_breakable_by_hand = 2,
|
||||
flammable = 3 },
|
||||
inventory_image = 'bed_icon.png',
|
||||
wield_image = 'bed_icon.png',
|
||||
tiles = {
|
||||
'bed_top_b.png', 'default_wood.png',
|
||||
'bed_side_b.png' },
|
||||
drawtype = 'nodebox',
|
||||
paramtype = 'light',
|
||||
paramtype2 = 'facedir',
|
||||
node_box = nodeBox( -1/2, -1/2, -1/2, 1/2, 1/8, 1/2 ),
|
||||
selection_box = nodeBox( -1/2, -1/2, -1/2, 1/2, 1/8, 3/2 ),
|
||||
after_place_node = function( p, u )
|
||||
local m = minetest.env:get_meta( p )
|
||||
local n = minetest.env:get_node( p )
|
||||
m:set_string('owner', u:get_player_name())
|
||||
case( n.param2 ):of {
|
||||
[0] = function() p.z = p.z + 1 end,
|
||||
[1] = function() p.x = p.x + 1 end,
|
||||
[2] = function() p.z = p.z - 1 end,
|
||||
[3] = function() p.x = p.x - 1 end
|
||||
}
|
||||
minetest.env:set_node( p, {name='bed:bed_b', param2=n.param2} )
|
||||
bed.setHome( u:get_player_name(), u:getpos() )
|
||||
minetest.chat_send_player( u:get_player_name(), 'Home set!' )
|
||||
end,
|
||||
on_destruct = function( p )
|
||||
bed.unsetHome( minetest.env:get_meta( p ):get_string('owner') )
|
||||
case( minetest.env:get_node(p).param2 ):of {
|
||||
[0] = function() p.z = p.z + 1 end,
|
||||
[1] = function() p.x = p.x + 1 end,
|
||||
[2] = function() p.z = p.z - 1 end,
|
||||
[3] = function() p.x = p.x - 1 end
|
||||
}
|
||||
minetest.env:remove_node( p )
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node( 'bed:bed_b', {
|
||||
groups = {
|
||||
snappy = 1,
|
||||
choppy = 2,
|
||||
oddly_breakable_by_hand = 2 },
|
||||
tiles = { 'bed_top_a.png', 'default_wood.png',
|
||||
'bed_right_a.png', 'bed_left_a.png',
|
||||
'bed_front_a.png', 'bed_front_a.png' },
|
||||
drawtype = 'nodebox',
|
||||
paramtype = 'light',
|
||||
paramtype2 = 'facedir',
|
||||
node_box = nodeBox( -1/2, -1/2, -1/2, 1/2, 1/8, 1/2 ),
|
||||
selection_box = nodeBox( 0, 0, 0, 0, 0, 0 )
|
||||
})
|
||||
|
||||
--------------------------------------------------------------- Recipes --------
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'bed:bed',
|
||||
recipe = { { 'wool:blue', 'wool:blue', 'wool:blue' },
|
||||
{ 'default:wood', 'default:wood', 'default:wood' } }
|
||||
})
|
||||
|
||||
---------------------------------------------------------------- Events --------
|
||||
|
||||
minetest.register_on_joinplayer( function( u )
|
||||
local n = u:get_player_name()
|
||||
local f = loadfile( bed.spndir .. n )
|
||||
if f ~= nil then bed.spnlst[n] = f() end
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer( function( u )
|
||||
if bed.spnlst[u:get_player_name()] ~= nil then
|
||||
bed.moveToHome( u )
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
minetest.register_alias( 'bed:bed', 'bed:bed_a' )
|
||||
|
||||
if not isDir(bed.spndir) then
|
||||
os.execute( 'mkdir ' .. bed.spndir )
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
After Width: | Height: | Size: 334 B |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 481 B |
After Width: | Height: | Size: 479 B |
After Width: | Height: | Size: 469 B |
After Width: | Height: | Size: 490 B |
After Width: | Height: | Size: 471 B |
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -2,8 +2,8 @@
|
|||
-- Custom Commands
|
||||
--------------------------------------------------------------------------------
|
||||
-- Many custom commands, currently includes:
|
||||
-- /killme Suicide
|
||||
-- /playerlist List players
|
||||
-- /kill Suicide
|
||||
-- /list List players
|
||||
--
|
||||
-- (c)2012 Fernando Zapata
|
||||
-- Code licensed under GNU GPLv2
|
||||
|
@ -13,7 +13,7 @@
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
---- Suicide command ----
|
||||
minetest.register_chatcommand( 'killme', {
|
||||
minetest.register_chatcommand( 'kill', {
|
||||
description = 'kill yourself',
|
||||
func = function( name, param )
|
||||
local player = minetest.env:get_player_by_name(name)
|
||||
|
@ -22,7 +22,7 @@ minetest.register_chatcommand( 'killme', {
|
|||
})
|
||||
|
||||
---- List connected players ----
|
||||
minetest.register_chatcommand( 'playerlist', {
|
||||
minetest.register_chatcommand( 'list', {
|
||||
descrpition = 'list connected players',
|
||||
func = function( name, param )
|
||||
local players = minetest.get_connected_players()
|
||||
|
@ -34,6 +34,4 @@ minetest.register_chatcommand( 'playerlist', {
|
|||
end
|
||||
})
|
||||
|
||||
print( ' ++ loaded : Custom Commands, by ZLovesPancakes' )
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -8,10 +8,6 @@
|
|||
-- http://creativecommons.org/licenses/by-sa/3.0/
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------- Globals --------
|
||||
|
||||
--helper = {}
|
||||
|
||||
------------------------------------------------------------- Functions --------
|
||||
|
||||
function xyz( i,j,k ) return {x=i,y=j,z=k} end
|
||||
|
@ -27,10 +23,10 @@ function inTable( v, t )
|
|||
return false
|
||||
end
|
||||
|
||||
function switch( c )
|
||||
local swtbl = {
|
||||
function case( c )
|
||||
return {
|
||||
casevar = c,
|
||||
caseof = function (self, code)
|
||||
of = function (self, code)
|
||||
local f
|
||||
if (self.casevar) then
|
||||
f = code[self.casevar] or code.default
|
||||
|
@ -48,10 +44,9 @@ function switch( c )
|
|||
end
|
||||
end
|
||||
}
|
||||
return swtbl
|
||||
end
|
||||
|
||||
function isDir( d )
|
||||
function isDir(d)
|
||||
local f = io.open(d..'/.')
|
||||
if f then
|
||||
io.close(f)
|
||||
|
@ -61,4 +56,8 @@ function isDir( d )
|
|||
end
|
||||
end
|
||||
|
||||
function nodeBox(x, y, z, i, j, k)
|
||||
return {type = 'fixed', fixed = {x, y, z, i, j, k}}
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
--------------------------------------------------------------------------------
|
||||
-- Lighter
|
||||
--------------------------------------------------------------------------------
|
||||
-- Easy method to create fire
|
||||
--
|
||||
-- (c)2012 Fernando Zapata (ZLovesPancakes, Franz.ZPT)
|
||||
-- Code licensed under GNU GPLv2
|
||||
-- http://www.gnu.org/licenses/gpl-2.0.html
|
||||
-- Content licensed under CC BY-SA 3.0
|
||||
-- http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-- 2012-05-01 14:22:27
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
minetest.register_craftitem( 'lighter:flint', {
|
||||
description = 'Flint',
|
||||
inventory_image = 'lighter_flint.png'
|
||||
})
|
||||
|
||||
minetest.register_tool( 'lighter:lighter', {
|
||||
description = 'Flint & Steel',
|
||||
inventory_image = 'lighter_lighter.png',
|
||||
on_use = function( s, u, p )
|
||||
if p.type ~= 'node' then return end
|
||||
if minetest.env:get_node( p.under ).name == 'tnt:tnt' then
|
||||
tnt.lit( p.under )
|
||||
else
|
||||
minetest.env:add_node( p.above,
|
||||
{ name='fire:basic_flame' } )
|
||||
end
|
||||
s:add_wear( math.ceil(65535/30) )
|
||||
return s
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'lighter:lighter',
|
||||
recipe = {
|
||||
{ 'default:steel_ingot', '' },
|
||||
{ '', 'lighter:flint' }
|
||||
}
|
||||
})
|
||||
|
||||
----------------------------------------------------------- End of File --------
|
After Width: | Height: | Size: 163 B |
After Width: | Height: | Size: 177 B |
|
@ -1,2 +1,2 @@
|
|||
default
|
||||
|
||||
helper
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
------------------------------------------------------------- Functions --------
|
||||
|
||||
local function xyz( i,j,k ) return {x=i,y=j,z=k} end
|
||||
|
||||
local function unwheat( p, n, u )
|
||||
p.y = p.y + 1
|
||||
local nn = minetest.env:get_node( p ).name
|
||||
|
|
Before Width: | Height: | Size: 359 B |