Start nodes.lua reformating

master
Maksim 2019-05-11 18:35:05 +02:00
parent 6dcc8a9f80
commit 7100026018
6 changed files with 846 additions and 835 deletions

View File

@ -82,3 +82,6 @@ minetest.register_alias("default:string", "farming:string")
-- Hay Bale
minetest.register_alias("default:haybale", "farming:straw")
-- Ladder
minetest.register_alias("default:ladder", "default:ladder_wood")

View File

@ -1,3 +1,45 @@
--
-- Temporary chest solution
--
local function get_chest_neighborpos(pos, param2, side)
if side == "right" then
if param2 == 0 then
return {x=pos.x-1, y=pos.y, z=pos.z}
elseif param2 == 1 then
return {x=pos.x, y=pos.y, z=pos.z+1}
elseif param2 == 2 then
return {x=pos.x+1, y=pos.y, z=pos.z}
elseif param2 == 3 then
return {x=pos.x, y=pos.y, z=pos.z-1}
end
else
if param2 == 0 then
return {x=pos.x+1, y=pos.y, z=pos.z}
elseif param2 == 1 then
return {x=pos.x, y=pos.y, z=pos.z-1}
elseif param2 == 2 then
return {x=pos.x-1, y=pos.y, z=pos.z}
elseif param2 == 3 then
return {x=pos.x, y=pos.y, z=pos.z+1}
end
end
end
local function hacky_swap_node(pos,name, param2)
local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
if node.name == name then
return
end
node.name = name
node.param2 = param2 or node.param2
local meta0 = meta:to_table()
minetest.env:set_node(pos,node)
meta = minetest.env:get_meta(pos)
meta:from_table(meta0)
end
default.chest_formspec =
"size[9,9.75]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
@ -45,4 +87,214 @@ minetest.register_abm({
meta:set_int("chest_inv_ver",chest_inv_vers)
end
end
})
})
minetest.register_node("default: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, decorative = 1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local param2 = minetest.env:get_node(pos).param2
local meta = minetest.env:get_meta(pos)
if minetest.env:get_node(get_chest_neighborpos(pos, param2, "right")).name == "default:chest" then
minetest.env:set_node(pos, {name="default:chest_right",param2=param2})
local p = get_chest_neighborpos(pos, param2, "right")
meta:set_string("formspec",
"size[9,11.5]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0,0;9,3;]"..
"list[current_name;main;0,3;9,3;]"..
"list[current_player;main;0,7;9,3;9]"..
"list[current_player;main;0,10.5;9,1;]")
meta:set_string("infotext", "Large Chest")
hacky_swap_node(p, "default:chest_left", param2)
local m = minetest.env:get_meta(p)
m:set_string("formspec",
"size[9,11.5]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"list[current_name;main;0,0;9,3;]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3;9,3;]"..
"list[current_player;main;0,7;9,3;9]"..
"list[current_player;main;0,10.5;9,1;]")
m:set_string("infotext", "Large Chest")
elseif minetest.env:get_node(get_chest_neighborpos(pos, param2, "left")).name == "default:chest" then
minetest.env:set_node(pos, {name="default:chest_left",param2=param2})
local p = get_chest_neighborpos(pos, param2, "left")
meta:set_string("formspec",
"size[9,11.5]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"list[current_name;main;0,0;9,3;]"..
"list[nodemeta:"..p.x..","..p.y..","..p.z..";main;0,3;9,3;]"..
"list[current_player;main;0,7;9,3;9]"..
"list[current_player;main;0,10.5;9,1;]")
meta:set_string("infotext", "Large Chest")
hacky_swap_node(p, "default:chest_right", param2)
local m = minetest.env:get_meta(p)
m:set_string("formspec",
"size[9,11.5]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0;9,3;]"..
"list[current_name;main;0,3;9,3;]"..
"list[current_player;main;0,7;9,3;9]"..
"list[current_player;main;0,10.5;9,1;]")
m:set_string("infotext", "Large Chest")
else
meta:set_string("formspec",
"size[9,8.5]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"list[current_name;main;0,0;9,3;]"..
"list[current_player;main;0,4;9,3;9]"..
"list[current_player;main;0,7.5.5;9,1;]")
meta:set_string("infotext", "Chest")
end
local inv = meta:get_inventory()
inv:set_size("main", 9*3)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.env:get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory()
for i=1,inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.env:add_item(p, stack)
end
end
meta:from_table(meta2:to_table())
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,
on_receive_fields = function(pos, formname, fields, sender)
if fields.exit then
print('test')
fields.quit = true
-- minetest.show_formspec(sender:get_player_name(), 'quit', "")
end
end
})
minetest.register_node("default:chest_left", {
tiles = {"default_chest_top_big.png", "default_chest_top_big.png", "default_chest_side.png",
"default_chest_side.png", "default_chest_side_big.png^[transformFX", "default_chest_front_big.png"},
paramtype2 = "facedir",
groups = {choppy = 2, oddly_breakable_by_hand = 2,not_in_creative_inventory=1},
drop = "default:chest",
sounds = default.node_sound_wood_defaults(),
on_destruct = function(pos)
local m = minetest.env:get_meta(pos)
if m:get_string("infotext") == "Chest" then
return
end
local param2 = minetest.env:get_node(pos).param2
local p = get_chest_neighborpos(pos, param2, "left")
if not p or minetest.env:get_node(p).name ~= "default:chest_right" then
return
end
local meta = minetest.env:get_meta(p)
meta:set_string("formspec",
"size[9,8.5]"..
"image_button_exit[8.4,-0.1;0.75,0.75;close.png;exit;;true;true;]"..
"list[current_name;main;0,0;9,3;]"..
"list[current_player;main;0,4;9,3;9]"..
"list[current_player;main;0,7.5.5;9,1;]")
meta:set_string("infotext", "Chest")
hacky_swap_node(p, "default:chest")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.env:get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory()
for i=1,inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.env:add_item(p, stack)
end
end
meta:from_table(meta2:to_table())
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,
})
minetest.register_node("default:chest_right", {
tiles = {"default_chest_top_big.png^[transformFX", "default_chest_top_big.png^[transformFX", "default_chest_side.png",
"default_chest_side.png", "default_chest_side_big.png", "default_chest_front_big.png^[transformFX"},
paramtype2 = "facedir",
groups = {choppy = 2, oddly_breakable_by_hand = 2,not_in_creative_inventory=1},
drop = "default:chest",
sounds = default.node_sound_wood_defaults(),
on_destruct = function(pos)
local m = minetest.env:get_meta(pos)
if m:get_string("infotext") == "Chest" then
return
end
local param2 = minetest.env:get_node(pos).param2
local p = get_chest_neighborpos(pos, param2, "right")
if not p or minetest.env:get_node(p).name ~= "default:chest_left" then
return
end
local meta = minetest.env:get_meta(p)
meta:set_string("formspec",
"size[9,8.5]"..
"image_button_exit[9,0;1,1;close.png;exit;;true;true;]"..
"list[current_name;main;0,0;9,3;]"..
"list[current_player;main;0,4;9,3;9]"..
"list[current_player;main;0,7.5.5;9,1;]")
meta:set_string("infotext", "Chest")
hacky_swap_node(p, "default:chest")
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local meta = minetest.env:get_meta(pos)
local meta2 = meta
meta:from_table(oldmetadata)
local inv = meta:get_inventory()
for i=1,inv:get_size("main") do
local stack = inv:get_stack("main", i)
if not stack:is_empty() then
local p = {x=pos.x+math.random(0, 10)/10-0.5, y=pos.y, z=pos.z+math.random(0, 10)/10-0.5}
minetest.env:add_item(p, stack)
end
end
meta:from_table(meta2:to_table())
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,
})

View File

@ -72,7 +72,7 @@ function default.register_ores()
-- Clay
minetest.register_ore({
minetest.register_ore({
ore_type = "blob",
ore = "default:clay",
wherein = {"default:sand"},
@ -93,7 +93,7 @@ function default.register_ores()
-- Sand
minetest.register_ore({
minetest.register_ore({
ore_type = "blob",
ore = "default:sand",
wherein = {"default:stone", "default:sandstone",
@ -427,7 +427,7 @@ function default.register_biomes()
heat_point = 15,
humidity_point = 35,
})
minetest.register_biome({
name = "tundra_beach",
--node_dust = "",
@ -902,7 +902,7 @@ function default.register_mgv6_decorations()
minetest.clear_registered_decorations()
-- Bonusbox chest
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:sand", "default:dirt_with_snow", "default:gravel",
@ -914,7 +914,7 @@ function default.register_mgv6_decorations()
y_max = 31000,
decoration = {"bonusbox:chest"},
})
-- Papyrus
minetest.register_decoration({
@ -1105,8 +1105,8 @@ function default.register_decorations()
schematic = minetest.get_modpath("default") .. "/schematics/jungle_log.mts",
flags = "place_center_x",
rotation = "random",
--spawn_by = "default:dirt_with_rainforest_litter",
num_spawn_by = 8,
-- spawn_by = "default:dirt_with_rainforest_litter",
-- num_spawn_by = 8,
})
-- Taiga and temperate coniferous forest pine tree, small pine tree and log
@ -1131,7 +1131,7 @@ function default.register_decorations()
schematic = minetest.get_modpath("default") .. "/schematics/pine_tree.mts",
flags = "place_center_x, place_center_z",
})
minetest.register_decoration({
name = "default:small_pine_tree",
deco_type = "schematic",
@ -1216,7 +1216,7 @@ function default.register_decorations()
flags = "place_center_x",
rotation = "random",
spawn_by = "default:dirt_with_dry_grass",
num_spawn_by = 8,
-- num_spawn_by = 8,
})
-- Large cactus
@ -1281,10 +1281,12 @@ function default.register_decorations()
y_min = 0,
y_max = 0,
schematic = minetest.get_modpath("default").."/schematics/papyrus.mts",
-- spawn_by = "default:dirt_with_rainforest_litter",
-- num_spawn_by = 8,
})
-- Bonusbox chest
minetest.register_decoration({
deco_type = "simple",
place_on = {"default:sand", "default:dirt_with_snow", "default:gravel",
@ -1296,7 +1298,7 @@ function default.register_decorations()
y_max = 31000,
decoration = {"bonusbox:chest"},
})
-- Grass
minetest.register_decoration({

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 223 B