epicnodedemo_game/mods/game/runtime/nodes.lua

838 lines
22 KiB
Lua

--------------------------------------------------------------------------------------------
------------------------------- EpicNode Game ver: 0.1 :D ----------------------------------
--------------------------------------------------------------------------------------------
--Mod by Pinkysnowman --
--(c)2015 --
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
game.register("node", "stone", {
description = "Stone",
tiles = {"default_stone.png"},
groups = {cracky = 3, stone = 1},
drop = 'game:cobble',
legacy_mineral = true,
sounds = game.sound("stone"),
})
game.register("node", "cobble", {
description = "Cobblestone",
tiles = {"default_cobble.png"},
is_ground_content = false,
groups = {cracky = 3, stone = 2},
sounds = game.sound("stone"),
})
game.register("node", "stonebrick", {
description = "Stone Brick",
tiles = {"default_stone_brick.png"},
is_ground_content = false,
groups = {cracky = 2, stone = 1},
sounds = game.sound("stone"),
})
game.register("node", "mossycobble", {
description = "Mossy Cobblestone",
tiles = {"default_mossycobble.png"},
is_ground_content = false,
groups = {cracky = 3, stone = 1},
sounds = game.sound("stone"),
})
game.register("node", "desert_stonebrick", {
description = "Desert Stone Brick",
tiles = {"default_desert_stone_brick.png"},
is_ground_content = false,
groups = {cracky = 2, stone = 1},
sounds = game.sound("stone"),
})
game.register("node", "sandstone", {
description = "Sandstone",
tiles = {"default_sandstone.png"},
groups = {crumbly = 2, cracky = 3},
sounds = game.sound("stone"),
})
game.register("node", "sandstonebrick", {
description = "Sandstone Brick",
tiles = {"default_sandstone_brick.png"},
is_ground_content = false,
groups = {cracky = 2},
sounds = game.sound("stone"),
})
game.register("node", "obsidian", {
description = "Obsidian",
tiles = {"default_obsidian.png"},
sounds = game.sound("stone"),
groups = {cracky = 1, level = 2},
})
game.register("node", "obsidianbrick", {
description = "Obsidian Brick",
tiles = {"default_obsidian_brick.png"},
is_ground_content = false,
sounds = game.sound("stone"),
groups = {cracky = 1, level = 2},
})
--
-- Soft / Non-Stone
--
game.register("node", "dirt", {
description = "Dirt",
tiles = {"default_dirt.png"},
groups = {crumbly = 3, soil = 1},
sounds = game.sound("dirt"),
})
game.register("dirt", "grass", {
footstep = {name = "default_grass_footstep", gain = 0.25},
})
game.register("node", "grass_footsteps", {
description = "Dirt with Grass and Footsteps",
tiles = {"default_grass.png^default_footprint.png", "default_dirt.png",
{name = "default_dirt.png^default_grass_side.png",
tileable_vertical = false}},
groups = {crumbly = 3, soil = 1, not_in_creative_inventory = 1},
drop = 'game:dirt',
sounds = game.sound("dirt",{footstep = {name = "default_grass_footstep", gain = 0.25},}),
})
game.register("dirt", "dry_grass", {
footstep = {name = "default_grass_footstep", gain = 0.4},
})
game.register("drt", "snow", {
footstep = {name = "default_snow_footstep", gain = 0.25},
})
game.register("node", "sand", {
description = "Sand",
tiles = {"default_sand.png", "default_sand_side.png"},
groups = {crumbly = 3, falling_node = 1, sand = 1},
sounds = game.sound("sand"),
})
--
-- Trees
--
game.register("node", "wood", {
description = "Wooden Planks",
tiles = {"default_wood.png"},
is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
sounds = game.sound("wood"),
})
game.register("node", "apple", {
description = "Apple",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_apple.png"},
inventory_image = "default_apple.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
},
groups = {fleshy = 3, dig_immediate = 3, flammable = 2,
leafdecay = 3, leafdecay_drop = 1,food=1,not_in_creative_inventory=1},
on_use = minetest.item_eat(2),
sounds = game.sound("leaves"),
after_place_node = function(pos, placer, itemstack)
if placer:is_player() then
minetest.set_node(pos, {name = "game:apple", param2 = 1})
end
end,
})
game.register("node", "junglewood", {
description = "Junglewood Planks",
tiles = {"default_junglewood.png"},
is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
sounds = game.sound("wood"),
})
game.register("node", "fir_wood", {
description = "Fir Wood Planks",
tiles = {"default_pine_wood.png"},
is_ground_content = false,
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
sounds = game.sound("wood"),
})
--
-- Plantlife (non-cubic)
--
--
-- Liquids
--
game.register("node", "water_source", {
description = "Water Source",
inventory_image = minetest.inventorycube("default_water.png"),
drawtype = "liquid",
tiles = {
{
name = "default_water_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
},
special_tiles = {
-- New-style water source material (mostly unused)
{
name = "default_water_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
backface_culling = false,
},
},
alpha = 160,
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "game:water_flowing",
liquid_alternative_source = "game:water_source",
liquid_viscosity = 1,
post_effect_color = {a = 120, r = 30, g = 60, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1},
})
game.register("node", "water_flowing", {
description = "Flowing Water",
inventory_image = minetest.inventorycube("default_water.png"),
drawtype = "flowingliquid",
tiles = {"default_water.png"},
special_tiles = {
{
name = "default_water_flowing_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
{
name = "default_water_flowing_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
},
alpha = 160,
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "game:water_flowing",
liquid_alternative_source = "game:water_source",
liquid_viscosity = 1,
post_effect_color = {a = 120, r = 30, g = 60, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1,
not_in_creative_inventory = 1},
})
game.register("node", "river_water_source", {
description = "River Water Source",
inventory_image = minetest.inventorycube("default_river_water.png"),
drawtype = "liquid",
tiles = {
{
name = "default_river_water_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
},
special_tiles = {
{
name = "default_river_water_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
backface_culling = false,
},
},
alpha = 160,
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "game:river_water_flowing",
liquid_alternative_source = "game:river_water_source",
liquid_viscosity = 1,
liquid_renewable = false,
liquid_range = 2,
post_effect_color = {a = 120, r = 30, g = 76, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1},
})
game.register("node", "river_water_flowing", {
description = "Flowing River Water",
inventory_image = minetest.inventorycube("default_river_water.png"),
drawtype = "flowingliquid",
tiles = {"default_river_water.png"},
special_tiles = {
{
name = "default_river_water_flowing_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
{
name = "default_river_water_flowing_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
},
alpha = 160,
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "game:river_water_flowing",
liquid_alternative_source = "game:river_water_source",
liquid_viscosity = 1,
liquid_renewable = false,
liquid_range = 2,
post_effect_color = {a = 120, r = 30, g = 76, b = 90},
groups = {water = 3, liquid = 3, puts_out_fire = 1,
not_in_creative_inventory = 1},
})
game.register("node", "lava_source", {
description = "Lava Source",
inventory_image = minetest.inventorycube("default_lava.png"),
drawtype = "liquid",
tiles = {
{
name = "default_lava_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0,
},
},
},
special_tiles = {
-- New-style lava source material (mostly unused)
{
name = "default_lava_source_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0,
},
backface_culling = false,
},
},
paramtype = "light",
light_source = game.LIGHT_MAX - 1,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "game:lava_flowing",
liquid_alternative_source = "game:lava_source",
liquid_viscosity = 7,
liquid_renewable = false,
damage_per_second = 4 * 2,
post_effect_color = {a = 192, r = 255, g = 64, b = 0},
groups = {lava = 3, liquid = 2, hot = 3, igniter = 1},
})
game.register("node", "lava_flowing", {
description = "Flowing Lava",
inventory_image = minetest.inventorycube("default_lava.png"),
drawtype = "flowingliquid",
tiles = {"default_lava.png"},
special_tiles = {
{
name = "default_lava_flowing_animated.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.3,
},
},
{
name = "default_lava_flowing_animated.png",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.3,
},
},
},
paramtype = "light",
paramtype2 = "flowingliquid",
light_source = game.LIGHT_MAX - 1,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "game:lava_flowing",
liquid_alternative_source = "game:lava_source",
liquid_viscosity = 7,
liquid_renewable = false,
damage_per_second = 4 * 2,
post_effect_color = {a = 192, r = 255, g = 64, b = 0},
groups = {lava = 3, liquid = 2, hot = 3, igniter = 1,
not_in_creative_inventory = 1},
})
--
-- Tools / "Advanced" crafting / Non-"natural"
--
game.register("node", "torch", {
description = "Torch",
drawtype = "torchlike",
tiles = {
{
name = "default_torch_on_floor_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0
},
},
{
name="default_torch_on_ceiling_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0
},
},
{
name="default_torch_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 3.0
},
},
},
inventory_image = "default_torch_on_floor.png",
wield_image = "default_torch_on_floor.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
is_ground_content = false,
walkable = false,
light_source = game.LIGHT_MAX - 1,
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, attached_node = 1},
legacy_wallmounted = true,
sounds = game.sound("default"),
})
local chest_formspec =
"size[8,9]" ..
game.gui_bg ..
game.gui_bg_img ..
game.gui_slots ..
"list[current_name;main;0,0.3;8,4;]" ..
"list[current_player;main;0,4.85;8,1;]" ..
"list[current_player;main;0,6.08;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]" ..
game.get_hotbar_bg(0,4.85)
local function get_locked_chest_formspec(pos)
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
local formspec =
"size[8,9]" ..
game.gui_bg ..
game.gui_bg_img ..
game.gui_slots ..
"list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
"list[current_player;main;0,4.85;8,1;]" ..
"list[current_player;main;0,6.08;8,3;8]" ..
"listring[nodemeta:" .. spos .. ";main]" ..
"listring[current_player;main]" ..
game.get_hotbar_bg(0,4.85)
return formspec
end
local function has_locked_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end
game.register("node", "chest", {
description = "Chest",
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
"default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
paramtype2 = "facedir",
groups = {choppy = 2, oddly_breakable_by_hand = 2},
legacy_facedir_simple = true,
is_ground_content = false,
sounds = game.sound("wood"),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", chest_formspec)
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.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))
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" moves stuff to chest at " .. minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" takes stuff from chest at " .. minetest.pos_to_string(pos))
end,
})
game.register("node", "chest_locked", {
description = "Locked Chest",
tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
"default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
paramtype2 = "facedir",
groups = {choppy = 2, oddly_breakable_by_hand = 2},
legacy_facedir_simple = true,
is_ground_content = false,
sounds = game.sound("wood"),
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name() or "")
meta:set_string("infotext", "Locked Chest (owned by " ..
meta:get_string("owner") .. ")")
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Locked Chest")
meta:set_string("owner", "")
local inv = meta:get_inventory()
inv:set_size("main", 8 * 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
end,
allow_metadata_inventory_move = function(pos, from_list, from_index,
to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
return 0
end
return count
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
return 0
end
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
if not has_locked_chest_privilege(meta, player) then
return 0
end
return stack:get_count()
end,
on_metadata_inventory_put = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" moves stuff to locked chest at " .. minetest.pos_to_string(pos))
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
minetest.log("action", player:get_player_name() ..
" takes stuff from locked chest at " .. minetest.pos_to_string(pos))
end,
on_rightclick = function(pos, node, clicker)
local meta = minetest.get_meta(pos)
if has_locked_chest_privilege(meta, clicker) then
minetest.show_formspec(
clicker:get_player_name(),
"game:chest_locked",
get_locked_chest_formspec(pos)
)
end
end,
on_blast = function() end,
})
game.register("node", "sign_wall", {
description = "Sign",
drawtype = "nodebox",
tiles = {"default_sign.png"},
inventory_image = "default_sign_wall.png",
wield_image = "default_sign_wall.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
is_ground_content = false,
walkable = false,
node_box = {
type = "wallmounted",
wall_top = {-0.4375, 0.4375, -0.3125, 0.4375, 0.5, 0.3125},
wall_bottom = {-0.4375, -0.5, -0.3125, 0.4375, -0.4375, 0.3125},
wall_side = {-0.5, -0.3125, -0.4375, -0.4375, 0.3125, 0.4375},
},
groups = {choppy = 2, dig_immediate = 2, attached_node = 1},
legacy_wallmounted = true,
sounds = game.sound("default"),
on_construct = function(pos)
--local n = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[text;;${text}]")
meta:set_string("infotext", "\"\"")
end,
on_receive_fields = function(pos, formname, fields, sender)
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
if minetest.is_protected(pos, sender:get_player_name()) then
minetest.record_protection_violation(pos, sender:get_player_name())
return
end
local meta = minetest.get_meta(pos)
if not fields.text then return end
minetest.log("action", (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,
})
game.register("node", "ladder", {
description = "Ladder",
drawtype = "signlike",
tiles = {"default_ladder.png"},
inventory_image = "default_ladder.png",
wield_image = "default_ladder.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
climbable = true,
is_ground_content = false,
selection_box = {
type = "wallmounted",
--wall_top = = <default>
--wall_bottom = = <default>
--wall_side = = <default>
},
groups = {choppy = 2, oddly_breakable_by_hand = 3, flammable = 2},
legacy_wallmounted = true,
sounds = game.sound("wood"),
})
local fence_texture =
"default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126"
game.register("node", "fence_wood", {
description = "Wooden Fence",
drawtype = "fencelike",
tiles = {"default_wood.png"},
inventory_image = fence_texture,
wield_image = fence_texture,
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
sounds = game.sound("wood"),
})
game.register("node", "glass", {
description = "Glass",
drawtype = "glasslike_framed_optional",
tiles = {"default_glass.png", "default_glass_detail.png"},
inventory_image = minetest.inventorycube("default_glass.png"),
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = game.sound("glass"),
})
game.register("node", "meselamp", {
description = "Mese Lamp",
drawtype = "glasslike",
tiles = {"default_meselamp.png"},
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = game.sound("glass"),
light_source = game.LIGHT_MAX,
})
--
-- Misc
--
game.register("node", "cloud", {
description = "Cloud",
tiles = {"default_cloud.png"},
is_ground_content = false,
sounds = game.sound("default"),
groups = {not_in_creative_inventory = 1},
})
game.register("node", "nyancat", {
description = "Nyan Cat",
tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
"default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
paramtype2 = "facedir",
groups = {cracky = 2},
is_ground_content = false,
legacy_facedir_simple = true,
sounds = game.sound("default"),
})
game.register("node", "nyancat_rainbow", {
description = "Nyan Cat Rainbow",
tiles = {
"default_nc_rb.png^[transformR90", "default_nc_rb.png^[transformR90",
"default_nc_rb.png", "default_nc_rb.png"
},
paramtype2 = "facedir",
groups = {cracky = 2},
is_ground_content = false,
sounds = game.sound("default"),
})
game.register("node", "walk_light", {
drawtype = "airlike",
inventory_image = minetest.inventorycube("walking_light.png"),
paramtype = "light",
walkable = false,
is_ground_content = true,
light_propagates = true,
sunlight_propagates = true,
light_source = 13,
pointable = false,
})