Initial commit

master
fishyWET 2016-02-29 21:22:49 +08:00
parent 8751bec8e1
commit 70cdf199fa
26 changed files with 487 additions and 0 deletions

403
api.lua Normal file
View File

@ -0,0 +1,403 @@
moremush = {}
-- place_seed taken from minetest_game/farming/api.lua farming.place_seed, with removal of comments and minor changes.
moremush.place_seed = function(itemstack, placer, pointed_thing, plantname)
local pt = pointed_thing
if not pt then
return
end
if pt.type ~= "node" then
return
end
local under = minetest.get_node(pt.under)
local above = minetest.get_node(pt.above)
if minetest.is_protected(pt.under, placer:get_player_name()) then
minetest.record_protection_violation(pt.under, placer:get_player_name())
return
end
if minetest.is_protected(pt.above, placer:get_player_name()) then
minetest.record_protection_violation(pt.above, placer:get_player_name())
return
end
if not minetest.registered_nodes[under.name] then
return
end
if not minetest.registered_nodes[above.name] then
return
end
--if pt.above.y ~= pt.under.y+1 then
-- return
--end
if not minetest.registered_nodes[above.name].buildable_to then
return
end
print("UNDER:"..under.name)
print("ABOVE:"..above.name)
if under.name == "default:tree" or under.name == "default:mossycobble" then
local stack = ItemStack(plantname)
minetest.item_place(stack, placer, pointed_thing)
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
end
function moremush:register_mushroom(name, def)
minetest.register_node("moremush:"..name.."_i", {
tiles = {def.image..".png"},
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, flammable = 3, attached_node = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
light_source = def.light or 0,
drop = def.maindname,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
}
})
minetest.register_node(def.mainname, {
description = def.description or "Undefined Mushroom",
tiles = {def.image..".png", def.image..".png^[transformFXR180", def.image..".png^[transformFXR90"},
inventory_image = def.image..".png",
wield_image = def.image..".png",
drawtype = "torchlike",
paramtype = "light",
paramtype2 = "wallmounted",
legacy_wallmounted = true,
sunlight_propagates = true,
walkable = false,
groups = {snappy = 3, flammable = 3, attached_node = 1},
sounds = default.node_sound_leaves_defaults(),
on_use = minetest.item_eat(def.hp),
after_place_node = function(pos, placer, itemstack)
if( not( pos ) or not( placer )) then
return;
end
local n = minetest.get_node({x = pos.x, y = pos.y-1, z = pos.z-1})
local node = n.name
if not minetest.registered_nodes[node].buildable_to then
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name="moremush:"..name.."_i"})
end
end,
light_source = def.light or 0,
selection_box = {
type = "wallmounted",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
}
})
minetest.register_node("moremush:"..name.."_1", {
tiles = {def.image_1..".png"},
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, flammable = 3, attached_node = 1, mush = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = 'moremush:'..name..'_spores',
light_source = def.light_1 or 0,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
}
})
minetest.register_node("moremush:"..name.."_2", {
tiles = {def.image_2..".png"},
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, flammable = 3, attached_node = 1, mush = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = 'moremush:'..name..'_spores',
light_source = def.light_2 or 0,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
}
})
minetest.register_node("moremush:"..name.."_3", {
tiles = {def.image_3..".png"},
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, flammable = 3, attached_node = 1, mush = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = 'moremush:'..name..'_spores',
light_source = def.light_3 or 0,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
}
})
minetest.register_node("moremush:"..name.."_4", {
tiles = {def.image..".png"},
drawtype = "plantlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
groups = {snappy = 3, flammable = 3, attached_node = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
light_source = def.light or 0,
drop = {
max_items = 4,
items = {
{items = {'moremush:'..name..'_spores'},rarity = 10},
{items = {'moremush:'..name..'_spores'},rarity = 7},
{items = {'moremush:'..name..'_spores'}},
{items = {def.maindname}},
}
},
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
}
})
minetest.register_node("moremush:"..name.."_spores", {
description = def.description.." Spores" or "Undefined Mushroom Spores",
tiles = {def.image_0..".png"},
inventory_image = def.image_0..".png",
wield_image = def.image_0..".png",
drawtype = "signlike",
paramtype = "light",
paramtype2 = "wallmounted",
legacy_wallmounted = true,
sunlight_propagates = true,
walkable = false,
groups = {snappy = 3, flammable = 3, attached_node = 1, mush = 1},
sounds = default.node_sound_leaves_defaults(),
light_source = def.light_0 or 0,
on_place = function(itemstack, placer, pointed_thing)
return moremush.place_seed(itemstack, placer, pointed_thing, "moremush:"..name.."_spores")
end,
selection_box = {
type = "wallmounted",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
}
})
-- opposite nodes & wall nodes
minetest.register_node("moremush:"..name.."_1_o", {
tiles = {def.image_1..".png", def.image_1..".png^[transformFXR180", def.image_1..".png^[transformFXR90"},
drawtype = "torchlike",
paramtype = "light",
paramtype2 = "wallmounted",
legacy_wallmounted = true,
sunlight_propagates = true,
walkable = false,
groups = {snappy = 3, flammable = 3, attached_node = 1, mush = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = 'moremush:'..name..'_spores',
light_source = def.light_1 or 0,
selection_box = {
type = "wallmounted",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
}
})
minetest.register_node("moremush:"..name.."_2_o", {
tiles = {def.image_2..".png", def.image_2..".png^[transformFXR180", def.image_2..".png^[transformFXR90"},
drawtype = "torchlike",
paramtype = "light",
paramtype2 = "wallmounted",
legacy_wallmounted = true,
sunlight_propagates = true,
walkable = false,
groups = {snappy = 3, flammable = 3, attached_node = 1, mush = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = 'moremush:'..name..'_spores',
light_source = def.light_2 or 0,
selection_box = {
type = "wallmounted",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
}
})
minetest.register_node("moremush:"..name.."_3_o", {
tiles = {def.image_3..".png", def.image_3..".png^[transformFXR180", def.image_3..".png^[transformFXR90"},
drawtype = "torchlike",
paramtype = "light",
paramtype2 = "wallmounted",
legacy_wallmounted = true,
sunlight_propagates = true,
walkable = false,
groups = {snappy = 3, flammable = 3, attached_node = 1, mush = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
drop = 'moremush:'..name..'_spores',
light_source = def.light_3 or 0,
selection_box = {
type = "wallmounted",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
}
})
minetest.register_node("moremush:"..name.."_4_o", {
tiles = {def.image..".png", def.image..".png^[transformFXR180", def.image..".png^[transformFXR90"},
drawtype = "torchlike",
paramtype = "light",
paramtype2 = "wallmounted",
legacy_wallmounted = true,
sunlight_propagates = true,
walkable = false,
groups = {snappy = 3, flammable = 3, attached_node = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_leaves_defaults(),
light_source = def.light or 0,
drop = {
max_items = 4,
items = {
{items = {'moremush:'..name..'_spores'},rarity = 10},
{items = {'moremush:'..name..'_spores'},rarity = 7},
{items = {'moremush:'..name..'_spores'}},
{items = {def.maindname}},
}
},
selection_box = {
type = "wallmounted",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
}
})
minetest.register_abm({
nodenames = {"group:mush"},
neighbors = {"default:tree", "default:mossycobble"},
interval = 1,
chance = 1,
action = function(pos, node)
local n = minetest.get_node({x = pos.x, y = pos.y-1, z = pos.z})
if n.name == "default:tree" or n.name == "default:mossycobble" then
local ll = minetest.get_node_light(pos)
if not ll or ll > 10 or ll < 0 then
return
end
local n = minetest.get_node(pos)
if n.name == "moremush:"..name.."_spores" then
minetest.set_node(pos, {name="moremush:"..name.."_1"})
elseif n.name == "moremush:"..name.."_1" then
minetest.set_node(pos, {name="moremush:"..name.."_2"})
elseif n.name == "moremush:"..name.."_2" then
minetest.set_node(pos, {name="moremush:"..name.."_3"})
elseif n.name == "moremush:"..name.."_3" then
minetest.set_node(pos, {name="moremush:"..name.."_4"})
end
end
local n = minetest.get_node({x = pos.x, y = pos.y+1, z = pos.z})
if n.name == "default:tree" or n.name == "default:mossycobble" then
local ll = minetest.get_node_light(pos)
if not ll or ll > 10 or ll < 0 then
return
end
local n = minetest.get_node(pos)
if n.name == "moremush:"..name.."_spores" then
minetest.add_node(pos, {name = "moremush:"..name.."_1_o", param2 = 6})
elseif n.name == "moremush:"..name.."_1_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_2_o", param2 = 6})
elseif n.name == "moremush:"..name.."_2_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_3_o", param2 = 6})
elseif n.name == "moremush:"..name.."_3_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_4_o", param2 = 6})
end
end
local n = minetest.get_node({x = pos.x+1, y = pos.y, z = pos.z})
if n.name == "default:tree" or n.name == "default:mossycobble" then
local ll = minetest.get_node_light(pos)
if not ll or ll > 10 or ll < 0 then
return
end
local n = minetest.get_node(pos)
if n.name == "moremush:"..name.."_spores" then
minetest.add_node(pos, {name = "moremush:"..name.."_1_o", param2 = 2})
elseif n.name == "moremush:"..name.."_1_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_2_o", param2 = 2})
elseif n.name == "moremush:"..name.."_2_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_3_o", param2 = 2})
elseif n.name == "moremush:"..name.."_3_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_4_o", param2 = 2})
end
end
local n = minetest.get_node({x = pos.x-1, y = pos.y, z = pos.z})
if n.name == "default:tree" or n.name == "default:mossycobble" then
local ll = minetest.get_node_light(pos)
if not ll or ll > 10 or ll < 0 then
return
end
local n = minetest.get_node(pos)
if n.name == "moremush:"..name.."_spores" then
minetest.add_node(pos, {name = "moremush:"..name.."_1_o", param2 = 3})
elseif n.name == "moremush:"..name.."_1_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_2_o", param2 = 3})
elseif n.name == "moremush:"..name.."_2_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_3_o", param2 = 3})
elseif n.name == "moremush:"..name.."_3_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_4_o", param2 = 3})
end
end
local n = minetest.get_node({x = pos.x, y = pos.y, z = pos.z+1})
if n.name == "default:tree" or n.name == "default:mossycobble" then
local ll = minetest.get_node_light(pos)
if not ll or ll > 10 or ll < 0 then
return
end
local n = minetest.get_node(pos)
if n.name == "moremush:"..name.."_spores" then
minetest.add_node(pos, {name = "moremush:"..name.."_1_o", param2 = 4})
elseif n.name == "moremush:"..name.."_1_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_2_o", param2 = 4})
elseif n.name == "moremush:"..name.."_2_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_3_o", param2 = 4})
elseif n.name == "moremush:"..name.."_3_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_4_o", param2 = 4})
end
end
local n = minetest.get_node({x = pos.x, y = pos.y, z = pos.z-1})
if n.name == "default:tree" or n.name == "default:mossycobble" then
local ll = minetest.get_node_light(pos)
if not ll or ll > 10 or ll < 0 then
return
end
local n = minetest.get_node(pos)
if n.name == "moremush:"..name.."_spores" then
minetest.add_node(pos, {name = "moremush:"..name.."_1_o", param2 = 5})
elseif n.name == "moremush:"..name.."_1_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_2_o", param2 = 5})
elseif n.name == "moremush:"..name.."_2_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_3_o", param2 = 5})
elseif n.name == "moremush:"..name.."_3_o" then
minetest.add_node(pos, {name = "moremush:"..name.."_4_o", param2 = 5})
end
end
end
})
end

3
depends.txt Normal file
View File

@ -0,0 +1,3 @@
farming
flowers
default

81
init.lua Normal file
View File

@ -0,0 +1,81 @@
-- moremush 1.0
minetest.register_alias("flowers:mushroom_red", "moremush:mushroom_red")
--Simple API
dofile(minetest.get_modpath("moremush").."/api.lua")
moremush:register_mushroom("mushroom_red", {
mainname = ":flowers:mushroom_red",
maindname = "flowers:mushroom_red",
description = "Red Mushroom",
image = "flowers_mushroom_red",
image_0 = "moremush_red_spores",
image_1 = "moremush_red_1",
image_2 = "moremush_red_2",
image_3 = "moremush_red_3",
hp = -5,
})
moremush:register_mushroom("mushroom_brown", {
mainname = ":flowers:mushroom_brown",
maindname = "flowers:mushroom_brown",
description = "Brown Mushroom",
image = "flowers_mushroom_brown",
image_0 = "moremush_brown_spores",
image_1 = "moremush_brown_1",
image_2 = "moremush_brown_2",
image_3 = "moremush_brown_3",
hp = 1,
})
moremush:register_mushroom("mushroom_green", {
mainname = "moremush:mushroom_green",
maindname = "moremush:mushroom_green",
description = "Ghostly Green Mushroom",
image = "moremush_green",
image_0 = "moremush_green_spores",
image_1 = "moremush_green_1",
image_2 = "moremush_green_2",
image_3 = "moremush_green_3",
hp = 2,
light = 6,
light_0 = 1,
light_1 = 2,
light_2 = 3,
light_3 = 4
})
moremush:register_mushroom("mushroom_blue", {
mainname = "moremush:mushroom_blue",
maindname = "moremush:mushroom_blue",
description = "Ghostly Blue Mushroom",
image = "moremush_blue",
image_0 = "moremush_blue_spores",
image_1 = "moremush_blue_1",
image_2 = "moremush_blue_2",
image_3 = "moremush_blue_3",
hp = 2,
light = 6,
light_0 = 1,
light_1 = 2,
light_2 = 3,
light_3 = 4
})
moremush:register_mushroom("mushroom_boom", {
mainname = "moremush:mushroom_boom",
maindname = "moremush:mushroom_boom",
description = "Fire Mushroom",
image = "moremush_boom",
image_0 = "moremush_boom_spores",
image_1 = "moremush_boom_1",
image_2 = "moremush_boom_2",
image_3 = "moremush_boom_3",
hp = -20,
light = 8,
light_0 = 1,
light_1 = 2,
light_2 = 4,
light_3 = 6
})

BIN
textures/moremush_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

BIN
textures/moremush_boom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

BIN
textures/moremush_green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

BIN
textures/moremush_red_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

BIN
textures/moremush_red_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

BIN
textures/moremush_red_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B