Initial import

master
user 2012-06-28 21:11:10 +00:00
commit 09889aab68
246 changed files with 3263 additions and 0 deletions

72
bookmarks.lua Normal file
View File

@ -0,0 +1,72 @@
-- ***********************************************************************************
-- go **************************************************
-- ***********************************************************************************
local write_gofile = function()
local output = '' -- WRITE CHANGES TO FILE
for name, coords in pairs(GONETWORK) do output = output..name..':'..coords.x..','..coords.y..','..coords.z..';' end
local f = io.open(minetest.get_worldpath()..'/godtools.gonetwork', "w")
f:write(output)
io.close(f)
end
GONETWORK = {}
local gonfile = io.open(minetest.get_worldpath()..'/godtools.gonetwork', "r")
if gonfile then
local contents = gonfile:read()
io.close(gonfile)
if contents ~= nil then
local entries = contents:split(";")
for i,entry in pairs(entries) do
local goname, coords = unpack(entry:split(":"))
local p = {}
p.x, p.y, p.z = string.match(coords, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
GONETWORK[goname] = {x = tonumber(p.x),y= tonumber(p.y),z = tonumber(p.z)}
end
end
end
end
minetest.register_chatcommand("setgo", {
params = "<name>",
description = "set /go destination",
privs = {server=true},
func = function(name, param)
local target = minetest.env:get_player_by_name(name)
if target then
GONETWORK[param] = target:getpos()
write_gofile()
minetest.chat_send_player(name, "/go "..param.." set")
return
end
end,
})
minetest.register_chatcommand("go", {
params = "<goname>",
description = "go to destination",
func = function(name, param)
if GONETWORK[param] == nil then minetest.chat_send_player(name, "no such destination") return end
teleportee = minetest.env:get_player_by_name(name)
teleportee:setpos(GONETWORK[param])
end,
})
minetest.register_chatcommand("delgo", {
params = "<name>",
description = "delete /go destination",
privs = {server=true},
func = function(name, param)
if GONETWORK[param] then
GONETWORK[param] = nil
write_gofile()
end
end,
})
minetest.register_chatcommand("listgo", {
params = "<goname>",
description = "list all go destinations",
func = function(name, param)
for go, coords in pairs(GONETWORK) do minetest.chat_send_player(name, "/go "..go.. ' at '..coords.x..','..coords.y..','..coords.z) end
end,
})

0
buildings/aztec.bld Normal file
View File

0
buildings/aztectower.bld Normal file
View File

0
buildings/bighome.bld Normal file
View File

460
crafts.lua Normal file
View File

@ -0,0 +1,460 @@
minetest.register_craft({ output = 'madblocks:promix 6', recipe = {
{'', 'default:clay_lump',''},
{'default:dirt', 'default:dirt', 'default:dirt'},
{'default:dirt', 'default:dirt', 'default:dirt'},
}})
minetest.register_craft({ output = 'madblocks:growlamp 1', recipe = {
{'glass', 'torch','glass'},
{'glass', 'torch','glass'},
{'glass', 'torch','glass'},
}})
-- ** dye
minetest.register_craft({ output = 'node "madblocks:dye_cyan" 4', recipe = {
{'','',''},
{'node "madblocks:hydroponics_cyanflower"','',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:dye_magenta" 4', recipe = {
{'','',''},
{'node "madblocks:hydroponics_magentaflower"','',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:dye_yellow" 4', recipe = {
{'','',''},
{'node "madblocks:hydroponics_yellowflower"','',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:dye_green" 2', recipe = {
{'','',''},
{'','madblocks:dye_cyan',''},
{'','madblocks:dye_yellow',''},
}})
minetest.register_craft({ output = 'node "madblocks:dye_blue" 2', recipe = {
{'','',''},
{'','madblocks:dye_cyan',''},
{'','madblocks:dye_magenta',''},
}})
minetest.register_craft({ output = 'node "madblocks:dye_red" 2', recipe = {
{'','',''},
{'','madblocks:dye_yellow',''},
{'','madblocks:dye_magenta',''},
}})
minetest.register_craft({ output = 'node "madblocks:dye_black" 3', recipe = {
{'','madblocks:dye_cyan',''},
{'','madblocks:dye_magenta',''},
{'','madblocks:dye_yellow',''},
}})
-- ** bricks
minetest.register_craft({ output = 'node "madblocks:bluecyanbrick" 1', recipe = {
{'','node "madblocks:dye_blue"',''},
{'','node "brick"',''},
{'','madblocks:dye_cyan',''},
}})
minetest.register_craft({ output = 'node "madblocks:magentabrick" 1', recipe = {
{'','node "madblocks:dye_magenta"',''},
{'','node "brick"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:greenbrick" 1', recipe = {
{'','node "madblocks:dye_green"',''},
{'','node "brick"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:blackbrick" 1', recipe = {
{'','node "madblocks:dye_black"',''},
{'','node "brick"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:bluebrick" 1', recipe = {
{'','node "madblocks:dye_blue"',''},
{'','node "brick"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:yellowbrick" 1', recipe = {
{'','madblocks:dye_yellow',''},
{'','node "brick"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:brownbrick" 1', recipe = {
{'','madblocks:dye_red',''},
{'','node "brick"',''},
{'','madblocks:dye_black',''},
}})
minetest.register_craft({ output = 'node "madblocks:cyanbrick" 1', recipe = {
{'','madblocks:dye_cyan',''},
{'','node "brick"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:oddbrick" 1', recipe = {
{'','madblocks:dye_red',''},
{'','node "brick"',''},
{'','madblocks:dye_yellow',''},
}})
minetest.register_craft({ output = 'node "madblocks:asphalte" 1', recipe = {
{'','',''},
{'','craft "lump_of_coal"',''},
{'','node "cobble"',''},
}})
minetest.register_craft({ output = 'node "madblocks:mossystonebrick" 1', recipe = {
{'','node "default:leaves"',''},
{'','node "default:cobble"',''},
{'','node "madblocks:dye_yellow"',''},
}})
minetest.register_craft({ output = 'node "madblocks:culturedstone" 1', recipe = {
{'','madblocks:dye_yellow',''},
{'','node "default:cobble"',''},
{'','node "madblocks:dye_red"',''},
}})
minetest.register_craft({ output = 'node "madblocks:marblestonebrick" 1', recipe = {
{'','node "madblocks:dye_green"',''},
{'','node "default:cobble"',''},
{'','node "madblocks:dye_black"',''},
}})
minetest.register_craft({ output = 'node "madblocks:shinystonebrick" 1', recipe = {
{'','node "default:sand"',''},
{'','node "default:cobble"',''},
{'','node "madblocks:dye_red"',''},
}})
minetest.register_craft({ output = 'node "madblocks:cinderblock" 9', recipe = {
{'default:cobble','default:cobble','default:cobble'},
{'default:cobble','default:cobble','default:cobble'},
{'default:cobble','default:cobble','default:cobble'},
}})
minetest.register_craft({ output = 'node "madblocks:woodshingles" 8', recipe = {
{'node "default:wood"','node "default:wood"'},
{'node "default:wood"','node "default:wood"'},
}})
minetest.register_craft({ output = 'node "madblocks:magentawood" 1', recipe = {
{'','node "madblocks:dye_magenta"',''},
{'','node "default:wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:bluewood" 1', recipe = {
{'','node "madblocks:dye_blue"',''},
{'','node "default:wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:blackwood" 1', recipe = {
{'','node "madblocks:dye_black"',''},
{'','node "default:wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:yellowwood" 1', recipe = {
{'','node "madblocks:dye_yellow"',''},
{'','node "default:wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:cyanwood" 1', recipe = {
{'','node "madblocks:dye_cyan"',''},
{'','node "default:wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:greenwood" 1', recipe = {
{'','node "madblocks:dye_green"',''},
{'','node "default:wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:redwood" 1', recipe = {
{'','node "madblocks:dye_red"',''},
{'','node "default:wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:redwood_fence" 1', recipe = {
{'','node "madblocks:dye_red"',''},
{'','node "default:fence_wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:blackwood_fence" 1', recipe = {
{'','node "madblocks:dye_black"',''},
{'','node "default:fence_wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:greenwood_fence" 1', recipe = {
{'','node "madblocks:dye_green"',''},
{'','node "default:fence_wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:yellowwood_fence" 1', recipe = {
{'','node "madblocks:dye_yellow"',''},
{'','node "default:fence_wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:bluewood_fence" 1', recipe = {
{'','node "madblocks:dye_blue"',''},
{'','node "default:fence_wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:magentawood_fence" 1', recipe = {
{'','node "madblocks:dye_magenta"',''},
{'','node "default:fence_wood"',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:cyanwood_fence" 1', recipe = {
{'','node "madblocks:dye_cyan"',''},
{'','node "default:fence_wood"',''},
{'','',''},
}})
-- ** lights
minetest.register_craft({ output = 'node "madblocks:glowtron" 1', recipe = {
{'','torch',''},
{'','glass',''},
{'','madblocks:dye_black','madblocks:dye_yellow'},
}})
minetest.register_craft({ output = 'node "madblocks:glowyellow" 1', recipe = {
{'','torch',''},
{'','glass',''},
{'','madblocks:dye_yellow',''},
}})
minetest.register_craft({ output = 'node "madblocks:glowgreen" 1', recipe = {
{'','torch',''},
{'','glass',''},
{'','madblocks:dye_green',''},
}})
minetest.register_craft({ output = 'node "madblocks:glowred" 1', recipe = {
{'','torch',''},
{'','glass',''},
{'','madblocks:dye_red',''},
}})
minetest.register_craft({ output = 'node "madblocks:glowblue" 1', recipe = {
{'','torch',''},
{'','glass',''},
{'','madblocks:dye_blue',''},
}})
-- ** signs
minetest.register_craft({ output = 'madblocks:signs_park 1', recipe = {
{'','madblocks:dye_blue',''},
{'','madblocks:sheetmetal',''},
{'','',''},
}})
minetest.register_craft({ output = 'madblocks:signs_cliff 1', recipe = {
{'','madblocks:dye_black',''},
{'','madblocks:sheetmetal',''},
{'','madblocks:dye_yellow',''},
}})
minetest.register_craft({ output = 'madblocks:signs_interdit 1', recipe = {
{'','madblocks:dye_red',''},
{'','madblocks:sheetmetal',''},
{'','madblocks:dye_red',''},
}})
minetest.register_craft({ output = 'madblocks:signs_montreal 1', recipe = {
{'','madblocks:dye_green',''},
{'','madblocks:sheetmetal',''},
{'','',''},
}})
minetest.register_craft({ output = 'madblocks:signs_420 1', recipe = {
{'','madblocks:dye_black',''},
{'','madblocks:sheetmetal',''},
{'','',''},
}})
minetest.register_craft({ output = 'madblocks:signs_chicken 1', recipe = {
{'','madblocks:dye_yellow',''},
{'','madblocks:sheetmetal',''},
{'','madblocks:dye_black',''},
}})
minetest.register_craft({ output = 'madblocks:signs_obscene 1', recipe = {
{'','madblocks:dye_red',''},
{'','madblocks:sheetmetal',''},
{'','madblocks:dye_black',''},
}})
minetest.register_craft({ output = 'madblocks:sheetmetal 4', recipe = {
{'default:steel_ingot'},
}})
minetest.register_craft({ output = 'node "madblocks:pylon" 5', recipe = {
{'madblocks:sheetmetal','','madblocks:sheetmetal'},
{'','madblocks:sheetmetal',''},
{'madblocks:sheetmetal','','madblocks:sheetmetal'},
}})
minetest.register_craft({ output = 'node "madblocks:safetyladder" 7', recipe = {
{'madblocks:sheetmetal','','madblocks:sheetmetal'},
{'madblocks:sheetmetal','madblocks:sheetmetal','madblocks:sheetmetal'},
{'madblocks:sheetmetal','','madblocks:sheetmetal'},
}})
minetest.register_craft({ output = 'node "madblocks:spotlight" 1', recipe = {
{'','',''},
{'','madblocks:glowyellow_off',''},
{'','madblocks:sheetmetal',''},
}})
minetest.register_craft({ output = 'madblocks:wine 1', recipe = {
{'default:glass', 'madblocks:hydroponics_grapes','default:glass'},
{'default:glass', 'madblocks:hydroponics_grapes','default:glass'},
{'default:glass', 'madblocks:hydroponics_grapes','default:glass'},
}})
minetest.register_craft({ output = 'node "madblocks:bigben" 1', recipe = {
{'','madblocks:dye_black',''},
{'','madblocks:sheetmetal',''},
{'','default:wood',''},
}})
minetest.register_craft({ output = 'node "madblocks:siren" 1', recipe = {
{'','',''},
{'madblocks:sheetmetal','madblocks:dye_red','madblocks:sheetmetal'},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:churchbells" 1', recipe = {
{'','',''},
{'','madblocks:sheetmetal',''},
{'madblocks:sheetmetal','','madblocks:sheetmetal'},
}})
minetest.register_craft({ output = 'node "madblocks:slimtree" 1', recipe = {
{'','default:leaves',''},
{'','default:leaves',''},
{'','default:stick',''},
}})
minetest.register_craft({ output = 'node "madblocks:orangecone" 1', recipe = {
{'','madblocks:dye_red','madblocks:dye_yellow'},
{'','madblocks:rubber',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:coffeecup" 1', recipe = {
{'','',''},
{'default:clay_lump','madblocks:coffee','default:clay_lump'},
{'','default:clay_lump',''},
}})
minetest.register_craft({ output = 'node "madblocks:fancylamp" 1', recipe = {
{'','madblocks:dye_black',''},
{'','madblocks:sheetmetal',''},
{'','madblocks:glowyellow_off',''},
}})
minetest.register_craft({ output = 'node "madblocks:hangingflowers" 1', recipe = {
{'','',''},
{'default:stick','madblocks:rosebush','default:stick'},
{'','default:stick',''},
}})
minetest.register_craft({ output = 'node "madblocks:countrystonebrick" 2', recipe = {
{'','',''},
{'','madblocks:cement',''},
{'','default:cobble',''},
}})
minetest.register_craft({ output = 'node "madblocks:cement" 2', recipe = {
{'','',''},
{'','default:sand',''},
{'','default:gravel',''},
}})
minetest.register_craft({ output = 'node "madblocks:cinderblock_planter" 2', recipe = {
{'','',''},
{'','default:dirt',''},
{'','madblocks:cinderblock',''},
}})
minetest.register_craft({ output = 'node "madblocks:fancybracket" 4', recipe = {
{'','','madblocks:sheetmetal'},
{'','','madblocks:sheetmetal'},
{'','madblocks:sheetmetal','madblocks:sheetmetal'},
}})
minetest.register_craft({ output = 'node "madblocks:blackstonebrick" 1', recipe = {
{'','',''},
{'','madblocks:dye_black',''},
{'','default:cobble',''},
}})
minetest.register_craft({ output = 'node "madblocks:roundstonebrick" 5', recipe = {
{'','default:cobble',''},
{'default:cobble','madblocks:cement','default:cobble'},
{'','default:cobble',''},
}})
minetest.register_craft({ output = 'node "madblocks:slimstonebrick" 3', recipe = {
{'','default:cobble',''},
{'','madblocks:cement',''},
{'','default:cobble',''},
}})
minetest.register_craft({ output = 'node "madblocks:greystonebrick" 2', recipe = {
{'','madblocks:dye_black',''},
{'','default:cobble',''},
{'','madblocks:cement',''},
}})
minetest.register_craft({ output = 'node "madblocks:medistonebrick" 3', recipe = {
{'','',''},
{'madblocks:dye_cyan','','madblocks:dye_yellow'},
{'default:cobble','madblocks:cement','default:cobble'},
}})
minetest.register_craft({ output = 'node "madblocks:whitestonebrick" 3', recipe = {
{'','default:clay',''},
{'','default:cobble',''},
{'','madblocks:cement',''},
}})
minetest.register_craft({ output = 'node "madblocks:flowers2" 2', recipe = {
{'','',''},
{'madblocks:hydroponics_yellowflower','madblocks:hydroponics_magentaflower',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:flowers1" 2', recipe = {
{'','',''},
{'madblocks:hydroponics_magentaflower','madblocks:hydroponics_cyanflower',''},
{'','',''},
}})
minetest.register_craft({ output = 'node "madblocks:awning" 2', recipe = {
{'','',''},
{'','','default:junglegrass'},
{'','default:junglegrass','madblocks:dye_red'},
}})
minetest.register_craft({ output = 'node "madblocks:drum" 3', recipe = {
{'madblocks:sheetmetal','','madblocks:sheetmetal'},
{'madblocks:sheetmetal','madblocks:dye_black','madblocks:sheetmetal'},
{'madblocks:sheetmetal','madblocks:sheetmetal','madblocks:sheetmetal'},
}})
minetest.register_craft({ output = 'node "madblocks:barrel" 3', recipe = {
{'default:wood','','default:wood'},
{'default:wood','madblocks:sheetmetal','default:wood'},
{'default:wood','default:wood','default:wood'},
}})
minetest.register_craft({ output = 'node "madblocks:stool" 1', recipe = {
{'','madblocks:dye_red',''},
{'','madblocks:sheetmetal',''},
{'default:stick','','default:stick'},
}})
minetest.register_craft({ output = 'node "madblocks:gnome" 1', recipe = {
{'default:clay_lump','madblocks:dye_red','default:clay_lump'},
{'','default:clay_lump','madblocks:dye_green'},
{'default:clay_lump','','default:clay_lump'},
}})
minetest.register_craft({ output = 'node "madblocks:statue" 1', recipe = {
{'','default:clay_lump',''},
{'','default:clay_lump',''},
{'','default:clay_lump',''},
}})
minetest.register_craft({ output = 'node "madblocks:gargoyle" 1', recipe = {
{'','',''},
{'default:clay_lump','madblocks:dye_black','default:clay_lump'},
{'','default:clay_lump',''},
}})
minetest.register_craft({ output = 'node "madblocks:searchlight" 1', recipe = {
{'','madblocks:spotlight',''},
{'madblocks:spotlight','madblocks:sheetmetal','madblocks:spotlight'},
{'','madblocks:spotlight',''},
}})
-- 8 signs todo
minetest.register_craft({ output = 'madblocks:signs_cafe 1', recipe = {
{'','madblocks:coffeecup',''},
{'','default:sign_wall',''},
{'','default:torch',''},
}})
minetest.register_craft({ output = 'madblocks:signs_drpepper 1', recipe = {
{'','madblocks:dye_black',''},
{'','default:sign_wall',''},
{'','madblocks:dye_red',''},
}})
minetest.register_craft({ output = 'madblocks:signs_enjoycoke 1', recipe = {
{'','madblocks:sheetmetal',''},
{'','default:sign_wall',''},
{'','madblocks:dye_red',''},
}})
minetest.register_craft({ output = 'madblocks:signs_hucksfoodfuel 1', recipe = {
{'','madblocks:dye_red',''},
{'','default:sign_wall',''},
{'','madblocks:dye_yellow',''},
}})
minetest.register_craft({ output = 'madblocks:signs_dangermines 1', recipe = {
{'','madblocks:dye_yellow',''},
{'','default:sign_wall',''},
{'','madblocks:dye_black',''},
}})
minetest.register_craft({ output = 'madblocks:lampling 1', recipe = {
{'','madblocks:glowyellow',''},
{'','default:stick',''},
{'','default:stick',''},
}})
minetest.register_craft({ output = 'madblocks:street 1', recipe = {
{'','',''},
{'','',''},
{'madblocks:replicator','madblocks:replicator','madblocks:replicator'},
}})
minetest.register_craft({ type = "cooking", output = "madblocks:coffee", recipe = "madblocks:hydroponics_coffee", })

1
depends.txt Normal file
View File

@ -0,0 +1 @@
default

356
hydroponics.lua Normal file
View File

@ -0,0 +1,356 @@
GLOWLIKE('growlamp','Growlamp','plantlike')
minetest.register_node("madblocks:promix", {
description = "Promix",
tile_images = {"madblocks_promix.png"},
is_ground_content = true,
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults(),
})
get_plantname = {} -- plants index by nodenames (tomato1, tomato2, seeds_tomato, etc..)
get_plantbynumber = {} -- plants index by number (for random select)
get_wildplants = {} -- wildplant nodenames (pop control)
local is_specialharvest = function(plantname)
local result = 'madblocks:hydroponics_'..plantname
if HYDROPONICS_PLANTS[plantname].give_on_harvest ~= nil then result = HYDROPONICS_PLANTS[plantname].give_on_harvest end
return result
end
for index,plant in pairs(HYDROPONICS_PLANTS) do
-- define nodes
minetest.register_node("madblocks:hydroponics_wild_"..plant.name, {
description = "Wild Plant",
drawtype = "plantlike",
visual_scale = 1.0,
tile_images = {"madblocks_hydroponics_wildplant.png"},
paramtype = "light",
walkable = false,
groups = {snappy=3,flammable=3},
sounds = default.node_sound_leaves_defaults(),
drop = 'madblocks:hydroponics_seeds_'..plant.name..' 4',
selection_box = {
type = "fixed",
fixed = {-1/3, -1/2, -1/3, 1/3, 1/6, 1/3},
},
})
minetest.register_node("madblocks:hydroponics_seeds_"..plant.name, {
description = plant.name.." Seeds",
drawtype = "signlike",
tile_images = {"madblocks_hydroponics_seeds.png"},
inventory_image = "madblocks_hydroponics_seeds.png",
wield_image = "madblocks_hydroponics_seeds.png",
paramtype = "light",
paramtype2 = "wallmounted",
is_ground_content = true,
walkable = false,
climbable = false,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
legacy_wallmounted = true,
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node('madblocks:hydroponics_seedlings_'..plant.name, {
drawtype = 'plantlike',
visual_scale = 1.0,
tile_images = { 'madblocks_hydroponics_seedlings.png' },
inventory_image = 'madblocks_hydroponics_seedlings.png',
sunlight_propagates = true,
paramtype = 'light',
walkable = false,
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
drop = '',
})
minetest.register_node('madblocks:hydroponics_sproutlings_' .. plant.name, {
drawtype = 'plantlike',
visual_scale = 1.0,
tile_images = { 'madblocks_hydroponics_sproutlings.png' },
inventory_image = 'madblocks_hydroponics_sproutlings.png',
sunlight_propagates = true,
paramtype = 'light',
walkable = false,
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
drop = '',
})
minetest.register_node('madblocks:hydroponics_'..plant.name..'1', {
description = 'Tomato Plant (Young)',
drawtype = 'plantlike',
visual_scale = 1.0,
tile_images = { 'madblocks_hydroponics_'..plant.name..'1.png' },
inventory_image = 'madblocks_hydroponics_'..plant.name..'1.png',
sunlight_propagates = true,
paramtype = 'light',
walkable = false,
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
drop = '',
})
local ondig = nil
if plant.growtype == 'permaculture' then
plant.growtype = 'growshort'
ondig = function(pos,node)
minetest.env:add_node(pos,{type='node',name='madblocks:hydroponics_'..plant.name..'1'})
end
end
minetest.register_node('madblocks:hydroponics_'..plant.name..'2', {
description = 'Tomato Plant (Youngish)',
drawtype = 'plantlike',
visual_scale = 1.0,
tile_images = { 'madblocks_hydroponics_'..plant.name..'2.png' },
inventory_image = 'madblocks_hydroponics_'..plant.name..'2.png',
sunlight_propagates = true,
paramtype = 'light',
walkable = false,
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
drop = '',
})
minetest.register_node('madblocks:hydroponics_'..plant.name..'3', {
description = 'Tomato Plant (Fruitings)',
drawtype = 'plantlike',
visual_scale = 1.0,
tile_images = { 'madblocks_hydroponics_'..plant.name..'3.png' },
inventory_image = 'madblocks_hydroponics_'..plant.name..'3.png',
sunlight_propagates = true,
paramtype = 'light',
walkable = false,
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
drop = '',
})
local harvest = 'madblocks:hydroponics_'..plant.name
if plant.give_on_harvest ~= nil then harvest = plant.give_on_harvest end
minetest.register_node('madblocks:hydroponics_'..plant.name..'4', {
description = 'Tomato Plant (Ripe)',
drawtype = 'plantlike',
visual_scale = 1.0,
tile_images = { 'madblocks_hydroponics_'..plant.name..'4.png' },
inventory_image = 'madblocks_hydroponics_'..plant.name..'4.png',
sunlight_propagates = true,
paramtype = 'light',
walkable = false,
furnace_burntime = 1,
groups = { snappy = 3 },
sounds = default.node_sound_leaves_defaults(),
on_dig = ondig,
drop = {
items = {
{ items = {'madblocks:hydroponics_seeds_'..plant.name..' 4'},
rarity = 6,
},
{
items = {harvest..' 4'},
}
}
},
})
if plant.give_on_harvest == nil then
minetest.register_node("madblocks:hydroponics_"..plant.name, {
description = plant.name,
drawtype = "plantlike",
visual_scale = 1.0,
tile_images = {"madblocks_hydroponics_"..plant.name..".png"},
inventory_image = "madblocks_hydroponics_"..plant.name..".png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
groups = {fleshy=3,dig_immediate=3,flammable=2},
on_use = minetest.item_eat(4),
sounds = default.node_sound_defaults(),
})
end
table.insert(get_wildplants, 'madblocks:hydroponics_wild_'..plant.name)
table.insert(get_plantbynumber, plant.name)
get_plantname["madblocks:hydroponics_"..plant.name.."4"] = plant.name
get_plantname["madblocks:hydroponics_"..plant.name.."3"] = plant.name
get_plantname["madblocks:hydroponics_"..plant.name.."2"] = plant.name
get_plantname["madblocks:hydroponics_"..plant.name.."1"] = plant.name
get_plantname['madblocks:hydroponics_sproutlings_'..plant.name] = plant.name
get_plantname['madblocks:hydroponics_seedlings_'..plant.name] = plant.name
get_plantname['madblocks:hydroponics_seeds_'..plant.name] = plant.name
end
-- GROW (TALL) FUNCTION
growtall = function (plantname, nodename, grnode)
if nodename == 'madblocks:hydroponics_'..plantname..'3' then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_"..plantname.."4"})
minetest.env:add_node(grnode.grow2,{type="node",name="madblocks:hydroponics_"..plantname.."4"})
elseif nodename == 'madblocks:hydroponics_'..plantname..'2' then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_"..plantname.."3"})
minetest.env:add_node(grnode.grow2,{type="node",name="madblocks:hydroponics_"..plantname.."3"})
elseif nodename == 'madblocks:hydroponics_'..plantname..'1' then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_"..plantname.."2"})
minetest.env:add_node(grnode.grow2,{type="node",name="madblocks:hydroponics_"..plantname.."2"})
elseif nodename =='madblocks:hydroponics_sproutlings_'..plantname then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_"..plantname.."1"})
elseif nodename == 'madblocks:hydroponics_seedlings_'..plantname then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_sproutlings_"..plantname})
elseif nodename == 'madblocks:hydroponics_seeds_'..plantname then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_seedlings_"..plantname})
end
end
growshort = function (plantname, nodename, grnode)
if nodename == 'madblocks:hydroponics_'..plantname..'3' then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_"..plantname.."4"})
-- minetest.env:add_node(grnode.grow2,{type="node",name="madblocks:hydroponics_"..plantname.."4"})
elseif nodename == 'madblocks:hydroponics_'..plantname..'2' then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_"..plantname.."3"})
-- minetest.env:add_node(grnode.grow2,{type="node",name="madblocks:hydroponics_"..plantname.."3"})
elseif nodename == 'madblocks:hydroponics_'..plantname..'1' then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_"..plantname.."2"})
-- minetest.env:add_node(grnode.grow2,{type="node",name="madblocks:hydroponics_"..plantname.."2"})
elseif nodename =='madblocks:hydroponics_sproutlings_'..plantname then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_"..plantname.."1"})
elseif nodename == 'madblocks:hydroponics_seedlings_'..plantname then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_sproutlings_"..plantname})
elseif nodename == 'madblocks:hydroponics_seeds_'..plantname then minetest.env:add_node(grnode.grow1,{type="node",name="madblocks:hydroponics_seedlings_"..plantname})
end
end
-- WILD PLANTS/SEEDS GENERATING
minetest.register_abm({
nodenames = { "default:dirt_with_grass" },
interval = NATURE_GROWSPEED,
chance = 80,
action = function(pos, node, active_object_count, active_object_count_wider)
local air = { x=pos.x, y=pos.y+1,z=pos.z }
local is_air = minetest.env:get_node_or_nil(air)
if is_air ~= nil and is_air.name == 'air' then
local count = table.getn(get_plantbynumber)
local random_plant = math.random(1,count)
local nodename = "madblocks:hydroponics_wild_"..get_plantbynumber[random_plant]
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name=nodename})
end
end
})
minetest.register_abm({
nodenames = get_wildplants,
interval = NATURE_GROWSPEED,
chance = 2,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:remove_node({x=pos.x,y=pos.y,z=pos.z})
end
})
-- GROWING
minetest.register_abm({
nodenames = { "madblocks:growlamp" },
interval = HYDRO_GROW_INTERVAL,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local grnode1 = {water = {x=pos.x,y=pos.y-5,z=pos.z}, mix = {x=pos.x,y=pos.y-4,z=pos.z},grow1 = {x=pos.x,y=pos.y-3,z=pos.z}, grow2 = {x=pos.x,y=pos.y-2,z=pos.z}}
local grnode2 = {water = {x=pos.x-1,y=pos.y-5,z=pos.z}, mix = {x=pos.x-1,y=pos.y-4,z=pos.z},grow1 = {x=pos.x-1, y=pos.y-3,z=pos.z}, grow2 = {x=pos.x-1,y=pos.y-2,z=pos.z}}
local grnode3 = {water = {x=pos.x+1,y=pos.y-5,z=pos.z}, mix = {x=pos.x+1,y=pos.y-4,z=pos.z},grow1 = {x=pos.x+1, y=pos.y-3,z=pos.z}, grow2 = {x=pos.x+1,y=pos.y-2,z=pos.z}}
local grnode4 = {water = {x=pos.x,y=pos.y-5,z=pos.z-1}, mix = {x=pos.x,y=pos.y-4,z=pos.z-1},grow1 = {x=pos.x, y=pos.y-3, z=pos.z-1}, grow2 = {x=pos.x,y=pos.y-2,z=pos.z-1}}
local grnode5 = {water = {x=pos.x,y=pos.y-5,z=pos.z+1}, mix = {x=pos.x,y=pos.y-4,z=pos.z+1},grow1 = {x=pos.x, y=pos.y-3, z=pos.z+1}, grow2 = {x=pos.x,y=pos.y-2,z=pos.z+1}}
local grnode6 = {water = {x=pos.x-1,y=pos.y-5,z=pos.z-1}, mix = {x=pos.x-1,y=pos.y-4,z=pos.z-1},grow1 = {x=pos.x-1,y=pos.y-3,z=pos.z-1}, grow2 = {x=pos.x-1,y=pos.y-2,z=pos.z-1}}
local grnode7 = {water = {x=pos.x-1,y=pos.y-5,z=pos.z+1}, mix = {x=pos.x-1,y=pos.y-4,z=pos.z+1},grow1 = {x=pos.x-1,y=pos.y-3,z=pos.z+1}, grow2 = {x=pos.x-1,y=pos.y-2,z=pos.z+1}}
local grnode8 = {water = {x=pos.x+1,y=pos.y-5,z=pos.z-1}, mix = {x=pos.x+1,y=pos.y-4,z=pos.z-1},grow1 = {x=pos.x+1,y=pos.y-3,z=pos.z-1}, grow2 = {x=pos.x+1,y=pos.y-2,z=pos.z-1}}
local grnode9 = {water = {x=pos.x+1,y=pos.y-5,z=pos.z+1}, mix = {x=pos.x+1,y=pos.y-4,z=pos.z+1},grow1 = {x=pos.x+1,y=pos.y-3,z=pos.z+1}, grow2 = {x=pos.x+1,y=pos.y-2,z=pos.z+1}}
local water1 = minetest.env:get_node(grnode1.water)
if water1.name == 'default:water_source' or water1.name == 'default:water_flowing' then water1 = true end
local ismix1 = minetest.env:get_node(grnode1.mix)
local water2 = minetest.env:get_node(grnode2.water)
if water2.name == 'default:water_source' or water2.name == 'default:water_flowing' then water2 = true end
local ismix2 = minetest.env:get_node(grnode2.mix)
local water3 = minetest.env:get_node(grnode3.water)
if water3.name == 'default:water_source' or water3.name == 'default:water_flowing' then water3 = true end
local ismix3 = minetest.env:get_node(grnode3.mix)
local water4 = minetest.env:get_node(grnode4.water)
if water4.name == 'default:water_source' or water4.name == 'default:water_flowing' then water4 = true end
local ismix4 = minetest.env:get_node(grnode4.mix)
local water5 = minetest.env:get_node(grnode5.water)
if water5.name == 'default:water_source' or water5.name == 'default:water_flowing' then water5 = true end
local ismix5 = minetest.env:get_node(grnode5.mix)
local water6 = minetest.env:get_node(grnode6.water)
if water6.name == 'default:water_source' or water6.name == 'default:water_flowing' then water6 = true end
local ismix6 = minetest.env:get_node(grnode6.mix)
local water7 = minetest.env:get_node(grnode7.water)
if water7.name == 'default:water_source' or water7.name == 'default:water_flowing' then water7 = true end
local ismix7 = minetest.env:get_node(grnode7.mix)
local water8 = minetest.env:get_node(grnode8.water)
if water8.name == 'default:water_source' or water8.name == 'default:water_flowing' then water8 = true end
local ismix8 = minetest.env:get_node(grnode8.mix)
local water9 = minetest.env:get_node(grnode9.water)
if water9.name == 'default:water_source' or water9.name == 'default:water_flowing' then water9 = true end
local ismix9 = minetest.env:get_node(grnode9.mix)
if water1 == true and ismix1.name == 'madblocks:promix' then
local grow1 = minetest.env:get_node(grnode1.grow1)
local curplant = get_plantname[grow1.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow1.name,grnode1) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow1.name,grnode1) end -- *** GENERIC GROW FUNCTION
end
if water2 == true and ismix2.name == 'madblocks:promix' then
local grow2 = minetest.env:get_node(grnode2.grow1)
local curplant = get_plantname[grow2.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow2.name,grnode2) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow2.name,grnode2) end -- *** GENERIC GROW FUNCTION
end
if water3 == true and ismix3.name == 'madblocks:promix' then
local grow3 = minetest.env:get_node(grnode3.grow1)
local curplant = get_plantname[grow3.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow3.name,grnode3) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow3.name,grnode3) end -- *** GENERIC GROW FUNCTION
end
if water4 == true and ismix4.name == 'madblocks:promix' then
local grow4 = minetest.env:get_node(grnode4.grow1)
local curplant = get_plantname[grow4.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow4.name,grnode4) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow4.name,grnode4) end -- *** GENERIC GROW FUNCTION
end
if water5 == true and ismix5.name == 'madblocks:promix' then
local grow5 = minetest.env:get_node(grnode5.grow1)
local curplant = get_plantname[grow5.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow5.name,grnode5) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow5.name,grnode5) end -- *** GENERIC GROW FUNCTION
end
if water6 == true and ismix6.name == 'madblocks:promix' then
local grow6 = minetest.env:get_node(grnode6.grow1)
local curplant = get_plantname[grow6.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow6.name,grnode6) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow6.name,grnode6) end -- *** GENERIC GROW FUNCTION
end
if water7 == true and ismix7.name == 'madblocks:promix' then
local grow7 = minetest.env:get_node(grnode7.grow1)
local curplant = get_plantname[grow7.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow7.name,grnode7) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow7.name,grnode7) end -- *** GENERIC GROW FUNCTION
end
if water8 == true and ismix8.name == 'madblocks:promix' then
local grow8 = minetest.env:get_node(grnode8.grow1)
local curplant = get_plantname[grow8.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow8.name,grnode8) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow8.name,grnode8) end -- *** GENERIC GROW FUNCTION
end
if water9 == true and ismix9.name == 'madblocks:promix' then
local grow9 = minetest.env:get_node(grnode9.grow1)
local curplant = get_plantname[grow9.name]
if curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growtall' then growtall(curplant,grow9.name,grnode9) -- *** GENERIC GROW FUNCTION
elseif curplant ~= nil and HYDROPONICS_PLANTS[curplant].growtype == 'growshort' then growshort(curplant,grow9.name,grnode9) end -- *** GENERIC GROW FUNCTION
end
end
})

38
init.lua Normal file
View File

@ -0,0 +1,38 @@
local madblocks_modpath = minetest.get_modpath("madblocks")
math.randomseed(os.time())
SEASON_LENGTH = 1500 -- max tested 1500
WEATHER_CHANGE_INTERVAL = 60
NATURE_GROW_INTERVAL = 700
HYDRO_GROW_INTERVAL = 100
BIRDS = false--true
NATURE_PLANTS = { 'madblocks:hydroponics_cyanflower','madblocks:hydroponics_magentaflower','madblocks:hydroponics_yellowflower',
'madblocks:dandylions','madblocks:mushroom'}
HYDROPONICS_PLANTS = {
tomato = {name='tomato',growtype='growtall'},
peas = {name='peas',growtype='growtall'},
habanero = {name='habanero',growtype='growtall'},
cyanflower = {name='cyanflower',growtype='growtall'},
magentaflower = {name='magentaflower',growtype='growtall'},
yellowflower = {name='yellowflower',growtype='growtall'},
rubberplant = {name='rubberplant',growtype='growshort', give_on_harvest='madblocks:rubber'},
grapes = {name='grapes',growtype='permaculture'},
coffee = {name='coffee',growtype='permaculture'},
roses = {name='roses',growtype='growtall',give_on_harvest='madblocks:rosebush'}
}
-- fixed git-120603
dofile (madblocks_modpath .. "/items.lua")
dofile (madblocks_modpath .. "/lights.lua")
dofile (madblocks_modpath .. "/nature.lua")
dofile (madblocks_modpath .. "/hydroponics.lua")
dofile (madblocks_modpath .. "/misc.lua")
dofile (madblocks_modpath .. "/crafts.lua")
dofile (madblocks_modpath .. "/bookmarks.lua")
dofile (madblocks_modpath .. "/multinode.lua")
dofile (madblocks_modpath .. "/nocrafts.lua") -- new stuff, look in file for giveme names
print('mAdBlOcKs 12.6.12 loaded')
--next: get rid of rubber, rubberplant (5 or 6 nodes), fix crafts

373
items.lua Normal file
View File

@ -0,0 +1,373 @@
-- ***********************************************************************************
-- FUNCTIONS **************************************************
-- ***********************************************************************************
BRICKLIKE = function(nodeid, nodename)
minetest.register_node("madblocks:"..nodeid, {
description = nodename,
tile_images = {"madblocks_"..nodeid..'.png'},
inventory_image = minetest.inventorycube("madblocks_"..nodeid..'.png'),
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
end
WOODLIKE = function(nodeid, nodename,fence)
minetest.register_node("madblocks:"..nodeid, {
description = nodename,
tile_images = {"madblocks_"..nodeid..".png"},
inventory_image = minetest.inventorycube("madblocks_"..nodeid..".png"),
is_ground_content = true,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
if fence == true then
minetest.register_node("madblocks:"..nodeid.."_fence", {
description = nodename.." Fence",
drawtype = "fencelike",
tile_images = {"madblocks_"..nodeid..".png"},
inventory_image = "madblocks_"..nodeid.."_fence.png",
wield_image = "madblocks_"..nodeid.."_fence.png",
paramtype = "light",
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
end
end
SIGNLIKE = function(nodeid, light)
light = light or 0
minetest.register_node("madblocks:signs_"..nodeid, {
description = "Sign",
drawtype = "signlike",
tile_images = {"madblocks_signs_"..nodeid..".png"},
inventory_image = "madblocks_signs_"..nodeid..".png",
wield_image = "madblocks_signs_"..nodeid..".png",
paramtype = "light",
paramtype2 = "wallmounted",
is_ground_content = true,
walkable = false,
climbable = false,
selection_box = {
type = "wallmounted",
},
light_source = light ,
light_propagates = true,
sunlight_propagates = true,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=2},
legacy_wallmounted = true,
sounds = default.node_sound_stone_defaults(),
})
end
PLANTLIKE = function(nodeid, nodename,type,option)
if option == nil then option = false end
local params ={ description = nodename, drawtype = "plantlike", tile_images = {"madblocks_"..nodeid..'.png'},
inventory_image = "madblocks_"..nodeid..'.png', wield_image = "madblocks_"..nodeid..'.png', paramtype = "light", }
if type == 'veg' then
params.groups = {snappy=2,dig_immediate=3,flammable=2}
params.sounds = default.node_sound_leaves_defaults()
if option == false then params.walkable = false end
elseif type == 'met' then -- metallic
params.groups = {cracky=3}
params.sounds = default.node_sound_stone_defaults()
elseif type == 'cri' then -- craft items
params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
params.sounds = default.node_sound_wood_defaults()
if option == false then params.walkable = false end
elseif type == 'eat' then -- edible
params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
params.sounds = default.node_sound_wood_defaults()
params.walkable = false
params.on_use = minetest.item_eat(option)
end
minetest.register_node("madblocks:"..nodeid, params)
end
-- ***********************************************************************************
-- STANDARD DEFS **************************************************
-- ***********************************************************************************
BRICKLIKE('bluecyanbrick', 'Blue-Cyan Odd Brick')
BRICKLIKE('magentabrick','Magenta Brick')
BRICKLIKE('greenbrick','Green Brick')
BRICKLIKE('blackbrick','Black Brick')
BRICKLIKE('bluebrick','Blue Brick')
BRICKLIKE('yellowbrick','Yellow Brick')
BRICKLIKE('brownbrick','Brown Brick')
BRICKLIKE('cyanbrick','Cyan Brick')
BRICKLIKE('oddbrick','Oddly Coloured Brick')
BRICKLIKE('mossystonebrick','Mossy Stone Brick')
BRICKLIKE('culturedstone','Cultured Stone')
BRICKLIKE('marblestonebrick','Marble Stone Brick')
BRICKLIKE('shinystonebrick','Sand-Blasted Stone Brick')
BRICKLIKE('cinderblock','Cinderblock')
BRICKLIKE('blackstonebrick','Black Stonebrick')
BRICKLIKE('roundstonebrick','Round Stonebrick')
BRICKLIKE('slimstonebrick','Slim Stonebrick')
BRICKLIKE('greystonebrick','Grey Stonebrick')
BRICKLIKE('medistonebrick','Mediterranean Stonebrick')
BRICKLIKE('whitestonebrick','White Stonebrick')
BRICKLIKE('cement','Cement')
BRICKLIKE('countrystonebrick','Country Stonebrick')
BRICKLIKE('asphalte','Asphalte')
WOODLIKE('woodshingles','Wood Shingles')
WOODLIKE('magentawood','Magenta Stained Wood',true)
WOODLIKE('bluewood','Blue Stained Wood',true)
WOODLIKE('blackwood','Black Stained Wood',true)
WOODLIKE('yellowwood','Yellow Stained Wood',true)
WOODLIKE('cyanwood','Cyan Stained Wood',true)
WOODLIKE('greenwood','Green Stained Wood',true)
WOODLIKE('redwood','Red Stained Wood',true)
WOODLIKE('dye_cyan','Cyan Dye')
WOODLIKE('dye_magenta','Magenta Dye')
WOODLIKE('dye_yellow','Yellow Dye')
WOODLIKE('dye_red','Red Dye')
WOODLIKE('dye_blue','Blue Dye')
WOODLIKE('dye_green','Green Dye')
WOODLIKE('dye_black','Black Dye')
SIGNLIKE('park')
SIGNLIKE('cliff')
SIGNLIKE('interdit')
SIGNLIKE('montreal')
SIGNLIKE('420')
SIGNLIKE('chicken')
SIGNLIKE('obscene')
SIGNLIKE('cafe',7)
SIGNLIKE('drpepper')
SIGNLIKE('dangermines')
SIGNLIKE('hucksfoodfuel')
SIGNLIKE('enjoycoke')
PLANTLIKE('flowers1','Flower Arrangement #1','veg')
PLANTLIKE('flowers2','Flower Arrangement #2','veg')
PLANTLIKE('hangingflowers','Hanging Flower Basket','cri')
PLANTLIKE('stool','Bar Stool','cri',true)
PLANTLIKE('gnome','Garden Gnome','cri')
PLANTLIKE('statue','Statuette','cri')
PLANTLIKE('gargoyle','Gargoyle','cri')
PLANTLIKE('wine','Wine Bottle','eat',1)
PLANTLIKE('coffeecup','Coffee Cup','eat',2)
-- ***********************************************************************************
-- ASSORTED DEFS **************************************************
-- ***********************************************************************************
minetest.register_node("madblocks:drum", {
description = "Drum",
drawtype = 'plantlike',
tile_images = {"madblocks_drum.png"},
inventory_image = "madblocks_drum.png",
wield_image = "madblocks_drum.png",
paramtype = "light",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Chest")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
on_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
" moves stuff in chest at "..minetest.pos_to_string(pos))
return minetest.node_metadata_inventory_move_allow_all(
pos, from_list, from_index, to_list, to_index, count, player)
end,
on_metadata_inventory_offer = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" moves stuff to chest at "..minetest.pos_to_string(pos))
return minetest.node_metadata_inventory_offer_allow_all(
pos, listname, index, stack, player)
end,
on_metadata_inventory_take = function(pos, listname, index, count, player)
minetest.log("action", player:get_player_name()..
" takes stuff from chest at "..minetest.pos_to_string(pos))
return minetest.node_metadata_inventory_take_allow_all(
pos, listname, index, count, player)
end,
})
minetest.register_node("madblocks:barrel", {
description = "Barrel",
drawtype = 'plantlike',
tile_images = {"madblocks_barrel.png"},
inventory_image = "madblocks_barrel.png",
wield_image = "madblocks_barrel.png",
paramtype = "light",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Chest")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
on_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player)
minetest.log("action", player:get_player_name()..
" moves stuff in chest at "..minetest.pos_to_string(pos))
return minetest.node_metadata_inventory_move_allow_all(
pos, from_list, from_index, to_list, to_index, count, player)
end,
on_metadata_inventory_offer = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name()..
" moves stuff to chest at "..minetest.pos_to_string(pos))
return minetest.node_metadata_inventory_offer_allow_all(
pos, listname, index, stack, player)
end,
on_metadata_inventory_take = function(pos, listname, index, count, player)
minetest.log("action", player:get_player_name()..
" takes stuff from chest at "..minetest.pos_to_string(pos))
return minetest.node_metadata_inventory_take_allow_all(
pos, listname, index, count, player)
end,
})
minetest.register_node("madblocks:pylon", {
description = "Pylon",
drawtype = "glasslike",
tile_images = {"madblocks_power_pylon.png"},
inventory_image = minetest.inventorycube("madblocks_power_pylon.png"),
paramtype = "light",
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("madblocks:safetyladder", {
description = "Ladder",
drawtype = "signlike",
tile_images = {"madblocks_power_polepegs.png"},
inventory_image = "madblocks_power_polepegs.png",
wield_image = "madblocks_power_polepegs.png",
paramtype = "light",
paramtype2 = "wallmounted",
is_ground_content = true,
walkable = false,
climbable = true,
selection_box = { type = "wallmounted" },
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=2},
legacy_wallmounted = true,
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node(":madblocks:lampling", {
description = "Lampling",
drawtype = "plantlike",
visual_scale = 1.0,
tile_images = {"madblocks_lampling.png"},
inventory_image = "madblocks_lampling.png",
wield_image = "madblocks_lampling.png",
paramtype = "light",
walkable = false,
groups = {snappy=2,dig_immediate=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("madblocks:sheetmetal", {
description = "Sheet Metal",
tile_images = {"madblocks_sheetmetal_top.png","madblocks_sheetmetal_top.png","madblocks_sheetmetal.png"},
is_ground_content = true,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=2},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("madblocks:rosebush", {
description = "Rose Bush",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tile_images = {"madblocks_rosebush.png"},
paramtype = "light",
groups = {snappy=3, flammable=2},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("madblocks:rubber", {
paramtype2 = "facedir",
legacy_facedir_simple = true,
description = "Rubber",
tile_images = { "madblocks_rubber_ends.png", "madblocks_rubber_ends.png", "madblocks_rubber_side.png"},
light_propagates = true,
paramtype = "light",
sunlight_propagates = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("madblocks:bigben", {
description = "Big Ben",
tile_images = {"madblocks_bigben_top.png","madblocks_bigben_top.png","madblocks_bigben.png"},
is_ground_content = true,
groups = {snappy=2,choppy=3,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("madblocks:coffee", {
description = "Roasted Coffee",
tile_images = {"madblocks_coffee.png"},
inventory_image = minetest.inventorycube("madblocks_coffee.png"),
is_ground_content = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("madblocks:fancybracket", {
description = "Fancy Support Bracket",
drawtype = "torchlike",
tile_images = {"madblocks_fancybracket.png", "madblocks_fancybracket.png", "madblocks_fancybracket.png"},
inventory_image = "madblocks_fancybracket.png",
wield_image = "madblocks_fancybracket.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
selection_box = {
type = "wallmounted",
wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
},
groups = {choppy=2,dig_immediate=3,flammable=1},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
})
minetest.register_node("madblocks:cinderblock_planter", {
description = "Cinderblock Planter",
tile_images = {"madblocks_cinderblock_planter.png","madblocks_cinderblock.png"},
inventory_image = minetest.inventorycube("madblocks_cinderblock_planter.png","madblocks_cinderblock.png","madblocks_cinderblock.png"),
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("madblocks:awning", {
drawtype = "raillike",
visual_scale = 1.0,
paramtype = "light",
description = "Awning",
tile_images = {"madblocks_awning.png","madblocks_awning2.png"},
inventory_image = "madblocks_awning.png",
light_propagates = true,
sunlight_propagates = true,
is_ground_content = true,
groups = {cracky=3},
})

187
lights.lua Normal file
View File

@ -0,0 +1,187 @@
-- ***********************************************************************************
-- FUNCTIONS **************************************************
-- ***********************************************************************************
searchlight = function(pos)
for i = 1, 30, 1 do
local xm = {x=pos.x-i,y=pos.y-i,z=pos.z}
local xp = {x=pos.x+i,y=pos.y-i,z=pos.z}
local zm = {x=pos.x,y=pos.y-i,z=pos.z-i}
local zp = {x=pos.x,y=pos.y-i,z=pos.z+i}
local xmn = minetest.env:get_node_or_nil(xm)
local xpn = minetest.env:get_node_or_nil(xp)
local zmn = minetest.env:get_node_or_nil(zm)
local zpn = minetest.env:get_node_or_nil(zp)
if xmn ~= nil and xmn.name == "air" then
minetest.env:add_node(xm,{type="node",name='madblocks:light'})
end
if xpn ~= nil and xpn.name == "air" then
minetest.env:add_node(xp,{type="node",name='madblocks:light'})
end
if zmn ~= nil and zmn.name == "air" then
minetest.env:add_node(zm,{type="node",name='madblocks:light'})
end
if zpn ~= nil and zpn.name == "air" then
minetest.env:add_node(zp,{type="node",name='madblocks:light'})
end
end
end
searchlight_off = function(pos)
for i = 1, 30, 1 do
local xm = {x=pos.x-i,y=pos.y-i,z=pos.z}
local xp = {x=pos.x+i,y=pos.y-i,z=pos.z}
local zm = {x=pos.x,y=pos.y-i,z=pos.z-i}
local zp = {x=pos.x,y=pos.y-i,z=pos.z+i}
local xmn = minetest.env:get_node_or_nil(xm)
local xpn = minetest.env:get_node_or_nil(xp)
local zmn = minetest.env:get_node_or_nil(zm)
local zpn = minetest.env:get_node_or_nil(zp)
if xmn ~= nil and xmn.name == 'madblocks:light' then
minetest.env:remove_node(xm)
end
if xpn ~= nil and xpn.name == 'madblocks:light' then
minetest.env:remove_node(xp)
end
if zmn ~= nil and zmn.name == 'madblocks:light' then
minetest.env:remove_node(zm)
end
if zpn ~= nil and zpn.name == 'madblocks:light' then
minetest.env:remove_node(zp)
end
end
end
spotlight = function(pos,node)
for i = 1, 19, 1 do
local ontop = {x=pos.x,y=pos.y+i,z=pos.z}
local is_air = minetest.env:get_node_or_nil(ontop)
if is_air ~= nil and is_air.name == "air" then
minetest.env:add_node(ontop,{type="node",name='madblocks:light'})
end
end
end
spotlight_off = function(pos,node)
for i = 1, 19, 1 do
local ontop = {x=pos.x,y=pos.y+i,z=pos.z}
local is_air = minetest.env:get_node_or_nil(ontop)
if is_air ~= nil and is_air.name == 'madblocks:light' then
minetest.env:remove_node(ontop)
end
end
end
GLOWLIKE = function(nodeid,nodename,drawtype)
if drawtype == nil then
drawtype = 'glasslike'
inv_image = minetest.inventorycube("madblocks_"..nodeid..".png")
else
inv_image = "madblocks_"..nodeid..".png"
end
minetest.register_node("madblocks:"..nodeid, {
description = nodename,
drawtype = drawtype,
tile_images = {"madblocks_"..nodeid..".png"},
inventory_image = inv_image,
light_propagates = true,
paramtype = "light",
sunlight_propagates = true,
light_source = 15 ,
is_ground_content = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
end
-- ***********************************************************************************
-- DEFS **************************************************
-- ***********************************************************************************
GLOWLIKE('glowyellow','Yellow Glow Glass')
GLOWLIKE('glowgreen','Green Glow Glass')
GLOWLIKE('glowblue','Blue Glow Glass')
GLOWLIKE('glowred','Red Glow Glass')
GLOWLIKE('glowtron','Tron Glow Glass')
GLOWLIKE('fancylamp','Fancy Lamp','plantlike')
minetest.register_node("madblocks:light", {
drawtype = "glasslike",
tile_images = {"madblocks_spotlights_inv.png"},
inventory_image = minetest.inventorycube("madblocks_spotlights_inv.png"),
paramtype = "light",
walkable = false,
is_ground_content = true,
light_propagates = true,
sunlight_propagates = true,
light_source = 15 ,
selection_box = {
type = "fixed",
fixed = {0, 0, 0, 0, 0, 0},
},
})
minetest.register_node("madblocks:searchlight", {
description = 'Searchlight',
drawtype = "plantlike",
tile_images = {'madblocks_searchlight.png'},
inventory_image = 'madblocks_searchlight.png',
wield_image = 'madblocks_searchlight.png',
paramtype = "light",
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
drop = 'madblocks:searchlight_off',
on_punch = function(pos,node)
searchlight_off(pos)
minetest.env:add_node(pos, {name='madblocks:searchlight_off'})
end,
on_dig = function(pos,node)
searchlight_off(pos)
end,
})
minetest.register_node("madblocks:searchlight_off", {
description = 'Searchlight',
drawtype = "plantlike",
tile_images = {'madblocks_searchlight.png'},
inventory_image = 'madblocks_searchlight.png',
wield_image = 'madblocks_searchlight.png',
paramtype = "light",
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
on_punch = function(pos,node)
searchlight(pos)
minetest.env:add_node(pos, {name='madblocks:searchlight'})
end,
})
minetest.register_node("madblocks:spotlight", {
description = "Spotlight",
tile_images = { "madblocks_spotlights_top.png", "madblocks_spotlights_side.png", "madblocks_spotlights_side.png"},
inventory_image = minetest.inventorycube("madblocks_spotlights_top.png","madblocks_spotlights_side.png","madblocks_spotlights_side.png"),
paramtype2 = "facedir",
light_propagates = true,
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3},
drop = 'madblocks:spotlight_off',
on_punch = function(pos,node)
spotlight_off(pos)
minetest.env:add_node(pos, {name='madblocks:spotlight_off'})
end,
on_dig = function(pos,node)
spotlight_off(pos)
end,
})
minetest.register_node("madblocks:spotlight_off", {
description = "Spotlight",
tile_images = { "madblocks_spotlights_top.png", "madblocks_spotlights_side.png", "madblocks_spotlights_side.png"},
inventory_image = minetest.inventorycube("madblocks_spotlights_top.png","madblocks_spotlights_side.png","madblocks_spotlights_side.png"),
paramtype2 = "facedir",
light_propagates = true,
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3},
on_punch = function(pos,node)
spotlight(pos)
minetest.env:add_node(pos, {name='madblocks:spotlight'})
end,
})

378
misc.lua Normal file
View File

@ -0,0 +1,378 @@
-- ***********************************************************************************
-- SOUND NODES **************************************************
-- ***********************************************************************************
SOUNDS = {}
SOUNDNODE = function(nodeid, nodename,drawtype)
SOUNDS[nodeid] = {}
SOUNDS[nodeid].sounds = {}
local on_punch = function(pos,node)
local sound = SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)]
if sound == nil then
local wanted_sound = {name=nodeid, gain=1.5}
SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)] = { handle = minetest.sound_play(wanted_sound, {pos=pos, loop=true}), name = wanted_sound.name, }
else
minetest.sound_stop(sound.handle)
SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)] = nil
end
end
after_dig_node = function(pos,node)
local sound = SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)]
if sound ~= nil then
minetest.sound_stop(sound.handle)
SOUNDS[nodeid].sounds[minetest.hash_node_position(pos)] = nil
nodeupdate(pos)
end
end
if drawtype == 'signlike' then
minetest.register_node("madblocks:"..nodeid, {
description = nodename,
drawtype = "signlike",
tile_images = {"madblocks_"..nodeid..'.png'},
inventory_image = "madblocks_"..nodeid..'.png',
wield_image = "madblocks_"..nodeid..'.png',
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
metadata_name = "sign",
selection_box = {
type = "wallmounted",
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
},
groups = {choppy=2,dig_immediate=2},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
on_punch = on_punch,
after_dig_node = after_dig_node,
})
elseif drawtype == '' then
minetest.register_node("madblocks:"..nodeid, {
description = nodename,
drawtype = 'plantlike',
tile_images = {"madblocks_"..nodeid..'.png'},
inventory_image = "madblocks_"..nodeid..'.png',
wield_image = "madblocks_"..nodeid..'.png',
paramtype = "light",
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
on_punch = on_punch,
after_dig_node = after_dig_node,
})
end
end
SOUNDNODE('siren','Loud Siren')
SOUNDNODE('churchbells','Church Bells')
local bigben = {}
bigben.sounds = {}
bigben_sound = function(p)
local wanted_sound = {name="bigbenshort", gain=1.5}
bigben.sounds[minetest.hash_node_position(p)] = {
handle = minetest.sound_play(wanted_sound, {pos=p, loop=false}),
name = wanted_sound.name,
}
end
minetest.register_abm({
nodenames = {'madblocks:bigben'},
interval = 60,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
bigben_sound(pos)
end
})
-- ***********************************************************************************
-- FIREPLACE **************************************************
-- ***********************************************************************************
local fireplace = {}
fireplace.D = 1
fireplace.sounds = {}
function fireplace.get_area_p0p1(pos)
local p0 = {
x=math.floor(pos.x/fireplace.D)*fireplace.D,
y=math.floor(pos.y/fireplace.D)*fireplace.D,
z=math.floor(pos.z/fireplace.D)*fireplace.D,
}
local p1 = {
x=p0.x+fireplace.D-1,
y=p0.y+fireplace.D-1,
z=p0.z+fireplace.D-1
}
return p0, p1
end
function fireplace.update_sounds_around(pos)
local p0, p1 = fireplace.get_area_p0p1(pos)
local cp = {x=(p0.x+p1.x)/2, y=(p0.y+p1.y)/2, z=(p0.z+p1.z)/2}
local flames_p = minetest.env:find_nodes_in_area(p0, p1, {"madblocks:basic_flame"})
local should_have_sound = (#flames_p > 0)
local wanted_sound = nil
if #flames_p >= 9 then
wanted_sound = {name="fire_large", gain=1.5}
elseif #flames_p > 0 then
wanted_sound = {name="fire_small", gain=1.5}
end
local p0_hash = minetest.hash_node_position(p0)
local sound = fireplace.sounds[p0_hash]
if not sound then
if should_have_sound then
fireplace.sounds[p0_hash] = {
handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}),
name = wanted_sound.name,
}
end
else
if not wanted_sound then
minetest.sound_stop(sound.handle)
fireplace.sounds[p0_hash] = nil
elseif sound.name ~= wanted_sound.name then
minetest.sound_stop(sound.handle)
fireplace.sounds[p0_hash] = {
handle = minetest.sound_play(wanted_sound, {pos=cp, loop=true}),
name = wanted_sound.name,
}
end
end
end
function fireplace.on_flame_add_at(pos)
fireplace.update_sounds_around(pos)
end
function fireplace.on_flame_remove_at(pos)
fireplace.update_sounds_around(pos)
end
minetest.register_abm({
nodenames = { "madblocks:fireplace" },
interval = 5,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local xm = {x=pos.x-1,y=pos.y,z=pos.z}
local xp = {x=pos.x+1,y=pos.y,z=pos.z}
local zm = {x=pos.x,y=pos.y,z=pos.z-1}
local zp = {x=pos.x,y=pos.y,z=pos.z+1}
local xmnode = minetest.env:get_node(xm)
local xpnode = minetest.env:get_node(xp)
local zmnode = minetest.env:get_node(zm)
local zpnode = minetest.env:get_node(zp)
if xpnode.name == 'default:cobble' or
xmnode.name == 'default:cobble' then -- build along Z axis
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="madblocks:log"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="madblocks:basic_flame"})
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z-1},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z-1},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z-1},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z+1},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z+1},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z+1},{type="node",name="default:cobble"})
elseif zpnode.name == 'default:cobble' or
zmnode.name == 'default:cobble' then -- build along x axis
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="madblocks:log"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="madblocks:basic_flame"})
minetest.env:add_node({x=pos.x-1,y=pos.y,z=pos.z},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x-1,y=pos.y+1,z=pos.z},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x-1,y=pos.y+2,z=pos.z},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x+1,y=pos.y+2,z=pos.z},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x+1,y=pos.y+1,z=pos.z},{type="node",name="default:cobble"})
minetest.env:add_node({x=pos.x+1,y=pos.y,z=pos.z},{type="node",name="default:cobble"})
end
fireplace.update_sounds_around({x=pos.x,y=pos.y+1,z=pos.z})
end
})
minetest.register_node(":madblocks:log", {
description = "Fire Log",
tile_images = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
is_ground_content = true,
groups = {tree=1,snappy=2,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
on_punch = function(p,node)
fire_above = {x = p.x, y= p.y+1, z = p.z}
isflame = minetest.env:get_node(fire_above)
if isflame.name == 'air' then
minetest.env:add_node(fire_above,{type="node",name="madblocks:basic_flame"})
elseif isflame.name == "madblocks:basic_flame" then
minetest.env:remove_node(fire_above)
end
fireplace.update_sounds_around({x=p.x,y=p.y+1,z=p.z})
end,
after_dig_node = function(p,node)
fire_above = {x = p.x, y= p.y+1, z = p.z}
isflame = minetest.env:get_node(fire_above)
if isflame.name == "madblocks:basic_flame" then
minetest.env:remove_node(fire_above)
end
fireplace.update_sounds_around({x=p.x,y=p.y+1,z=p.z})
end,
})
minetest.register_node(":madblocks:basic_flame", {
description = "Fire",
drawtype = "glasslike",
tile_images = {"fire_basic_flame.png"},
light_source = 14,
groups = {dig_immediate=3},
drop = '',
walkable = false,
after_place_node = function(pos, node)
fireplace.on_flame_add_at(pos)
end,
on_dig = function(pos,node)
fireplace.on_flame_remove_at(pos)
end,
})
minetest.register_node(":madblocks:fireplace", {
description = "Fireplace",
tile_images = {"default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png","default_cobble.png","madblocks_fireplace.png"},
inventory_image = minetest.inventorycube("default_cobble.png","madblocks_fireplace.png","default_cobble.png"),
light_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
light_source = 10,
material = minetest.digprop_glasslike(1.0),
groups = {cracky=3},
})
minetest.register_craft({
output = 'madblocks:fireplace 1',
recipe = {
{'default:cobble','default:cobble','default:cobble'},
{'default:cobble','default:torch','default:cobble'},
{'default:cobble','default:tree','default:cobble'},
}
})
-- ***********************************************************************************
-- LAMPLING **************************************************
-- ***********************************************************************************
minetest.register_abm({
nodenames = { "madblocks:lampling" },
interval = 60,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="madblocks:blackwood_fence"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="madblocks:blackwood_fence"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="madblocks:blackwood_fence"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="madblocks:blackwood_fence"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="madblocks:glowyellow"})
end
})
-- ***********************************************************************************
-- STREETS **************************************************
-- ***********************************************************************************
minetest.register_node(":madblocks:street", {
description = "Street Builder",
tile_images = {"madblocks_street.png"},
inventory_image = minetest.inventorycube("madblocks_street.png"),
light_propagates = true,
paramtype = "light",
sunlight_propagates = true,
light_source = 10,
material = minetest.digprop_glasslike(1.0),
groups = {cracky=3},
on_punch = function(pos,node)
local xm = {x=pos.x-1,y=pos.y,z=pos.z}
local xp = {x=pos.x+1,y=pos.y,z=pos.z}
local zm = {x=pos.x,y=pos.y,z=pos.z-1}
local zp = {x=pos.x,y=pos.y,z=pos.z+1}
local xmnode = minetest.env:get_node(xm)
local xpnode = minetest.env:get_node(xp)
local zmnode = minetest.env:get_node(zm)
local zpnode = minetest.env:get_node(zp)
if xpnode.name ~= "air" and xmnode.name == "air" and zpnode.name == "air" and zmnode.name == "air" and
xpnode.name ~= "madblocks:replicator" and xpnode.name ~= "madblocks:mk2" and xpnode.name ~= "madblocks:street" then
for i = 0, 9, 1 do
local xmin = pos.x-(i+1)
local corner1 = {x=pos.x+2,y=pos.y,z=pos.z+2}
local corner2 = {x=pos.x+2,y=pos.y,z=pos.z-2}
c1node = minetest.env:get_node(corner1)
c2node = minetest.env:get_node(corner2)
if i == 0 then
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z-1},{type="node",name=xpnode.name})
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z+1},{type="node",name=xpnode.name})
end
minetest.env:add_node({x=xmin,y=pos.y,z=pos.z},{type="node",name=xpnode.name})
minetest.env:add_node({x=xmin,y=pos.y,z=pos.z-1},{type="node",name=xpnode.name})
minetest.env:add_node({x=xmin,y=pos.y,z=pos.z+1},{type="node",name=xpnode.name})
if i == 9 then
minetest.env:add_node({x=xmin,y=pos.y,z=pos.z+2},{type="node",name=xpnode.name})
minetest.env:add_node({x=xmin,y=pos.y+1,z=pos.z+2},{type="node", name="madblocks:lampling"})
end
end
elseif xmnode.name ~= "air" and xpnode.name == "air" and zpnode.name == "air" and zmnode.name == "air" and
xmnode.name ~= "madblocks:replicator" and xmnode.name ~= "madblocks:mk2" and xmnode.name ~= "madblocks:street" then
for i = 0, 9, 1 do
local xplu = pos.x+(i+1)
local corner1 = {x=pos.x-2,y=pos.y,z=pos.z+2}
local corner2 = {x=pos.x-2,y=pos.y,z=pos.z-2}
c1node = minetest.env:get_node(corner1)
c2node = minetest.env:get_node(corner2)
if i == 0 then
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z-1},{type="node",name=xmnode.name})
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z+1},{type="node",name=xmnode.name})
end
minetest.env:add_node({x=xplu,y=pos.y,z=pos.z},{type="node",name=xmnode.name})
minetest.env:add_node({x=xplu,y=pos.y,z=pos.z-1},{type="node",name=xmnode.name})
minetest.env:add_node({x=xplu,y=pos.y,z=pos.z+1},{type="node",name=xmnode.name})
if i == 9 then
minetest.env:add_node({x=xplu,y=pos.y,z=pos.z+2},{type="node",name=xmnode.name})
minetest.env:add_node({x=xplu,y=pos.y+1,z=pos.z+2},{type="node",name="madblocks:lampling"})
end
end
elseif zpnode.name ~= "air" and zmnode.name == "air" and xpnode.name == "air" and xmnode.name == "air" and
zpnode.name ~= "madblocks:replicator" and zpnode.name ~= "madblocks:mk2" and zpnode.name ~= "madblocks:street" then
for i = 0, 9, 1 do
local zmin = pos.z-(i+1)
local corner1 = {x=pos.x+2,y=pos.y,z=pos.z+2}
local corner2 = {x=pos.x-2,y=pos.y,z=pos.z+2}
c1node = minetest.env:get_node(corner1)
c2node = minetest.env:get_node(corner2)
if i == 0 then
minetest.env:add_node({x=pos.x-1,y=pos.y,z=pos.z},{type="node",name=zpnode.name})
minetest.env:add_node({x=pos.x+1,y=pos.y,z=pos.z},{type="node",name=zpnode.name})
end
minetest.env:add_node({x=pos.x,y=pos.y,z=zmin},{type="node",name=zpnode.name})
minetest.env:add_node({x=pos.x-1,y=pos.y,z=zmin},{type="node",name=zpnode.name})
minetest.env:add_node({x=pos.x+1,y=pos.y,z=zmin},{type="node",name=zpnode.name})
if i == 9 then
minetest.env:add_node({x=pos.x+2,y=pos.y,z=zmin},{type="node",name=zpnode.name})
minetest.env:add_node({x=pos.x+2,y=pos.y+1,z=zmin},{type="node",name="madblocks:lampling"})
end
end
elseif zmnode.name ~= "air" and zpnode.name == "air" and xpnode.name == "air" and xmnode.name == "air" and
zmnode.name ~= "madblocks:replicator" and zmnode.name ~= "madblocks:mk2" and zmnode.name ~= "madblocks:street" then
for i = 0, 9, 1 do
local zplu = pos.z+(i+1)
local corner1 = {x=pos.x+2,y=pos.y,z=pos.z-2}
local corner2 = {x=pos.x-2,y=pos.y,z=pos.z-2}
c1node = minetest.env:get_node(corner1)
c2node = minetest.env:get_node(corner2)
if i == 0 then
minetest.env:add_node({x=pos.x-1,y=pos.y,z=pos.z},{type="node",name=zmnode.name})
minetest.env:add_node({x=pos.x+1,y=pos.y,z=pos.z},{type="node",name=zmnode.name})
end
minetest.env:add_node({x=pos.x,y=pos.y,z=zplu},{type="node",name=zmnode.name})
minetest.env:add_node({x=pos.x-1,y=pos.y,z=zplu},{type="node",name=zmnode.name})
minetest.env:add_node({x=pos.x+1,y=pos.y,z=zplu},{type="node",name=zmnode.name})
if i == 9 then
minetest.env:add_node({x=pos.x+2,y=pos.y,z=zplu},{type="node",name=zmnode.name})
minetest.env:add_node({x=pos.x+2,y=pos.y+1,z=zplu},{type="node",name="madblocks:lampling"})
end
end
nodeupdate(pos)
end
end,
})

399
multinode.lua Normal file
View File

@ -0,0 +1,399 @@
MN1 = {}
MN2 = {}
MN1CACHE = {}
MN2CACHE = {}
COPY = {}
COPYREF = {}
PASTEREF ={}
REPLACE = {}
WITH = {}
ACTIONNODE = function(nodeid, nodename,onplace,ondig)
local params = {
description = nodename,
tile_images = {"madblocks_"..nodeid..".png"},
inventory_image = minetest.inventorycube("madblocks_"..nodeid..".png"),
is_ground_content = true,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
}
if onplace ~= nil then params.after_place_node = onplace end
if ondig ~= nil then params.after_dig_node = ondig end
minetest.register_node("madblocks:"..nodeid, params)
end
ACTIONNODE('m1','Multinode Marker 1', function(pos,placer)
local player = placer:get_player_name()-- or ""
if player == '' then print('errorm1') end
if MN1[player] == nil then MN1[player] = {} end
table.insert(MN1[player], pos)
minetest.chat_send_player(player, "marker 1 set")
end)
ACTIONNODE('m2','Multinode Marker 2', function(pos,placer)
local player = placer:get_player_name()-- or ""
if player == '' then print('errorm2') end
if MN2[player] == nil then MN2[player] = {} end
table.insert(MN2[player], pos)
minetest.chat_send_player(player, "marker 2 set")
end)
ACTIONNODE('pasteref','Paste Reference Marker', function(pos,placer)
local player = placer:get_player_name()-- or ""
if player == '' then print('errorm2') end
PASTEREF[player] = pos
minetest.chat_send_player(player, "paste reference set")
end)
-- ***********************************************************************************
-- FUNCTIONS **************************************************
-- ***********************************************************************************
compare = function(p1,p2)
result = {}
if p1 > p2 then
result.high = p1
result.low = p2
result.diff = p1 - p2
elseif p2 > p1 then
result.high = p2
result.low = p1
result.diff = p2 - p1
else
result.high = p2
result.low = p1
result.diff = 0
end
if result.diff < 0 then
result.diff = -result.diff
result.mul = -1
else result.mul = 1 end
return result
end
local fixlight = function(p)
local no = minetest.env:get_node(p)
no.param1 = 13
minetest.env:add_node(p, no)
end
local fillnode = function(pos,param)
if param == '-light' then
fixlight(pos)
else
minetest.env:add_node(pos,{type="node",name=param})
end
end
local removenode = function(pos,param)
if param == '-a' then
minetest.env:remove_node(pos)
else
local node = minetest.env:get_node_or_nil(pos)
if node and node.name == param then minetest.env:remove_node(pos) end
end
end
local copynode = function(pos,param)
local node = minetest.env:get_node_or_nil(pos)
if node then table.insert(COPY[param],{pos=pos,name=node.name}) end
end
local replacenode = function(pos,param)
local node = minetest.env:get_node_or_nil(pos)
if node and node.name == REPLACE[param] then minetest.env:add_node(pos,{type="node",name=WITH[param]}) end
end
local multinode = function(p1,p2,mutation,param)
local xdif = compare(p1.x,p2.x)
local ydif = compare(p1.y,p2.y)
local zdif = compare(p1.z,p2.z)
if mutation == copynode then COPYREF[param] = p1 end
if xdif.diff > 0 then
for q =0,xdif.diff,1 do
mutation({x=xdif.high-q*xdif.mul,y=ydif.high,z=zdif.high},param)
if ydif.diff > 0 then
for m =0,ydif.diff,1 do
mutation({x=xdif.high-q*xdif.mul,y=ydif.high-m*ydif.mul,z=zdif.high},param)
if zdif.diff > 0 then
for i =0,zdif.diff,1 do
mutation({x=xdif.high-q*xdif.mul,y=ydif.high-m*ydif.mul,z=zdif.high-i*zdif.mul},param)
end
end
end
elseif zdif.diff > 0 then
for i =0,zdif.diff,1 do
mutation({x=xdif.high-q*xdif.mul,y=ydif.high,z=zdif.high-i*zdif.mul},param)
end
end
end
elseif ydif.diff > 0 then
for m =0,ydif.diff,1 do
mutation({x=xdif.high,y=ydif.high-m*ydif.mul,z=zdif.high},param)
if zdif.diff > 0 then
for i =0,zdif.diff,1 do
mutation({x=xdif.high,y=ydif.high-m*ydif.mul,z=zdif.high-i*zdif.mul},param)
end
end
end
elseif zdif.diff > 0 then
for i =0,zdif.diff,1 do
mutation({x=xdif.high,y=ydif.high,z=zdif.high-i*zdif.mul},param)
end
else
return false
end
end
-- ***********************************************************************************
-- CHATCOMMANDS **************************************************
-- ***********************************************************************************
minetest.register_chatcommand("reload", {
params = "<none>",
description = "restore last multinode list",
privs = {server=true},
func = function(name, param)
MN1[name] = MN1CACHE[name]
MN2[name] = MN2CACHE[name]
end,
})
minetest.register_chatcommand("clear", {
params = "<none>",
description = "clear",
privs = {server=true},
func = function(name, param)
COPY[name] = {}
COPYREF[name] = {}
PASTEREF[name] = {}
REPLACE[name] = {}
WITH[name] = {}
MN1[name] = {}
MN2[name] = {}
end,
})
minetest.register_chatcommand("p1", {
params = "<X>,<Y>,<Z>",
description = "first corner",
privs = {server=true},
func = function(name, param)
if MN1[name] == nil then MN1[name] = {} end
local p = {}
p.x, p.y, p.z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
table.insert(MN1[name], p)
minetest.chat_send_player(name, "p1 set")
return
else
local target = minetest.env:get_player_by_name(name)
if target then
table.insert(MN1[name],target:getpos())
minetest.chat_send_player(name, "p1 set")
return
end
end
end,
})
minetest.register_chatcommand("p2", {
params = "<X>,<Y>,<Z>",
description = "opposite corner",
privs = {server=true},
func = function(name, param)
if MN2[name] == nil then MN2[name] = {} end
local p = {}
p.x, p.y, p.z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
table.insert(MN2[name], p)
minetest.chat_send_player(name, "p2 set")
return
else
local target = minetest.env:get_player_by_name(name)
if target then
table.insert(MN2[name], target:getpos())
minetest.chat_send_player(name, "p2 set")
return
end
end
end,
})
minetest.register_chatcommand("fill", {
params = "<nodename>",
description = "fill with given node",
privs = {server=true},
func = function(name, param)
if table.getn(MN1[name]) == 0 or table.getn(MN2[name]) == 0 or param == nil then
print('failed check 1')
return end
MN1CACHE[name] = MN1[name]--LASTFILL1 = FILL1
MN2CACHE[name] = MN2[name]--LASTFILL2 = FILL2
MN1[name] = {}
MN2[name] = {}
for a = 1,table.getn(MN1CACHE[name]),1 do
if MN1CACHE[name][a] == nil or MN2CACHE[name][a] == nil then print('failed check 2') return end
if multinode(MN1CACHE[name][a],MN2CACHE[name][a],fillnode,param) == false then minetest.chat_send_player(name, "there is no fill only zuul") end
end
end,
})
minetest.register_chatcommand("remove", {
params = "<nodename>",
description = "to remove specific node or use flag '-a'",
privs = {server=true},
func = function(name, param)
if table.getn(MN1[name]) == 0 or table.getn(MN2[name]) == 0 or param == nil then
print('failed check 1')
return end
MN1CACHE[name] = MN1[name]--LASTFILL1 = FILL1
MN2CACHE[name] = MN2[name]--LASTFILL2 = FILL2
MN1[name] = {}
MN2[name] = {}
for a = 1,table.getn(MN1CACHE[name]),1 do
if MN1CACHE[name][a] == nil or MN2CACHE[name][a] == nil then print('failed check 2') return end
if multinode(MN1CACHE[name][a],MN2CACHE[name][a],removenode,param) == false then minetest.chat_send_player(name, "there is no remove only zuul") end
end
end,
})
minetest.register_chatcommand("copy", {
params = "<none>",
description = "copy",
privs = {server=true},
func = function(name, param)
if MN1[name] == nil or MN2[name] == nil then minetest.chat_send_player(name, "a klingon that kills without showing his face, has no honor") return end
if table.getn(MN1[name]) == 0 or table.getn(MN2[name]) == 0 or param == nil then
print('failed check 1')
return end
MN1CACHE[name] = MN1[name]
MN2CACHE[name] = MN2[name]
MN1[name] = {}
MN2[name] = {}
if COPY[name] == nil then COPY[name] = {} end
if COPYREF[name] == nil then COPYREF[name] = {} end
for a = 1,table.getn(MN1CACHE[name]),1 do
if MN1CACHE[name][a] == nil or MN2CACHE[name][a] == nil then print('failed check 2') return end
if multinode(MN1CACHE[name][a],MN2CACHE[name][a],copynode,name) == false then minetest.chat_send_player(name, "there is no copy only zuul") end
end
end,
})
minetest.register_chatcommand("paste", {
params = "<none>",
description = "paste",
privs = {server=true},
func = function(name, param)
if PASTEREF[name] then
newpos = PASTEREF[name]
else
local target = minetest.env:get_player_by_name(name)
if target then
newpos = target:getpos()
end
end
difx = COPYREF[name].x - newpos.x
dify = COPYREF[name].y - newpos.y
difz = COPYREF[name].z - newpos.z
for a = 1,table.getn(COPY[name]),1 do
if param ~= '+90' and param ~= '-90' and param ~= '+180' then
pastepos = {x=COPY[name][a].pos.x-difx,y=COPY[name][a].pos.y-dify,z=COPY[name][a].pos.z-difz}
else
local x = COPY[name][a].pos.x -COPYREF[name].x
local y = COPY[name][a].pos.y
local z = COPY[name][a].pos.z -COPYREF[name].z
local newx,newz = nil
if param == '+90' then
newx = z
newz = -(x)
elseif param == '-90' then
newx = -(z)
newz = x
elseif param == '+180' then
newx = -(x)
newz = -(z)
else
return
end
x = newx + COPYREF[name].x
z = newz + COPYREF[name].z
pastepos = {x=x-difx,y=y-dify,z=z-difz}
end
minetest.env:add_node(pastepos,{type="node",name=COPY[name][a].name})
end
PASTEREF[name] = nil
end,
})
minetest.register_chatcommand("replace", {
params = "<none>",
description = "clear",
privs = {server=true},
func = function(name, param)
REPLACE[name] = param
end,
})
minetest.register_chatcommand("with", {
params = "<none>",
description = "clear",
privs = {server=true},
func = function(name, param)
WITH[name] = param
end,
})
minetest.register_chatcommand("doit", {
params = "<none>",
description = "clear",
privs = {server=true},
func = function(name, param)
if table.getn(MN1[name]) == 0 or table.getn(MN2[name]) == 0 then
print('failed check 1')
return end
MN1CACHE[name] = MN1[name]
MN2CACHE[name] = MN2[name]
MN1[name] = {}
MN2[name] = {}
for a = 1,table.getn(MN1CACHE[name]),1 do
if MN1CACHE[name][a] == nil or MN2CACHE[name][a] == nil then print('failed check 2') return end
if multinode(MN1CACHE[name][a],MN2CACHE[name][a],replacenode,name) == false then minetest.chat_send_player(name, "there is no replace only zuul") end
end
REPLACE[name] = nil
WITH[name] = nil
end,
})
minetest.register_chatcommand("saveas", {
params = "<bldname>",
description = "paste",
privs = {server=true},
func = function(name, param)
if COPY[name] == nil then minetest.chat_send_player(name, "a klingon that kills without showing his face, has no honor") return end
local output = '' -- WRITE CHANGES TO FILE
local f = io.open(minetest.get_modpath('madblocks')..'/buildings/'..param..'.bld', "w")
if f == nil then minetest.chat_send_player(name, "a klingon that kills without showing his face, has no honor") return end
for a = 1,table.getn(COPY[name]),1 do
local x = COPY[name][a].pos.x -COPYREF[name].x
local y = COPY[name][a].pos.y -COPYREF[name].y
local z = COPY[name][a].pos.z -COPYREF[name].z
output = output..COPY[name][a].name..'~'..x..','..y..','..z..';'
end
f:write(output)
io.close(f)
minetest.chat_send_player(name, param.." saved")
end,
})
minetest.register_chatcommand("load", {
params = "<bldname>",
description = "paste",
privs = {server=true},
func = function(name, param)
local bldfile = io.open(minetest.get_modpath('madblocks')..'/buildings/'..param..'.bld', "r")
if bldfile then
COPY[name] = {}
COPYREF[name] = {x=0,y=0,z=0}
local contents = bldfile:read()
io.close(bldfile)
if contents ~= nil then
local entries = contents:split(";")
for i,entry in pairs(entries) do
local nodename, coords = unpack(entry:split("~"))
local p = {}
p.x, p.y, p.z = string.match(coords, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
table.insert(COPY[name],{name = nodename, pos = {x = tonumber(p.x),y= tonumber(p.y),z = tonumber(p.z)}})
end
end
end
end
end,
})

413
nature.lua Normal file
View File

@ -0,0 +1,413 @@
-- ***********************************************************************************
-- SEASONAL CHANGES **************************************************
-- ***********************************************************************************
SEASON_FILE = minetest.get_worldpath()..'/madblocks.season'
local function set_season(t)
CURRENT_SEASON = t
-- write to file
local f = io.open(SEASON_FILE, "w")
f:write(CURRENT_SEASON)
io.close(f)
end
local f = io.open(SEASON_FILE, "r")
if f ~= nil then
CURRENT_SEASON = f:read("*n")
io.close(f)
else
print('could not find season file, creating one (setting winter).')
set_season(1)
end
switch_seasons = function()
if CURRENT_SEASON == 1 then
set_season(2) -- set to spring
print('changing to spring')
minetest.after(SEASON_LENGTH,switch_seasons)
elseif CURRENT_SEASON == 2 then
set_season(3) -- set to summer
print('changing to summer')
minetest.after(SEASON_LENGTH,switch_seasons)
elseif CURRENT_SEASON == 3 then
set_season(4) -- set to autumn
print('changing to autumn')
minetest.after(SEASON_LENGTH,switch_seasons)
elseif CURRENT_SEASON == 4 then
set_season(1) -- set to winter
print('changing to winter')
minetest.after(SEASON_LENGTH,switch_seasons)
end
end
minetest.after(SEASON_LENGTH,switch_seasons)
minetest.register_chatcommand("season", {
params = "<season>",
description = "set the season",
func = function(name, param)
if param == 'winter' or param == 'Winter' then set_season(1)
elseif param == 'spring' or param == 'Spring' then set_season(2)
elseif param == 'summer' or param == 'Summer' then set_season(3)
elseif param == 'fall' or param == 'Fall' then set_season(4)
elseif param == 'pause' or param == 'Pause' then set_season(0)
minetest.chat_send_player(name, "Season paused.")
return
else
minetest.chat_send_player(name, "Invalid paramater '"..param.."', try 'winter','spring','summer' or 'fall'.")
return
end
minetest.chat_send_player(name, "Season changed.")
end,
})
minetest.register_abm({
nodenames = { "default:dirt_with_grass","madblocks:grass_autumn",'madblocks:grass_winter',"madblocks:grass_spring",
'default:leaves','madblocks:leaves_autumn','madblocks:leaves_winter','madblocks:leaves_spring',
"default:water_source","default:water_flowing", "default:cactus","default:desert_sand","default:sand","madblocks:desertsand_winter", "madblocks:sand_winter","madblocks:cactus_winter",'madblocks:ice_source','madblocks:ice_flowing' },
interval = WEATHER_CHANGE_INTERVAL,
chance = 6,
action = function(pos, node, active_object_count, active_object_count_wider)
if CURRENT_SEASON == 1 then
if node.name == 'madblocks:grass_autumn' or node.name == 'default:dirt_with_grass' or node.name == 'madblocks:grass_spring' then
minetest.env:add_node(pos,{type="node",name='madblocks:grass_winter'})
elseif node.name == 'madblocks:leaves_autumn' or node.name == 'default:leaves' or node.name == 'madblocks:leaves_spring' then
minetest.env:add_node(pos,{type="node",name='madblocks:leaves_winter'})
elseif node.name == 'default:desert_sand' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='madblocks:desertsand_winter'})
end
elseif node.name == 'default:sand' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='madblocks:sand_winter'})
end
elseif node.name == 'default:cactus' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='madblocks:cactus_winter'})
end
elseif node.name == 'default:water_source' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='madblocks:ice_source'})
end
elseif node.name == 'default:water_flowing' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='madblocks:ice_flowing'})
end
end
elseif CURRENT_SEASON == 2 then
if node.name == 'madblocks:grass_winter' or node.name == 'madblocks:grass_autumn' or node.name == 'default:dirt_with_grass' then
minetest.env:add_node(pos,{type="node",name='madblocks:grass_spring'})
elseif node.name == 'madblocks:leaves_winter' or node.name == 'madblocks:leaves_autumn' or node.name == 'default:leaves' then
minetest.env:add_node(pos,{type="node",name='madblocks:leaves_spring'})
elseif node.name == 'madblocks:desertsand_winter' then
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
elseif node.name == 'madblocks:sand_winter' then
minetest.env:add_node(pos,{type="node",name='default:sand'})
elseif node.name == 'madblocks:cactus_winter' then
minetest.env:add_node(pos,{type="node",name='default:cactus'})
elseif node.name == 'madblocks:ice_source' then
minetest.env:add_node(pos,{type="node",name='default:water_source'})
elseif node.name == 'madblocks:ice_flowing' then
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
end
elseif CURRENT_SEASON == 3 then
if node.name == 'madblocks:leaves_spring' or node.name == 'madblocks:leaves_winter' or node.name == 'madblocks:leaves_autumn' then
minetest.env:add_node(pos,{type="node",name='default:leaves'})
elseif node.name == 'madblocks:grass_spring' or node.name == 'madblocks:grass_winter' or node.name == 'madblocks:grass_autumn' then
minetest.env:add_node(pos,{type="node",name='default:dirt_with_grass'})
elseif node.name == 'madblocks:desertsand_winter' then
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
elseif node.name == 'madblocks:sand_winter' then
minetest.env:add_node(pos,{type="node",name='default:sand'})
elseif node.name == 'madblocks:cactus_winter' then
minetest.env:add_node(pos,{type="node",name='default:cactus'})
elseif node.name == 'madblocks:ice_source' then
minetest.env:add_node(pos,{type="node",name='default:water_source'})
elseif node.name == 'madblocks:ice_flowing' then
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
end
elseif CURRENT_SEASON == 4 then
if node.name == 'default:leaves' or node.name == 'madblocks:leaves_spring' or node.name == 'madblocks:leaves_winter' then
minetest.env:add_node(pos,{type="node",name='madblocks:leaves_autumn'})
elseif node.name == 'default:dirt_with_grass' or node.name == 'madblocks:grass_spring' or node.name == 'madblocks:grass_winter' then
minetest.env:add_node(pos,{type="node",name='madblocks:grass_autumn'})
elseif node.name == 'madblocks:desertsand_winter' then
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
elseif node.name == 'madblocks:sand_winter' then
minetest.env:add_node(pos,{type="node",name='default:sand'})
elseif node.name == 'madblocks:cactus_winter' then
minetest.env:add_node(pos,{type="node",name='default:cactus'})
elseif node.name == 'madblocks:ice_source' then
minetest.env:add_node(pos,{type="node",name='default:water_source'})
elseif node.name == 'madblocks:ice_flowing' then
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
end
end
end
})
-- ***********************************************************************************
-- BIRDS SPRING/SUMMER **************************************************
-- ***********************************************************************************
if BIRDS == true then
local bird = {}
bird.sounds = {}
bird_sound = function(p)
local wanted_sound = {name="bird", gain=0.6}
bird.sounds[minetest.hash_node_position(p)] = {
handle = minetest.sound_play(wanted_sound, {pos=p, loop=true}),
name = wanted_sound.name, }
end
bird_stop = function(p)
local sound = bird.sounds[minetest.hash_node_position(p)]
if sound ~= nil then
minetest.sound_stop(sound.handle)
bird.sounds[minetest.hash_node_position(p)] = nil
end
end
minetest.register_on_dignode(function(p, node)
if node.name == "madblocks:bird" then
bird_stop(p)
end
end)
minetest.register_abm({
nodenames = { "madblocks:leaves_spring",'default:leaves' },
interval = NATURE_GROW_INTERVAL,
chance = 200,
action = function(pos, node, active_object_count, active_object_count_wider)
local air = { x=pos.x, y=pos.y+1,z=pos.z }
local is_air = minetest.env:get_node_or_nil(air)
if is_air ~= nil and is_air.name == 'air' then
minetest.env:add_node(air,{type="node",name='madblocks:bird'})
bird_sound(air)
end
end
})
minetest.register_abm({
nodenames = {'madblocks:bird' },
interval = NATURE_GROW_INTERVAL,
chance = 2,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:remove_node(pos)
bird_stop(pos)
end
})
end
-- ***********************************************************************************
-- NATURE_GROW **************************************************
-- ***********************************************************************************
minetest.register_abm({
nodenames = { "default:dirt_with_grass",'madblocks:grass_spring' },
interval = NATURE_GROW_INTERVAL,
chance = 200,
action = function(pos, node, active_object_count, active_object_count_wider)
local air = { x=pos.x, y=pos.y+1,z=pos.z }
local is_air = minetest.env:get_node_or_nil(air)
if is_air ~= nil and is_air.name == 'air' then
local count = table.getn(NATURE_PLANTS)
local random_plant = math.random(1,count)
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name=NATURE_PLANTS[random_plant]})
end
end
})
minetest.register_abm({
nodenames = NATURE_PLANTS,
interval = NATURE_GROW_INTERVAL,
chance = 2,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:remove_node({x=pos.x,y=pos.y,z=pos.z})
end
})
-- ***********************************************************************************
-- SLIMTREES **************************************************
-- ***********************************************************************************
minetest.register_abm({
nodenames = { "madblocks:slimtree" },
interval = 60,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x+1,y=pos.y+3,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+3,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z+1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z-1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x+1,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z+1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z-1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x+1,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z+1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z-1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x+1,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z+1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z-1},{type="node",name="default:leaves"})
end
})
-- ***********************************************************************************
-- NODES **************************************************
-- ***********************************************************************************
PLANTLIKE('slimtree','Slimtree Sapling','veg')
PLANTLIKE('bird','Bird','veg')
PLANTLIKE('dandylions','Dandylions','veg')
PLANTLIKE('mushroom','Wild Mushroom','veg')
minetest.register_node("madblocks:slimtree_wood", {
description = "Slimtree",
drawtype = "fencelike",
tile_images = {"madblocks_tree.png"},
inventory_image = "madblocks_tree.png",
wield_image = "madblocks_tree.png",
paramtype = "light",
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {tree=1,snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=2},
sounds = default.node_sound_wood_defaults(),
drop = 'default:fence_wood',
})
minetest.register_node("madblocks:ice_source", {
description = "Ice",
tile_images = {"madblocks_ice.png"},
is_ground_content = true,
groups = {snappy=2,choppy=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("madblocks:ice_flowing", {
description = "Ice",
tile_images = {"madblocks_ice.png"},
is_ground_content = true,
groups = {snappy=2,choppy=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("madblocks:leaves_autumn", {
description = "Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tile_images = {"madblocks_leaves_autumn.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2},
drop = {
max_items = 1, items = {
{items = {'default:sapling'}, rarity = 20,},
{items = {'madblocks:leaves_autumn'},}
}},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("madblocks:leaves_spring", {
description = "Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tile_images = {"madblocks_leaves_spring.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2},
drop = {
max_items = 1, items = {
{items = {'default:sapling'}, rarity = 20,},
{items = {'madblocks:leaves_spring'},}
}},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("madblocks:grass_spring", {
description = "Dirt with snow",
tile_images = {"madblocks_grass_spring.png", "default_dirt.png", "default_dirt.png^madblocks_grass_spring_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("madblocks:grass_autumn", {
description = "Dirt with snow",
tile_images = {"madblocks_grass_autumn.png", "default_dirt.png", "default_dirt.png^madblocks_grass_autumn_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("madblocks:grass_winter", {
description = "Dirt with snow",
tile_images = {"madblocks_snow.png", "default_dirt.png", "default_dirt.png^madblocks_grass_w_snow_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("madblocks:leaves_winter", {
description = "Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tile_images = {"madblocks_leaves_with_snow.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2},
drop = {
max_items = 1, items = {
{items = {'default:sapling'}, rarity = 20,},
{items = {'madblocks:leaves_winter'},}
}},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("madblocks:cactus_winter", {
description = "Cactus",
tile_images = {"madblocks_cactus_wsnow_top.png", "madblocks_cactus_wsnow_top.png", "madblocks_cactus_wsnow_side.png"},
is_ground_content = true,
groups = {snappy=2,choppy=3,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("madblocks:sand_winter", {
description = "Sand with snow",
tile_images = {"madblocks_snow.png", "default_sand.png", "default_sand.png^madblocks_sand_w_snow_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:sand',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("madblocks:desertsand_winter", {
description = "Desert Sand with snow",
tile_images = {"madblocks_snow.png", "default_desert_sand.png", "default_desert_sand.png^madblocks_desertsand_w_snow_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:desert_sand',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})

352
nocrafts.lua Normal file
View File

@ -0,0 +1,352 @@
METALLIKE = function(nodeid, nodename,fence)
minetest.register_node("madblocks:"..nodeid, {
description = nodename,
tile_images = {"madblocks_"..nodeid..".png"},
inventory_image = minetest.inventorycube("madblocks_"..nodeid..".png"),
is_ground_content = true,
groups = {cracky=3},
sounds = default.node_sound_wood_defaults(),
})
if fence == true then
minetest.register_node("madblocks:"..nodeid.."_fence", {
description = nodename.." Fence",
drawtype = "fencelike",
tile_images = {"madblocks_"..nodeid..".png"},
inventory_image = "madblocks_"..nodeid.."_fence.png",
wield_image = "madblocks_"..nodeid.."_fence.png",
paramtype = "light",
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {cracky=3},
sounds = default.node_sound_wood_defaults(),
})
end
end
-- ***********************************************************************************
-- NEW METALLIC ITEMS **************************************************
-- ***********************************************************************************
METALLIKE('brushedmetal','Brushed Metal',true)
METALLIKE('yellow_rustedmetal','Yellow Painted Rusted Metal',true)
METALLIKE('texturedmetal','Textured Metal')
METALLIKE('metalbulkhead','Metal Bulkhead')
METALLIKE('stripedmetal','Caution Striped Metal')
BRICKLIKE('brownmedistonebrick','Mediterranean Stonebrick (Brown Tones)')
-- ***********************************************************************************
-- RIVEN/MYST (DECO) NODES **************************************************
-- ***********************************************************************************
SOUNDNODE('riven1','Riven Art (1)','signlike')
SOUNDNODE('riven2','Riven Art (2)','signlike')
SOUNDNODE('riven3','Riven Art (3)','signlike')
METALLIKE('rivenwood','Riven Wood')
METALLIKE('rivenwoodblue','Riven Wood (Blue)')
METALLIKE('rivenstone1','Riven Stone (1)')
METALLIKE('rivenstone2','Riven Stone (2)')
METALLIKE('rivenstoneblue','Riven Stone (Blue)')
METALLIKE('rivenmetal','Riven Rusted Metal')
METALLIKE('rivenbulkhead','Riven Metal Bulkhead')
METALLIKE('rivengoldstone1','Riven Gold Stone (1)')
METALLIKE('rivengoldstone2','Riven Gold Stone (2)')
minetest.register_node("madblocks:rivenbeetle", {
description = "Sign",
drawtype = "signlike",
tile_images = {"madblocks_rivenbeetle.png"},
inventory_image = "madblocks_rivenbeetle.png",
wield_image = "madblocks_rivenbeetle.png",
paramtype = "light",
paramtype2 = "wallmounted",
light_propagates = true,
sunlight_propagates = true,
light_source = 10,
walkable = false,
selection_box = {
type = "wallmounted",
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
},
groups = {choppy=2,dig_immediate=2},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
})
minetest.register_node("madblocks:rivendagger", {
description = "Sign",
drawtype = "signlike",
tile_images = {"madblocks_rivendagger.png"},
inventory_image = "madblocks_rivendagger.png",
wield_image = "madblocks_rivendagger.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
metadata_name = "sign",
selection_box = {
type = "wallmounted",
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
},
groups = {choppy=2,dig_immediate=2},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
on_construct = function(pos)
--local n = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", "hack:sign_text_input")
meta:set_string("infotext", "\"\"")
end,
on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
local meta = minetest.env:get_meta(pos)
fields.text = fields.text or ""
print((sender:get_player_name() or "").." wrote \""..fields.text..
"\" to sign at "..minetest.pos_to_string(pos))
meta:set_string("text", fields.text)
meta:set_string("infotext", '"'..fields.text..'"')
end,
})
minetest.register_tool("madblocks:riventool", {
description = "Riven Dagger (tool)",
inventory_image = "madblocks_riventool.png",
tool_capabilities = {
full_punch_interval = 0.5,
max_drop_level=3,
groupcaps={
fleshy={times={[1]=6.00, [2]=3, [3]=1}, uses=10, maxlevel=3},
cracky={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=5000, maxlevel=3},
crumbly={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=5000, maxlevel=3},
snappy={times={[1]=0.1, [2]=0.1, [3]=0.1}, uses=5000, maxlevel=3}
}
},
})
-- ***********************************************************************************
-- RIVEN/MYST LINKING BOOKS **************************************************
-- ***********************************************************************************
local linkingbook = {}
linkingbook.sounds = {}
linkingbook_sound = function(p)
local wanted_sound = {name="linkingbook", gain=1.5}
linkingbook.sounds[minetest.hash_node_position(p)] = {
handle = minetest.sound_play(wanted_sound, {pos=p, loop=false}),
name = wanted_sound.name,
}
end
local function has_linkingbook_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end
minetest.register_node("madblocks:linkingbook", {
description = "Linking Book",
drawtype = "signlike",
tile_images = {"madblocks_linkingbook.png"},
inventory_image = "madblocks_linkingbook.png",
wield_image = "madblocks_linkingbook.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
metadata_name = "sign",
selection_box = {
type = "wallmounted",
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
},
groups = {choppy=2,dig_immediate=2},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
on_punch = function(pos,node,puncher)
local player = puncher:get_player_name()-- or ""
local meta = minetest.env:get_meta(pos)
local stringpos = meta:get_string("text")
local p = {}
p.x, p.y, p.z = string.match(stringpos, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
teleportee = minetest.env:get_player_by_name(player)
linkingbook_sound(pos)
teleportee:setpos(p)
linkingbook_sound(p)
end
end,
on_construct = function(pos)
--local n = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", "hack:sign_text_input")
meta:set_string("infotext", "Linking Book")
-- new material
meta:set_string("owner", "")
end,
on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
local meta = minetest.env:get_meta(pos)
-- new material
if not has_linkingbook_privilege(meta, sender) then return end
fields.text = fields.text or ""
print((sender:get_player_name() or "").." wrote \""..fields.text..
"\" to sign at "..minetest.pos_to_string(pos))
meta:set_string("text", fields.text)
-- meta:set_string("infotext", '"'..fields.text..'"')
end,
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
end,
can_dig = function(pos,player)
meta = minetest.env:get_meta(pos)
return has_linkingbook_privilege(meta, player)
end,
})
minetest.register_node("madblocks:plinkingbook", {
description = "Private Linking Book",
drawtype = "signlike",
tile_images = {"madblocks_plinkingbook.png"},
inventory_image = "madblocks_plinkingbook.png",
wield_image = "madblocks_plinkingbook.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
metadata_name = "sign",
selection_box = {
type = "wallmounted",
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
},
groups = {choppy=2,dig_immediate=2},
legacy_wallmounted = true,
sounds = default.node_sound_defaults(),
on_punch = function(pos,node,puncher)
local meta = minetest.env:get_meta(pos)
if not has_linkingbook_privilege(meta, puncher) then return end
local player = puncher:get_player_name()-- or ""
local stringpos = meta:get_string("text")
local p = {}
p.x, p.y, p.z = string.match(stringpos, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
teleportee = minetest.env:get_player_by_name(player)
linkingbook_sound(pos)
teleportee:setpos(p)
linkingbook_sound(p)
end
end,
on_construct = function(pos)
--local n = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", "hack:sign_text_input")
meta:set_string("infotext", "Linking Book")
-- new material
meta:set_string("owner", "")
end,
on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
local meta = minetest.env:get_meta(pos)
-- new material
if not has_linkingbook_privilege(meta, sender) then return end
fields.text = fields.text or ""
print((sender:get_player_name() or "").." wrote \""..fields.text..
"\" to sign at "..minetest.pos_to_string(pos))
meta:set_string("text", fields.text)
-- meta:set_string("infotext", '"'..fields.text..'"')
end,
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
end,
can_dig = function(pos,player)
meta = minetest.env:get_meta(pos)
return has_linkingbook_privilege(meta, player)
end,
})
-- ***********************************************************************************
-- PALM TREES **************************************************
-- ***********************************************************************************
minetest.register_node("madblocks:palmleaves", {
description = "Rail",
drawtype = "raillike",
tile_images = {"madblocks_palmleaves.png", "madblocks_palmleaves_top.png", "madblocks_palmleaves_top.png", "madblocks_palmleaves_top.png"},
inventory_image = "madblocks_palmleaves.png",
wield_image = "madblocks_palmleaves.png",
paramtype = "light",
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
--fixed = <default>
},
groups = {bendy=2,snappy=1,dig_immediate=2},
})
PLANTLIKE('palmtree','Palmtree Sapling','veg')
minetest.register_abm({
nodenames = { "madblocks:palmtree" },
interval = 120,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+7,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z},{type="node",name="madblocks:slimtree_wood"})
minetest.env:add_node({x=pos.x+2,y=pos.y+8,z=pos.z},{type="node",name="madblocks:palmleaves"})
minetest.env:add_node({x=pos.x-2,y=pos.y+8,z=pos.z},{type="node",name="madblocks:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z+2},{type="node",name="madblocks:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z-2},{type="node",name="madblocks:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z},{type="node",name="madblocks:palmleaves"})
minetest.env:add_node({x=pos.x+1,y=pos.y+9,z=pos.z},{type="node",name="madblocks:palmleaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+9,z=pos.z},{type="node",name="madblocks:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z+1},{type="node",name="madblocks:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z-1},{type="node",name="madblocks:palmleaves"})
end
})
-- ***********************************************************************************
-- HOLO NODES **************************************************
-- ***********************************************************************************
minetest.register_node("madblocks:holocobble", {
description = "Holographic Cobblestone",
tile_images = {"default_cobble.png"},
is_ground_content = true,
walkable = false,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("madblocks:holostone", {
description = "Holographic Stone",
tile_images = {"default_stone.png"},
is_ground_content = true,
walkable = false,
groups = {cracky=3},
--drop = 'default:cobble',
legacy_mineral = true,
sounds = default.node_sound_stone_defaults(),
})

234
old/antigrief.lua Normal file
View File

@ -0,0 +1,234 @@
function table.set(t) -- set of list
local u = { }
for _, v in ipairs(t) do u[v] = true end
return u
end
function table.find(f, l) -- find element v of l satisfying f(v)
for _, v in ipairs(l) do
if f(v) then
return v
end
end
return nil
end
local function set_param(param,v)
local output = nil
local output_file = nil
if param == 'shield' then
output_file = GODTOOLS.SHIELD
if v == true then
output = '1'
elseif v == false then
output = '0'
else return
end
SHIELD = v
elseif param == 'prot1' and v.x and v.y and v.z then
output_file = GODTOOLS.PROT1
output = v.x..','..v.y..','..v.z
PROT1 = v
elseif param == 'prot2' and v.x and v.y and v.z then
output_file = GODTOOLS.PROT2
output = v.x..','..v.y..','..v.z
PROT2 = v
else return
end
local f = io.open(output_file, "w")
f:write(output)
io.close(f)
end
compare = function(p1,p2)
result = {}
if p1 > p2 then
result.high = p1
result.low = p2
result.diff = p1 - p2
elseif p2 > p1 then
result.high = p2
result.low = p1
result.diff = p2 - p1
else
result.high = p2
result.low = p1
result.diff = 0
end
if result.diff < 0 then
result.diff = -result.diff
result.mul = -1
else result.mul = 1 end
return result
end
GODTOOLS = {}
-- ***********************************************************************************
-- ANTIGRIEF / PROTECTION AREA **************************************************
-- ***********************************************************************************
--ENABLE_PROTECTION = true -- uncomment if using godtools w/o madblocks
if ENABLE_PROTECTION == true then
GODTOOLS.SHIELD = minetest.get_worldpath()..'/godtools.shield'
GODTOOLS.PROT1 = minetest.get_worldpath()..'/godtools.prot1'
GODTOOLS.PROT2 = minetest.get_worldpath()..'/godtools.prot2'
SHIELD = false
BACKUP_BUCKET = {}
PROT1 = {}
PROT2 = {}
local paramshield = io.open(GODTOOLS.SHIELD, "r")
local paramprot1 = io.open(GODTOOLS.PROT1, "r")
local paramprot2 = io.open(GODTOOLS.PROT2, "r")
if paramshield ~= nil then
value = paramshield:read("*n")
if value == 1 then
SHIELD = true
io.close(paramshield)
elseif value == 0 then
SHIELD = false
io.close(paramshield)
else
set_param('shield',false)
end
else
print('no shield file, setting default off')
set_param('shield',false)
end
if paramprot1 ~= nil then
local value = paramprot1:read()
local p = {}
p.x, p.y, p.z = string.match(value, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
PROT1.x = tonumber(p.x)
PROT1.y = tonumber(p.y)
PROT1.z = tonumber(p.z)
io.close(paramprot1)
else
set_param('prot1',{x=-500,y=-500,z=-500})
end
else
print('no prot1 file, setting default -500,-500,-500')
set_param('prot1',{x=-500,y=-500,z=-500})
end
if paramprot2 ~= nil then
local value = paramprot2:read()
local p = {}
p.x, p.y, p.z = string.match(value, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
PROT2.x = tonumber(p.x)
PROT2.y = tonumber(p.y)
PROT2.z = tonumber(p.z)
io.close(paramprot2)
else
set_param('prot2',{x=500,y=500,z=500})
end
else
print('no prot2 file, setting default 500,500,500')
set_param('prot2',{x=500,y=500,z=500})
end
minetest.register_chatcommand("shield", {
params = "<onoff>",
description = "griefing countermeasures",
privs = {server=true},
func = function(name, param)
if param == 'on' then
set_param('shield',true)
-- SHIELD = true
BACKUP_BUCKET = bucket.liquids
bucket.liquids = {}
minetest.chat_send_player(name, "shield up.")
elseif param == 'off' then
set_param('shield',false)
-- SHIELD = false
bucket.liquids = BACKUP_BUCKET
minetest.chat_send_player(name, "shield down.")
else minetest.chat_send_player(name, "invalid paramter, try 'on' or 'off'.")
end
end,
})
minetest.register_chatcommand("prot1", {
params = "<X>,<Y>,<Z>",
description = "first corner",
privs = {server=true},
func = function(name, param)
local p = {}
p.x, p.y, p.z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
set_param('prot1',{x= tonumber(p.x),y=tonumber(p.y),z=tonumber(p.z)})
minetest.chat_send_player(name, "Fill1 set to ("..p.x..", "..p.y..", "..p.z..")")
return
else
local target = minetest.env:get_player_by_name(name)
if target then
set_param('prot1',target:getpos())
minetest.chat_send_player(name, "Fill1 set to ("..PROT1.x..", "..PROT1.y..", "..PROT1.z..")")
return
end
end
end,
})
minetest.register_chatcommand("prot2", {
params = "<X>,<Y>,<Z>",
description = "opposite corner",
privs = {server=true},
func = function(name, param)
local p = {}
p.x, p.y, p.z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
if p.x and p.y and p.z then
set_param('prot2',{x= tonumber(p.x),y=tonumber(p.y),z=tonumber(p.z)})
minetest.chat_send_player(name, "Fill2 set to ("..p.x..", "..p.y..", "..p.z..")")
return
else
local target = minetest.env:get_player_by_name(name)
if target then
set_param('prot2',target:getpos())
minetest.chat_send_player(name, "Fill2 set to ("..PROT2.x..", "..PROT2.y..", "..PROT2.z..")")
return
end
end
end,
})
minetest.register_on_placenode(function(p, node)
if SHIELD == true then
if node.name == "default:water_source" or node.name == "default:lava_source" then
minetest.env:remove_node(p)
elseif PROT1 and PROT2 then
local xd = compare(PROT1.x,PROT2.x)
local yd = compare(PROT1.y,PROT2.y)
local zd = compare(PROT1.z,PROT2.z)
if p.x >= xd.low and p.x <= xd.high and p.y >= yd.low and p.y <= yd.high and p.z >= zd.low and p.z <= zd.high then
minetest.env:remove_node(p)
end
end
end
end)
minetest.register_on_dignode(function(p, node)
if SHIELD == true and PROT1 and PROT2 then
local xd = compare(PROT1.x,PROT2.x)
local yd = compare(PROT1.y,PROT2.y)
local zd = compare(PROT1.z,PROT2.z)
print(p.x..' '..p.y..' '..p.z)
print(xd.low..' '..xd.high..' '..yd.low..' '..yd.high..' '..zd.low..' '..zd.high)
if p.x >= xd.low and p.x <= xd.high and p.y >= yd.low and p.y <= yd.high and p.z >= zd.low and p.z <= zd.high then
minetest.env:add_node(p,{type="node",name=node.name})
print('VICTORY')
end
end
end)
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
sounds/bigbenshort.ogg Normal file

Binary file not shown.

BIN
sounds/bird.ogg Normal file

Binary file not shown.

BIN
sounds/churchbells.ogg Normal file

Binary file not shown.

BIN
sounds/fire_large.ogg Normal file

Binary file not shown.

BIN
sounds/fire_small.ogg Normal file

Binary file not shown.

BIN
sounds/linkingbook.ogg Normal file

Binary file not shown.

BIN
sounds/riven1.ogg Normal file

Binary file not shown.

BIN
sounds/riven2.ogg Normal file

Binary file not shown.

BIN
sounds/riven3.ogg Normal file

Binary file not shown.

BIN
sounds/siren.0.ogg Normal file

Binary file not shown.

BIN
textures/default_cobble.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

BIN
textures/default_tree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 843 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
textures/madblocks_bbc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
textures/madblocks_bird.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
textures/madblocks_drum.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Some files were not shown because too many files have changed in this diff Show More