Remove ipairs, lower fast speed
parent
d81f7076bd
commit
2c30633bf0
|
@ -17,7 +17,7 @@ movement_acceleration_air = 2.1
|
||||||
movement_acceleration_fast = 2.4
|
movement_acceleration_fast = 2.4
|
||||||
movement_speed_walk = 4.2
|
movement_speed_walk = 4.2
|
||||||
movement_speed_crouch = 2.1
|
movement_speed_crouch = 2.1
|
||||||
movement_speed_fast = 22
|
movement_speed_fast = 6.8
|
||||||
movement_speed_climb = 2.2
|
movement_speed_climb = 2.2
|
||||||
movement_speed_jump = 6.9
|
movement_speed_jump = 6.9
|
||||||
movement_speed_descend = 6
|
movement_speed_descend = 6
|
||||||
|
|
|
@ -75,7 +75,7 @@ end
|
||||||
|
|
||||||
function affects.player_died(player)
|
function affects.player_died(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
for _,a in ipairs(affects._removeOnDieAffects) do
|
for _,a in pairs(affects._removeOnDieAffects) do
|
||||||
affects.removeAffect(name,a)
|
affects.removeAffect(name,a)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,7 +44,7 @@ function arena.list(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function arena.in_arena(name)
|
function arena.in_arena(name)
|
||||||
for _,event in ipairs(events) do
|
for _,event in pairs(events) do
|
||||||
if ( event.participants[name] == true ) then
|
if ( event.participants[name] == true ) then
|
||||||
return event
|
return event
|
||||||
end
|
end
|
||||||
|
|
|
@ -252,7 +252,7 @@ core.register_entity(":__builtin:item", {
|
||||||
if self.physical_state then
|
if self.physical_state then
|
||||||
local own_stack = ItemStack(self.object:get_luaentity().itemstring)
|
local own_stack = ItemStack(self.object:get_luaentity().itemstring)
|
||||||
-- Merge with close entities of the same item
|
-- Merge with close entities of the same item
|
||||||
for _, object in ipairs(core.get_objects_inside_radius(p, 1.0)) do
|
for _, object in pairs(core.get_objects_inside_radius(p, 1.0)) do
|
||||||
local obj = object:get_luaentity()
|
local obj = object:get_luaentity()
|
||||||
if obj and obj.name == "__builtin:item"
|
if obj and obj.name == "__builtin:item"
|
||||||
and obj.physical_state == false then
|
and obj.physical_state == false then
|
||||||
|
|
|
@ -6,7 +6,7 @@ local BUSHES_DESCRIPTIONS = {
|
||||||
"Strawberry",
|
"Strawberry",
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, bush_name in ipairs(BUSHES) do
|
for i, bush_name in pairs(BUSHES) do
|
||||||
minetest.register_node("bushes:" .. bush_name .. "_bush", {
|
minetest.register_node("bushes:" .. bush_name .. "_bush", {
|
||||||
description = BUSHES_DESCRIPTIONS[i] .. " bush",
|
description = BUSHES_DESCRIPTIONS[i] .. " bush",
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
|
|
|
@ -176,7 +176,7 @@ minetest.register_abm({
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
for i, name in ipairs({
|
for i, name in pairs({
|
||||||
"fuel_totaltime",
|
"fuel_totaltime",
|
||||||
"fuel_time",
|
"fuel_time",
|
||||||
"src_totaltime",
|
"src_totaltime",
|
||||||
|
|
|
@ -23,7 +23,7 @@ cottages_window_sutter_operate = function( pos, old_node_state_name, new_node_st
|
||||||
local stop_up = 0;
|
local stop_up = 0;
|
||||||
local stop_down = 0;
|
local stop_down = 0;
|
||||||
|
|
||||||
for i,v in ipairs(offsets) do
|
for i,v in pairs(offsets) do
|
||||||
|
|
||||||
local node = minetest.get_node_or_nil( {x=pos.x, y=(pos.y+v), z=pos.z } );
|
local node = minetest.get_node_or_nil( {x=pos.x, y=(pos.y+v), z=pos.z } );
|
||||||
if( node and node.name and node.name==old_node_state_name
|
if( node and node.name and node.name==old_node_state_name
|
||||||
|
|
|
@ -44,7 +44,7 @@ minetest.after(0, function()
|
||||||
end
|
end
|
||||||
table.sort(creative_list)
|
table.sort(creative_list)
|
||||||
inv:set_size("main", #creative_list)
|
inv:set_size("main", #creative_list)
|
||||||
for _,itemstring in ipairs(creative_list) do
|
for _,itemstring in pairs(creative_list) do
|
||||||
inv:add_item("main", ItemStack(itemstring))
|
inv:add_item("main", ItemStack(itemstring))
|
||||||
end
|
end
|
||||||
creative_inventory.creative_inventory_size = #creative_list
|
creative_inventory.creative_inventory_size = #creative_list
|
||||||
|
@ -153,7 +153,7 @@ if minetest.setting_getbool("creative_mode") then
|
||||||
end
|
end
|
||||||
local inv = digger:get_inventory()
|
local inv = digger:get_inventory()
|
||||||
if inv then
|
if inv then
|
||||||
for _,item in ipairs(drops) do
|
for _,item in pairs(drops) do
|
||||||
item = ItemStack(item):get_name()
|
item = ItemStack(item):get_name()
|
||||||
if not inv:contains_item("main", item) then
|
if not inv:contains_item("main", item) then
|
||||||
inv:add_item("main", item)
|
inv:add_item("main", item)
|
||||||
|
|
|
@ -324,7 +324,7 @@ minetest.register_abm({
|
||||||
if not do_preserve then
|
if not do_preserve then
|
||||||
-- Drop stuff other than the node itself
|
-- Drop stuff other than the node itself
|
||||||
local itemstacks = minetest.get_node_drops(n0.name)
|
local itemstacks = minetest.get_node_drops(n0.name)
|
||||||
for _, itemname in ipairs(itemstacks) do
|
for _, itemname in pairs(itemstacks) do
|
||||||
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or
|
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or
|
||||||
itemname ~= n0.name then
|
itemname ~= n0.name then
|
||||||
local p_drop = {
|
local p_drop = {
|
||||||
|
@ -373,7 +373,7 @@ function default.dump_inv(pos,listname,inv)
|
||||||
inv = meta:get_inventory()
|
inv = meta:get_inventory()
|
||||||
end
|
end
|
||||||
if inv:get_list(listname) ~= nil then
|
if inv:get_list(listname) ~= nil then
|
||||||
for i,stack in ipairs(inv:get_list(listname)) do
|
for i,stack in pairs(inv:get_list(listname)) do
|
||||||
default.drop_item(pos,stack)
|
default.drop_item(pos,stack)
|
||||||
stack:clear()
|
stack:clear()
|
||||||
inv:set_stack(listname, i, stack)
|
inv:set_stack(listname, i, stack)
|
||||||
|
|
|
@ -1173,7 +1173,7 @@ minetest.register_abm({
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
for i, name in ipairs({
|
for i, name in pairs({
|
||||||
"fuel_totaltime",
|
"fuel_totaltime",
|
||||||
"fuel_time",
|
"fuel_time",
|
||||||
"src_totaltime",
|
"src_totaltime",
|
||||||
|
|
|
@ -81,7 +81,7 @@ dyelocal.dyes = {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Define items
|
-- Define items
|
||||||
for _, row in ipairs(dyelocal.dyes) do
|
for _, row in pairs(dyelocal.dyes) do
|
||||||
local name = row[1]
|
local name = row[1]
|
||||||
local description = row[2]
|
local description = row[2]
|
||||||
local groups = row[3]
|
local groups = row[3]
|
||||||
|
@ -123,7 +123,7 @@ dyelocal.mixes = {
|
||||||
}
|
}
|
||||||
|
|
||||||
for one,results in pairs(dyelocal.mixes) do
|
for one,results in pairs(dyelocal.mixes) do
|
||||||
for i,result in ipairs(results) do
|
for i,result in pairs(results) do
|
||||||
local another = dyelocal.mixbases[i]
|
local another = dyelocal.mixbases[i]
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
|
|
|
@ -27,7 +27,7 @@ function farming:add_plant(full_grown, names, interval, chance)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local step = nil
|
local step = nil
|
||||||
for i,name in ipairs(names) do
|
for i,name in pairs(names) do
|
||||||
if name == node.name then
|
if name == node.name then
|
||||||
step = i
|
step = i
|
||||||
break
|
break
|
||||||
|
@ -56,7 +56,7 @@ function farming:generate_tree(pos, trunk, leaves, underground, replacements)
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
local nodename = minetest.get_node(pos).name
|
local nodename = minetest.get_node(pos).name
|
||||||
local ret = true
|
local ret = true
|
||||||
for _,name in ipairs(underground) do
|
for _,name in pairs(underground) do
|
||||||
if nodename == name then
|
if nodename == name then
|
||||||
ret = false
|
ret = false
|
||||||
break
|
break
|
||||||
|
|
|
@ -262,15 +262,15 @@ local box2 = {
|
||||||
{-5, -2, -5, 5, 8, 5}
|
{-5, -2, -5, 5, 8, 5}
|
||||||
}
|
}
|
||||||
|
|
||||||
for j,list in ipairs(box1) do
|
for j,list in pairs(box1) do
|
||||||
for i,int in ipairs(list) do
|
for i,int in pairs(list) do
|
||||||
list[i] = int/16
|
list[i] = int/16
|
||||||
end
|
end
|
||||||
box1[j] = list
|
box1[j] = list
|
||||||
end
|
end
|
||||||
|
|
||||||
for j,list in ipairs(box2) do
|
for j,list in pairs(box2) do
|
||||||
for i,int in ipairs(list) do
|
for i,int in pairs(list) do
|
||||||
list[i] = int/16
|
list[i] = int/16
|
||||||
end
|
end
|
||||||
box2[j] = list
|
box2[j] = list
|
||||||
|
|
|
@ -131,7 +131,7 @@ handle_schematics.analyze_mts_file = function( path )
|
||||||
local needs_on_constr = {};
|
local needs_on_constr = {};
|
||||||
local is_air = 0;
|
local is_air = 0;
|
||||||
-- translate nodenames to ids
|
-- translate nodenames to ids
|
||||||
for i,v in ipairs( nodenames ) do
|
for i,v in pairs( nodenames ) do
|
||||||
ids[ i ] = minetest.get_content_id( v );
|
ids[ i ] = minetest.get_content_id( v );
|
||||||
needs_on_constr[ i ] = false;
|
needs_on_constr[ i ] = false;
|
||||||
if( minetest.registered_nodes[ v ] and minetest.registered_nodes[ v ].on_construct ) then
|
if( minetest.registered_nodes[ v ] and minetest.registered_nodes[ v ].on_construct ) then
|
||||||
|
|
|
@ -23,7 +23,7 @@ handle_schematics.analyze_we_file = function(scm, we_origin)
|
||||||
-- create a list of nodenames
|
-- create a list of nodenames
|
||||||
local nodenames = {};
|
local nodenames = {};
|
||||||
local nodenames_id = {};
|
local nodenames_id = {};
|
||||||
for i,ent in ipairs( nodes ) do
|
for i,ent in pairs( nodes ) do
|
||||||
if( ent and ent.name and not( nodenames_id[ ent.name ])) then
|
if( ent and ent.name and not( nodenames_id[ ent.name ])) then
|
||||||
nodenames_id[ ent.name ] = #nodenames + 1;
|
nodenames_id[ ent.name ] = #nodenames + 1;
|
||||||
nodenames[ nodenames_id[ ent.name ] ] = ent.name;
|
nodenames[ nodenames_id[ ent.name ] ] = ent.name;
|
||||||
|
|
|
@ -36,7 +36,7 @@ build_chest.add_entry = function( path )
|
||||||
end
|
end
|
||||||
|
|
||||||
local sub_menu = build_chest.menu;
|
local sub_menu = build_chest.menu;
|
||||||
for i,v in ipairs( path ) do
|
for i,v in pairs( path ) do
|
||||||
if( not( sub_menu[ v ] )) then
|
if( not( sub_menu[ v ] )) then
|
||||||
sub_menu[ v ] = {};
|
sub_menu[ v ] = {};
|
||||||
end
|
end
|
||||||
|
@ -379,7 +379,7 @@ build_chest.update_formspec = function( pos, page, player, fields )
|
||||||
|
|
||||||
-- find out where we currently are in the menu tree
|
-- find out where we currently are in the menu tree
|
||||||
local menu = build_chest.menu;
|
local menu = build_chest.menu;
|
||||||
for i,v in ipairs( current_path ) do
|
for i,v in pairs( current_path ) do
|
||||||
if( menu and menu[ v ] ) then
|
if( menu and menu[ v ] ) then
|
||||||
menu = menu[ v ];
|
menu = menu[ v ];
|
||||||
end
|
end
|
||||||
|
@ -464,7 +464,7 @@ build_chest.update_formspec = function( pos, page, player, fields )
|
||||||
-- order alphabeticly
|
-- order alphabeticly
|
||||||
table.sort( options, function(a,b) return a < b end );
|
table.sort( options, function(a,b) return a < b end );
|
||||||
|
|
||||||
for index,k in ipairs( options ) do
|
for index,k in pairs( options ) do
|
||||||
|
|
||||||
i = i+1;
|
i = i+1;
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,12 @@ end
|
||||||
-- search for mods and modpacks containing schematics in any form
|
-- search for mods and modpacks containing schematics in any form
|
||||||
local build_chest_check_all_directories_mods_and_modpacks = function( path, menu_title, gamename )
|
local build_chest_check_all_directories_mods_and_modpacks = function( path, menu_title, gamename )
|
||||||
local d2 = minetest.get_dir_list( path..'/mods', true );
|
local d2 = minetest.get_dir_list( path..'/mods', true );
|
||||||
for _,modname in ipairs( d2 ) do
|
for _,modname in pairs( d2 ) do
|
||||||
local d3 = minetest.get_dir_list( path..'/mods/'..modname, true );
|
local d3 = minetest.get_dir_list( path..'/mods/'..modname, true );
|
||||||
for _,subdir in ipairs( d3 ) do
|
for _,subdir in pairs( d3 ) do
|
||||||
if( subdir ~= 'textures' and subdir ~= 'sounds' and subdir ~= 'models' and subdir ~= '.git' and subdir ~= 'locale') then
|
if( subdir ~= 'textures' and subdir ~= 'sounds' and subdir ~= 'models' and subdir ~= '.git' and subdir ~= 'locale') then
|
||||||
local d4 = minetest.get_dir_list( path..'/mods/'..modname..'/'..subdir, false );
|
local d4 = minetest.get_dir_list( path..'/mods/'..modname..'/'..subdir, false );
|
||||||
for _,filename in ipairs( d4 ) do
|
for _,filename in pairs( d4 ) do
|
||||||
build_chest_add_files_to_menu_from_directory(
|
build_chest_add_files_to_menu_from_directory(
|
||||||
filename,
|
filename,
|
||||||
path..'/mods/'..modname..'/'..subdir..'/',
|
path..'/mods/'..modname..'/'..subdir..'/',
|
||||||
|
@ -56,10 +56,10 @@ local build_chest_check_all_directories_mods_and_modpacks = function( path, menu
|
||||||
end
|
end
|
||||||
-- it might be a modpack
|
-- it might be a modpack
|
||||||
d4 = minetest.get_dir_list( path..'/mods/'..modname..'/'..subdir, true );
|
d4 = minetest.get_dir_list( path..'/mods/'..modname..'/'..subdir, true );
|
||||||
for _,subsubdir in ipairs( d4 ) do
|
for _,subsubdir in pairs( d4 ) do
|
||||||
if( subsubdir ~= 'textures' and subsubdir ~= 'sounds' and subsubdir ~= 'models' and subsubdir ~= '.git' and subsubdir ~= 'locale') then
|
if( subsubdir ~= 'textures' and subsubdir ~= 'sounds' and subsubdir ~= 'models' and subsubdir ~= '.git' and subsubdir ~= 'locale') then
|
||||||
local d5 = minetest.get_dir_list( path..'/mods/'..modname..'/'..subdir..'/'..subsubdir, false );
|
local d5 = minetest.get_dir_list( path..'/mods/'..modname..'/'..subdir..'/'..subsubdir, false );
|
||||||
for _,filename in ipairs( d5 ) do
|
for _,filename in pairs( d5 ) do
|
||||||
build_chest_add_files_to_menu_from_directory(
|
build_chest_add_files_to_menu_from_directory(
|
||||||
filename,
|
filename,
|
||||||
path..'/mods/'..modname..'/'..subdir..'/'..subsubdir..'/',
|
path..'/mods/'..modname..'/'..subdir..'/'..subsubdir..'/',
|
||||||
|
@ -111,13 +111,13 @@ local build_chest_check_all_directories = function()
|
||||||
|
|
||||||
-- locate .mts, .wem and .we files in the worlds/WORLDNAME/schems/* folders
|
-- locate .mts, .wem and .we files in the worlds/WORLDNAME/schems/* folders
|
||||||
local d1 = minetest.get_dir_list( worldpath, true );
|
local d1 = minetest.get_dir_list( worldpath, true );
|
||||||
for _,worldname in ipairs( d1 ) do
|
for _,worldname in pairs( d1 ) do
|
||||||
-- get list of subdirectories
|
-- get list of subdirectories
|
||||||
local d2 = minetest.get_dir_list( worldpath..'/'..worldname, true );
|
local d2 = minetest.get_dir_list( worldpath..'/'..worldname, true );
|
||||||
for _,subdir in ipairs( d2 ) do
|
for _,subdir in pairs( d2 ) do
|
||||||
if( subdir=='schems' ) then
|
if( subdir=='schems' ) then
|
||||||
local d3 = minetest.get_dir_list( worldpath..'/'..worldname..'/schems', false );
|
local d3 = minetest.get_dir_list( worldpath..'/'..worldname..'/schems', false );
|
||||||
for _,filename in ipairs( d3 ) do
|
for _,filename in pairs( d3 ) do
|
||||||
build_chest_add_files_to_menu_from_directory(
|
build_chest_add_files_to_menu_from_directory(
|
||||||
filename,
|
filename,
|
||||||
worldpath..'/'..worldname..'/schems/',
|
worldpath..'/'..worldname..'/schems/',
|
||||||
|
@ -137,7 +137,7 @@ local build_chest_check_all_directories = function()
|
||||||
-- search in all GAMES/* folders for mods containing schematics
|
-- search in all GAMES/* folders for mods containing schematics
|
||||||
local game_path = main_path..'/games';
|
local game_path = main_path..'/games';
|
||||||
d1 = minetest.get_dir_list( game_path, true );
|
d1 = minetest.get_dir_list( game_path, true );
|
||||||
for _,gamename in ipairs( d1 ) do
|
for _,gamename in pairs( d1 ) do
|
||||||
build_chest_check_all_directories_mods_and_modpacks( game_path..'/'..gamename, 'import from game', gamename );
|
build_chest_check_all_directories_mods_and_modpacks( game_path..'/'..gamename, 'import from game', gamename );
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -149,7 +149,7 @@ if( minetest.setting_getbool( 'secure.enable_security' )) then
|
||||||
local worldpath = minetest.get_worldpath();
|
local worldpath = minetest.get_worldpath();
|
||||||
local d3 = minetest.get_dir_list( worldpath..'/schems', false );
|
local d3 = minetest.get_dir_list( worldpath..'/schems', false );
|
||||||
if( d3 ) then
|
if( d3 ) then
|
||||||
for _,filename in ipairs( d3 ) do
|
for _,filename in pairs( d3 ) do
|
||||||
build_chest_add_files_to_menu_from_directory(
|
build_chest_add_files_to_menu_from_directory(
|
||||||
filename,
|
filename,
|
||||||
worldpath..'/schems/',
|
worldpath..'/schems/',
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
build_chest.replacements_get_extra_buttons = function( group, name, types_found_list, button_name, extra_buttons )
|
build_chest.replacements_get_extra_buttons = function( group, name, types_found_list, button_name, extra_buttons )
|
||||||
-- find out if there are any nodes that may need a group replacement
|
-- find out if there are any nodes that may need a group replacement
|
||||||
local found_type = "";
|
local found_type = "";
|
||||||
for k,w in ipairs( replacements_group[ group ].all ) do
|
for k,w in pairs( replacements_group[ group ].all ) do
|
||||||
-- we have found the full block of that group type
|
-- we have found the full block of that group type
|
||||||
if( name == w ) then
|
if( name == w ) then
|
||||||
found_type = w;
|
found_type = w;
|
||||||
-- no primary node found; there may still be subordinate types
|
-- no primary node found; there may still be subordinate types
|
||||||
else
|
else
|
||||||
for nr,t in ipairs( replacements_group[ group ].data[ w ] ) do
|
for nr,t in pairs( replacements_group[ group ].data[ w ] ) do
|
||||||
if( name==t and not( types_found_list[ w ])) then
|
if( name==t and not( types_found_list[ w ])) then
|
||||||
found_type = w;
|
found_type = w;
|
||||||
end
|
end
|
||||||
|
@ -85,14 +85,14 @@ build_chest.replacements_get_list_formspec = function( pos, selected_row )
|
||||||
local types_found_list_roof = {};
|
local types_found_list_roof = {};
|
||||||
|
|
||||||
local not_the_first_entry = false;
|
local not_the_first_entry = false;
|
||||||
for i,v in ipairs( build_chest.building[ building_name ].statistic ) do
|
for i,v in pairs( build_chest.building[ building_name ].statistic ) do
|
||||||
local name = build_chest.building[ building_name ].nodenames[ v[1]];
|
local name = build_chest.building[ building_name ].nodenames[ v[1]];
|
||||||
-- nodes that are to be ignored do not need to be replaced
|
-- nodes that are to be ignored do not need to be replaced
|
||||||
if( name ~= 'air' and name ~= 'ignore' and name ~= 'mg:ignore' and v[2] and v[2]>0) then
|
if( name ~= 'air' and name ~= 'ignore' and name ~= 'mg:ignore' and v[2] and v[2]>0) then
|
||||||
local anz = v[2];
|
local anz = v[2];
|
||||||
-- find out if this node name gets replaced
|
-- find out if this node name gets replaced
|
||||||
local repl = name;
|
local repl = name;
|
||||||
for j,r in ipairs( replacements ) do
|
for j,r in pairs( replacements ) do
|
||||||
if( r and r[1]==name ) then
|
if( r and r[1]==name ) then
|
||||||
repl = r[2];
|
repl = r[2];
|
||||||
end
|
end
|
||||||
|
@ -172,13 +172,13 @@ build_chest.replacements_replace_rest_with_air = function( pos, meta )
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
local replacements_orig = minetest.deserialize( meta:get_string( 'replacements' ));
|
local replacements_orig = minetest.deserialize( meta:get_string( 'replacements' ));
|
||||||
for i,v in ipairs( build_chest.building[ building_name ].statistic ) do
|
for i,v in pairs( build_chest.building[ building_name ].statistic ) do
|
||||||
local name = build_chest.building[ building_name ].nodenames[ v[1]];
|
local name = build_chest.building[ building_name ].nodenames[ v[1]];
|
||||||
-- nodes that are to be ignored do not need to be replaced
|
-- nodes that are to be ignored do not need to be replaced
|
||||||
if( name ~= 'air' and name ~= 'ignore' and name ~= 'mg:ignore' and v[2] and v[2]>0) then
|
if( name ~= 'air' and name ~= 'ignore' and name ~= 'mg:ignore' and v[2] and v[2]>0) then
|
||||||
-- find out if this node name gets replaced
|
-- find out if this node name gets replaced
|
||||||
local repl = name;
|
local repl = name;
|
||||||
for j,r in ipairs( replacements_orig ) do
|
for j,r in pairs( replacements_orig ) do
|
||||||
if( r and r[1]==name ) then
|
if( r and r[1]==name ) then
|
||||||
repl = r[2];
|
repl = r[2];
|
||||||
-- set replacements for inexisting nodes to air
|
-- set replacements for inexisting nodes to air
|
||||||
|
@ -207,7 +207,7 @@ build_chest.replacements_apply = function( pos, meta, old_material, new_material
|
||||||
-- only accept replacements which can actually be placed
|
-- only accept replacements which can actually be placed
|
||||||
if( new_material=='air' or minetest.registered_nodes[ new_material ] ) then
|
if( new_material=='air' or minetest.registered_nodes[ new_material ] ) then
|
||||||
local replacements_orig = minetest.deserialize( meta:get_string( 'replacements' ));
|
local replacements_orig = minetest.deserialize( meta:get_string( 'replacements' ));
|
||||||
for i,v in ipairs(replacements_orig) do
|
for i,v in pairs(replacements_orig) do
|
||||||
if( v and v[1]==old_material ) then
|
if( v and v[1]==old_material ) then
|
||||||
v[2] = new_material;
|
v[2] = new_material;
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -224,7 +224,7 @@ end
|
||||||
|
|
||||||
build_chest.replacements_get_group_list_formspec = function( pos, group, button_name )
|
build_chest.replacements_get_group_list_formspec = function( pos, group, button_name )
|
||||||
local formspec = "";
|
local formspec = "";
|
||||||
for i,v in ipairs( replacements_group[ group ].found ) do
|
for i,v in pairs( replacements_group[ group ].found ) do
|
||||||
formspec = formspec.."item_image_button["..tostring(((i-1)%8)+1)..","..
|
formspec = formspec.."item_image_button["..tostring(((i-1)%8)+1)..","..
|
||||||
tostring(3+math.floor((i-1)/8))..";1,1;"..
|
tostring(3+math.floor((i-1)/8))..";1,1;"..
|
||||||
tostring( v )..";"..tostring( button_name )..";"..tostring(i).."]";
|
tostring( v )..";"..tostring( button_name )..";"..tostring(i).."]";
|
||||||
|
|
|
@ -134,7 +134,7 @@ build_chest.preview_image_formspec = function( building_name, replacements, side
|
||||||
|
|
||||||
local side_names = {"front","right","back","left","top"};
|
local side_names = {"front","right","back","left","top"};
|
||||||
local side = 1;
|
local side = 1;
|
||||||
for i,v in ipairs( side_names ) do
|
for i,v in pairs( side_names ) do
|
||||||
if( side_name and side_name==v ) then
|
if( side_name and side_name==v ) then
|
||||||
side = i;
|
side = i;
|
||||||
end
|
end
|
||||||
|
@ -154,9 +154,9 @@ build_chest.preview_image_formspec = function( building_name, replacements, side
|
||||||
|
|
||||||
-- the draw_tile function is based on content_id
|
-- the draw_tile function is based on content_id
|
||||||
local content_ids = {};
|
local content_ids = {};
|
||||||
for i,v in ipairs( data.nodenames ) do
|
for i,v in pairs( data.nodenames ) do
|
||||||
local found = false;
|
local found = false;
|
||||||
for j,w in ipairs( replacements ) do
|
for j,w in pairs( replacements ) do
|
||||||
if( w and w[1] and w[1]==v) then
|
if( w and w[1] and w[1]==v) then
|
||||||
found = true;
|
found = true;
|
||||||
if( minetest.registered_nodes[ w[2]] ) then
|
if( minetest.registered_nodes[ w[2]] ) then
|
||||||
|
@ -203,8 +203,8 @@ build_chest.preview_image_formspec = function( building_name, replacements, side
|
||||||
formspec = formspec.."label[3,3;Sorry, this schematic is too big for a preview image.]";
|
formspec = formspec.."label[3,3;Sorry, this schematic is too big for a preview image.]";
|
||||||
return formspec;
|
return formspec;
|
||||||
end
|
end
|
||||||
for y,y_values in ipairs( preview ) do
|
for y,y_values in pairs( preview ) do
|
||||||
for l,v in ipairs( y_values ) do
|
for l,v in pairs( y_values ) do
|
||||||
-- air, ignore and mg:ignore are not stored
|
-- air, ignore and mg:ignore are not stored
|
||||||
if( v and content_ids[ v ]==-1 ) then
|
if( v and content_ids[ v ]==-1 ) then
|
||||||
formspec = formspec..build_chest.preview_image_draw_tile( nil, "unknown_node.png", (l*scale), 9-(y*scale), scale*1.3, scale*1.2, tile_nr);
|
formspec = formspec..build_chest.preview_image_draw_tile( nil, "unknown_node.png", (l*scale), 9-(y*scale), scale*1.3, scale*1.2, tile_nr);
|
||||||
|
|
|
@ -30,7 +30,7 @@ local handle_schematics_get_meta_table = function( pos, all_meta, start_pos )
|
||||||
for name, list in pairs( m.inventory ) do
|
for name, list in pairs( m.inventory ) do
|
||||||
invlist[ name ] = {};
|
invlist[ name ] = {};
|
||||||
count_inv = count_inv + 1;
|
count_inv = count_inv + 1;
|
||||||
for i, stack in ipairs(list) do
|
for i, stack in pairs(list) do
|
||||||
if( not( stack:is_empty())) then
|
if( not( stack:is_empty())) then
|
||||||
invlist[ name ][ i ] = stack:to_string();
|
invlist[ name ][ i ] = stack:to_string();
|
||||||
empty_meta = false;
|
empty_meta = false;
|
||||||
|
@ -90,7 +90,7 @@ handle_schematics.save_meta = function( start_pos, end_pos, filename )
|
||||||
local p = handle_schematics.sort_pos_get_size( start_pos, end_pos );
|
local p = handle_schematics.sort_pos_get_size( start_pos, end_pos );
|
||||||
|
|
||||||
if( minetest.find_nodes_with_meta ) then
|
if( minetest.find_nodes_with_meta ) then
|
||||||
for _,pos in ipairs( minetest.find_nodes_with_meta( start_pos, end_pos )) do
|
for _,pos in pairs( minetest.find_nodes_with_meta( start_pos, end_pos )) do
|
||||||
handle_schematics_get_meta_table( pos, all_meta, p );
|
handle_schematics_get_meta_table( pos, all_meta, p );
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -114,7 +114,7 @@ handle_schematics.clear_meta = function( start_pos, end_pos )
|
||||||
local empty_meta = { inventory = {}, fields = {} };
|
local empty_meta = { inventory = {}, fields = {} };
|
||||||
|
|
||||||
if( minetest.find_nodes_with_meta ) then
|
if( minetest.find_nodes_with_meta ) then
|
||||||
for _,pos in ipairs( minetest.find_nodes_with_meta( start_pos, end_pos )) do
|
for _,pos in pairs( minetest.find_nodes_with_meta( start_pos, end_pos )) do
|
||||||
local meta = minetest.get_meta( pos );
|
local meta = minetest.get_meta( pos );
|
||||||
meta:from_table( empty_meta );
|
meta:from_table( empty_meta );
|
||||||
end
|
end
|
||||||
|
@ -130,7 +130,7 @@ handle_schematics.restore_meta = function( filename, all_meta, start_pos, end_po
|
||||||
if( not( all_meta ) and filename ) then
|
if( not( all_meta ) and filename ) then
|
||||||
all_meta = save_restore.restore_data( 'schems/'..filename..'.meta' );
|
all_meta = save_restore.restore_data( 'schems/'..filename..'.meta' );
|
||||||
end
|
end
|
||||||
for _,pos in ipairs( all_meta ) do
|
for _,pos in pairs( all_meta ) do
|
||||||
local p = {};
|
local p = {};
|
||||||
if( rotate == 0 ) then
|
if( rotate == 0 ) then
|
||||||
p = {x=start_pos.x+pos.x-1, y=start_pos.y+pos.y-1, z=start_pos.z+pos.z-1};
|
p = {x=start_pos.x+pos.x-1, y=start_pos.y+pos.y-1, z=start_pos.z+pos.z-1};
|
||||||
|
|
|
@ -140,7 +140,7 @@ local function generate_building_translate_nodenames( nodenames, replacements, c
|
||||||
local i;
|
local i;
|
||||||
local v;
|
local v;
|
||||||
local new_nodes = {};
|
local new_nodes = {};
|
||||||
for i,node_name in ipairs( nodenames ) do
|
for i,node_name in pairs( nodenames ) do
|
||||||
|
|
||||||
new_nodes[ i ] = {}; -- array for collecting information about the new content id for nodes with number "i" in their .mts savefile
|
new_nodes[ i ] = {}; -- array for collecting information about the new content id for nodes with number "i" in their .mts savefile
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ handle_schematics.place_buildings = function(village, minp, maxp, data, param2_d
|
||||||
local extranodes = {}
|
local extranodes = {}
|
||||||
local extra_calls = { on_constr = {}, trees = {}, chests = {}, signs = {}, traders = {} };
|
local extra_calls = { on_constr = {}, trees = {}, chests = {}, signs = {}, traders = {} };
|
||||||
|
|
||||||
for i, pos in ipairs(bpos) do
|
for i, pos in pairs(bpos) do
|
||||||
-- roads are only placed if there are at least mg_villages.MINIMAL_BUILDUNGS_FOR_ROAD_PLACEMENT buildings in the village
|
-- roads are only placed if there are at least mg_villages.MINIMAL_BUILDUNGS_FOR_ROAD_PLACEMENT buildings in the village
|
||||||
if( not(pos.btype) or pos.btype ~= 'road' or village.anz_buildings > mg_villages.MINIMAL_BUILDUNGS_FOR_ROAD_PLACEMENT )then
|
if( not(pos.btype) or pos.btype ~= 'road' or village.anz_buildings > mg_villages.MINIMAL_BUILDUNGS_FOR_ROAD_PLACEMENT )then
|
||||||
-- replacements are in table format for mapgen-based building spawning
|
-- replacements are in table format for mapgen-based building spawning
|
||||||
|
@ -762,7 +762,7 @@ handle_schematics.place_building_from_file = function( start_pos, end_pos, build
|
||||||
for k, v in pairs( res.extra_calls.on_constr ) do
|
for k, v in pairs( res.extra_calls.on_constr ) do
|
||||||
local node_name = minetest.get_name_from_content_id( k );
|
local node_name = minetest.get_name_from_content_id( k );
|
||||||
if( minetest.registered_nodes[ node_name ].on_construct ) then
|
if( minetest.registered_nodes[ node_name ].on_construct ) then
|
||||||
for _, pos in ipairs(v) do
|
for _, pos in pairs(v) do
|
||||||
minetest.registered_nodes[ node_name ].on_construct( pos );
|
minetest.registered_nodes[ node_name ].on_construct( pos );
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -783,7 +783,7 @@ end
|
||||||
-- add the dirt roads
|
-- add the dirt roads
|
||||||
handle_schematics.place_dirt_roads = function(village, minp, maxp, data, param2_data, a, c_road_node)
|
handle_schematics.place_dirt_roads = function(village, minp, maxp, data, param2_data, a, c_road_node)
|
||||||
local c_air = minetest.get_content_id( 'air' );
|
local c_air = minetest.get_content_id( 'air' );
|
||||||
for _, pos in ipairs(village.to_add_data.dirt_roads) do
|
for _, pos in pairs(village.to_add_data.dirt_roads) do
|
||||||
handle_schematics.place_road( minp, maxp, data, param2_data, a, c_road_node, pos, c_air );
|
handle_schematics.place_road( minp, maxp, data, param2_data, a, c_road_node, pos, c_air );
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ replacements_group['farming'].replace_material = function( replacements, old_mat
|
||||||
if( i<=#new_nodes and new_nodes[i] and minetest.registered_nodes[ new_nodes[i]] ) then
|
if( i<=#new_nodes and new_nodes[i] and minetest.registered_nodes[ new_nodes[i]] ) then
|
||||||
new = new_nodes[i];
|
new = new_nodes[i];
|
||||||
local found = false;
|
local found = false;
|
||||||
for i,v in ipairs(replacements) do
|
for i,v in pairs(replacements) do
|
||||||
if( v and v[1]==old ) then
|
if( v and v[1]==old ) then
|
||||||
v[2] = new;
|
v[2] = new;
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -90,7 +90,7 @@ replacements_group['farming'].add_material = function( fruit, fruit_item, prefix
|
||||||
|
|
||||||
-- farming nodes do not count as ground (except for soil - which is not handled here)
|
-- farming nodes do not count as ground (except for soil - which is not handled here)
|
||||||
local c_ignore = minetest.get_content_id( 'ignore' );
|
local c_ignore = minetest.get_content_id( 'ignore' );
|
||||||
for _,v in ipairs( data ) do
|
for _,v in pairs( data ) do
|
||||||
local id = minetest.get_content_id( v );
|
local id = minetest.get_content_id( v );
|
||||||
if( id and id ~= c_ignore ) then
|
if( id and id ~= c_ignore ) then
|
||||||
replacements_group.node_is_ground[ id ] = false;
|
replacements_group.node_is_ground[ id ] = false;
|
||||||
|
@ -150,7 +150,7 @@ replacements_group['farming'].construct_farming_type_list = function()
|
||||||
'potato','potatoe', -- diffrent mods spell them diffrently
|
'potato','potatoe', -- diffrent mods spell them diffrently
|
||||||
'tomato', 'corn'
|
'tomato', 'corn'
|
||||||
};
|
};
|
||||||
for i,fruit in ipairs( fruits ) do
|
for i,fruit in pairs( fruits ) do
|
||||||
if( minetest.registered_nodes[ 'farming_plus:'..fruit ]
|
if( minetest.registered_nodes[ 'farming_plus:'..fruit ]
|
||||||
and minetest.registered_nodes[ 'farming_plus:'..fruit..'_1' ]
|
and minetest.registered_nodes[ 'farming_plus:'..fruit..'_1' ]
|
||||||
and minetest.registered_items[ 'farming_plus:'..fruit..'_item' ] ) then
|
and minetest.registered_items[ 'farming_plus:'..fruit..'_item' ] ) then
|
||||||
|
@ -162,7 +162,7 @@ replacements_group['farming'].construct_farming_type_list = function()
|
||||||
|
|
||||||
-- Docfarming: https://forum.minetest.net/viewtopic.php?t=3948
|
-- Docfarming: https://forum.minetest.net/viewtopic.php?t=3948
|
||||||
fruits = {'carrot','corn','potato','raspberry'};
|
fruits = {'carrot','corn','potato','raspberry'};
|
||||||
for i,fruit in ipairs( fruits ) do
|
for i,fruit in pairs( fruits ) do
|
||||||
replacements_group['farming'].add_material( fruit, 'docfarming:'..fruit, 'docfarming:', '', '' );
|
replacements_group['farming'].add_material( fruit, 'docfarming:'..fruit, 'docfarming:', '', '' );
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ handle_schematics.get_replacement_table = function( housetype, pr, replacements
|
||||||
if( minetest.registered_nodes[ 'mg_villages:torch']) then
|
if( minetest.registered_nodes[ 'mg_villages:torch']) then
|
||||||
table.insert( replacements, {'default:torch', 'mg_villages:torch'});
|
table.insert( replacements, {'default:torch', 'mg_villages:torch'});
|
||||||
end
|
end
|
||||||
for i,v in ipairs( replacements ) do
|
for i,v in pairs( replacements ) do
|
||||||
if( v and #v == 2 ) then
|
if( v and #v == 2 ) then
|
||||||
rtable[ v[1] ] = v[2];
|
rtable[ v[1] ] = v[2];
|
||||||
ids[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] );
|
ids[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] );
|
||||||
|
|
|
@ -63,10 +63,10 @@ replacements_group['realtest'].replace = function( replacements )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
for i,v in ipairs( repl ) do
|
for i,v in pairs( repl ) do
|
||||||
if( v and v[2] and minetest.registered_nodes[ v[2]] ) then
|
if( v and v[2] and minetest.registered_nodes[ v[2]] ) then
|
||||||
local found = false;
|
local found = false;
|
||||||
for j,w in ipairs( replacements ) do
|
for j,w in pairs( replacements ) do
|
||||||
if( w and w[1] and w[1]==v[1] ) then
|
if( w and w[1] and w[1]==v[1] ) then
|
||||||
w[2] = v[2];
|
w[2] = v[2];
|
||||||
found = true;
|
found = true;
|
||||||
|
|
|
@ -26,7 +26,7 @@ replacements_group['roof'].replace_material = function( replacements, old_materi
|
||||||
if( i<=#new_nodes and new_nodes[i] and minetest.registered_nodes[ new_nodes[i]] ) then
|
if( i<=#new_nodes and new_nodes[i] and minetest.registered_nodes[ new_nodes[i]] ) then
|
||||||
new = new_nodes[i];
|
new = new_nodes[i];
|
||||||
local found = false;
|
local found = false;
|
||||||
for i,v in ipairs(replacements) do
|
for i,v in pairs(replacements) do
|
||||||
if( v and v[1]==old ) then
|
if( v and v[1]==old ) then
|
||||||
v[2] = new;
|
v[2] = new;
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -64,7 +64,7 @@ replacements_group['roof'].construct_roof_type_list = function()
|
||||||
|
|
||||||
-- roof from cottages
|
-- roof from cottages
|
||||||
local roofs = {'straw', 'reet', 'wood', 'slate', 'red', 'brown', 'black'};
|
local roofs = {'straw', 'reet', 'wood', 'slate', 'red', 'brown', 'black'};
|
||||||
for i,v in ipairs( roofs ) do
|
for i,v in pairs( roofs ) do
|
||||||
replacements_group['roof'].add_material( {
|
replacements_group['roof'].add_material( {
|
||||||
'cottages:roof_connector_'..v,
|
'cottages:roof_connector_'..v,
|
||||||
'cottages:roof_flat_'..v,
|
'cottages:roof_flat_'..v,
|
||||||
|
@ -76,7 +76,7 @@ replacements_group['roof'].construct_roof_type_list = function()
|
||||||
|
|
||||||
-- from dryplants
|
-- from dryplants
|
||||||
roofs = {'reed', 'wetreed'};
|
roofs = {'reed', 'wetreed'};
|
||||||
for i,v in ipairs( roofs ) do
|
for i,v in pairs( roofs ) do
|
||||||
replacements_group['roof'].add_material( {
|
replacements_group['roof'].add_material( {
|
||||||
'dryplants:'..v..'_roof',
|
'dryplants:'..v..'_roof',
|
||||||
'dryplants:'..v..'_slab',
|
'dryplants:'..v..'_slab',
|
||||||
|
@ -88,7 +88,7 @@ replacements_group['roof'].construct_roof_type_list = function()
|
||||||
end
|
end
|
||||||
-- roof from homedecor
|
-- roof from homedecor
|
||||||
roofs = {'wood', 'terracotta', 'asphalt', 'glass'};
|
roofs = {'wood', 'terracotta', 'asphalt', 'glass'};
|
||||||
for i,v in ipairs( roofs ) do
|
for i,v in pairs( roofs ) do
|
||||||
replacements_group['roof'].add_material( {
|
replacements_group['roof'].add_material( {
|
||||||
'homedecor:shingle_side_'..v,
|
'homedecor:shingle_side_'..v,
|
||||||
'homedecor:shingles_'..v,
|
'homedecor:shingles_'..v,
|
||||||
|
|
|
@ -33,7 +33,7 @@ replacements_group['wood'].replace_material = function( replacements, old_wood,
|
||||||
if( i<=#new_nodes and new_nodes[i] and minetest.registered_nodes[ new_nodes[i]] ) then
|
if( i<=#new_nodes and new_nodes[i] and minetest.registered_nodes[ new_nodes[i]] ) then
|
||||||
new = new_nodes[i];
|
new = new_nodes[i];
|
||||||
local found = false;
|
local found = false;
|
||||||
for i,v in ipairs(replacements) do
|
for i,v in pairs(replacements) do
|
||||||
if( v and v[1]==old ) then
|
if( v and v[1]==old ) then
|
||||||
v[2] = new;
|
v[2] = new;
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -59,7 +59,7 @@ replacements_group['wood'].add_material = function( candidate_list, mod_prefix,
|
||||||
if( not( candidate_list )) then
|
if( not( candidate_list )) then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
for _,v in ipairs( candidate_list ) do
|
for _,v in pairs( candidate_list ) do
|
||||||
local is_loaded = false;
|
local is_loaded = false;
|
||||||
local wood_name = mod_prefix..w_pre..v..w_post;
|
local wood_name = mod_prefix..w_pre..v..w_post;
|
||||||
-- create a complete list of all possible wood names
|
-- create a complete list of all possible wood names
|
||||||
|
@ -120,7 +120,7 @@ replacements_group['wood'].add_material = function( candidate_list, mod_prefix,
|
||||||
|
|
||||||
-- none of the wood nodes counts as ground
|
-- none of the wood nodes counts as ground
|
||||||
local c_ignore = minetest.get_content_id( 'ignore' );
|
local c_ignore = minetest.get_content_id( 'ignore' );
|
||||||
for _,v in ipairs( data ) do
|
for _,v in pairs( data ) do
|
||||||
local id = minetest.get_content_id( v );
|
local id = minetest.get_content_id( v );
|
||||||
if( id and id ~= c_ignore ) then
|
if( id and id ~= c_ignore ) then
|
||||||
replacements_group.node_is_ground[ id ] = false;
|
replacements_group.node_is_ground[ id ] = false;
|
||||||
|
|
|
@ -61,7 +61,7 @@ handle_schematics.add_mirrored_node_type = function( name, mirrored_name )
|
||||||
end
|
end
|
||||||
|
|
||||||
local door_materials = {'wood','steel','glass','obsidian_glass'};
|
local door_materials = {'wood','steel','glass','obsidian_glass'};
|
||||||
for _,material in ipairs( door_materials ) do
|
for _,material in pairs( door_materials ) do
|
||||||
handle_schematics.add_mirrored_node_type( 'doors:door_'..material..'_b_1', 'doors:door_'..material..'_b_2' );
|
handle_schematics.add_mirrored_node_type( 'doors:door_'..material..'_b_1', 'doors:door_'..material..'_b_2' );
|
||||||
handle_schematics.add_mirrored_node_type( 'doors:door_'..material..'_t_1', 'doors:door_'..material..'_t_2' );
|
handle_schematics.add_mirrored_node_type( 'doors:door_'..material..'_t_1', 'doors:door_'..material..'_t_2' );
|
||||||
handle_schematics.add_mirrored_node_type( 'doors:door_'..material..'_b_2', 'doors:door_'..material..'_b_1' );
|
handle_schematics.add_mirrored_node_type( 'doors:door_'..material..'_b_2', 'doors:door_'..material..'_b_1' );
|
||||||
|
|
|
@ -82,7 +82,7 @@ function worldedit_file.load_schematic(value, we_origin)
|
||||||
nodes = tables[1]
|
nodes = tables[1]
|
||||||
|
|
||||||
if version == 1 then --original flat table format
|
if version == 1 then --original flat table format
|
||||||
for i, entry in ipairs(nodes) do
|
for i, entry in pairs(nodes) do
|
||||||
local pos = entry[1]
|
local pos = entry[1]
|
||||||
entry.x, entry.y, entry.z = pos.x, pos.y, pos.z
|
entry.x, entry.y, entry.z = pos.x, pos.y, pos.z
|
||||||
entry[1] = nil
|
entry[1] = nil
|
||||||
|
|
|
@ -92,7 +92,7 @@ if minetest.get_modpath("bushes_classic") then
|
||||||
"raspberry",
|
"raspberry",
|
||||||
"gooseberry",
|
"gooseberry",
|
||||||
"mixed_berry"}
|
"mixed_berry"}
|
||||||
for _, berry in ipairs(berries) do
|
for _, berry in pairs(berries) do
|
||||||
if berry ~= "mixed_berry" then
|
if berry ~= "mixed_berry" then
|
||||||
register_food("bushes:"..berry, 1)
|
register_food("bushes:"..berry, 1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ function itemdrop_globalstep(player,name,dtime)
|
||||||
pos.y = pos.y+0.5
|
pos.y = pos.y+0.5
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
|
||||||
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
|
for _,object in pairs(minetest.env:get_objects_inside_radius(pos, 1)) do
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
|
||||||
|
@ -20,7 +20,7 @@ function itemdrop_globalstep(player,name,dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
|
for _,object in pairs(minetest.env:get_objects_inside_radius(pos, 2)) do
|
||||||
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
|
||||||
if object:get_luaentity().collect then
|
if object:get_luaentity().collect then
|
||||||
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
|
||||||
|
|
|
@ -11,7 +11,7 @@ local thunder = {
|
||||||
local rad = 15 * ( sk.level / 10 )
|
local rad = 15 * ( sk.level / 10 )
|
||||||
local damage = ( 25 * ( sk.level / skb.max_level ) )
|
local damage = ( 25 * ( sk.level / skb.max_level ) )
|
||||||
minetest.sound_play("magic_thunder",{object=p})
|
minetest.sound_play("magic_thunder",{object=p})
|
||||||
for _,obj in ipairs(minetest.get_objects_inside_radius(p:getpos(), rad)) do
|
for _,obj in pairs(minetest.get_objects_inside_radius(p:getpos(), rad)) do
|
||||||
if p ~= obj then
|
if p ~= obj then
|
||||||
obj:punch(p, 1.0, {
|
obj:punch(p, 1.0, {
|
||||||
full_punch_interval=1.0,
|
full_punch_interval=1.0,
|
||||||
|
|
|
@ -43,7 +43,7 @@ minetest.register_on_generated( function (minp, maxp, blockseed)
|
||||||
local spawn = {}
|
local spawn = {}
|
||||||
local chests = {}
|
local chests = {}
|
||||||
local c = 0
|
local c = 0
|
||||||
for k,v in ipairs(notify.dungeon) do
|
for k,v in pairs(notify.dungeon) do
|
||||||
--print(minetest.pos_to_string(v))
|
--print(minetest.pos_to_string(v))
|
||||||
-- find the size of this room
|
-- find the size of this room
|
||||||
--if v.y < 0 then
|
--if v.y < 0 then
|
||||||
|
@ -153,16 +153,16 @@ minetest.register_on_generated( function (minp, maxp, blockseed)
|
||||||
vm:set_data(data)
|
vm:set_data(data)
|
||||||
vm:calc_lighting()
|
vm:calc_lighting()
|
||||||
vm:write_to_map(data)
|
vm:write_to_map(data)
|
||||||
for _,v in ipairs(spawn) do
|
for _,v in pairs(spawn) do
|
||||||
mobs:spawn_mob(v.pos,v.mob)
|
mobs:spawn_mob(v.pos,v.mob)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,cpos in ipairs(chests) do
|
for _,cpos in pairs(chests) do
|
||||||
minetest.place_node(cpos,{name="default:chest"})
|
minetest.place_node(cpos,{name="default:chest"})
|
||||||
local meta = minetest.get_meta( cpos );
|
local meta = minetest.get_meta( cpos );
|
||||||
local inv = meta:get_inventory();
|
local inv = meta:get_inventory();
|
||||||
inv:add_item("main","quests:dungeon_token")
|
inv:add_item("main","quests:dungeon_token")
|
||||||
for _,item in ipairs(dungeon_chest) do
|
for _,item in pairs(dungeon_chest) do
|
||||||
if randomChance(item[2]) then
|
if randomChance(item[2]) then
|
||||||
local qty = math.random(1,item[3])
|
local qty = math.random(1,item[3])
|
||||||
inv:add_item("main", item[1].." "..tostring(qty))
|
inv:add_item("main", item[1].." "..tostring(qty))
|
||||||
|
@ -173,7 +173,7 @@ minetest.register_on_generated( function (minp, maxp, blockseed)
|
||||||
|
|
||||||
if notify.temple ~= nil then
|
if notify.temple ~= nil then
|
||||||
minetest.log("info","Temple generated")
|
minetest.log("info","Temple generated")
|
||||||
for k,v in ipairs(notify.temple) do
|
for k,v in pairs(notify.temple) do
|
||||||
minetest.log("info",minetest.pos_to_string(v))
|
minetest.log("info",minetest.pos_to_string(v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -367,7 +367,7 @@ mg_villages.add_building = function( building_data )
|
||||||
local building_id = building_data.sizex..'x'..building_data.sizez..'_'..building_data.scm;
|
local building_id = building_data.sizex..'x'..building_data.sizez..'_'..building_data.scm;
|
||||||
-- if the building is new, it will get the next free id
|
-- if the building is new, it will get the next free id
|
||||||
local building_nr = #mg_villages.all_buildings_list + 1;
|
local building_nr = #mg_villages.all_buildings_list + 1;
|
||||||
for i,v in ipairs( mg_villages.all_buildings_list ) do
|
for i,v in pairs( mg_villages.all_buildings_list ) do
|
||||||
if( v==building_id ) then
|
if( v==building_id ) then
|
||||||
-- we found the building
|
-- we found the building
|
||||||
building_nr = i;
|
building_nr = i;
|
||||||
|
@ -420,7 +420,7 @@ mg_villages.all_buildings_list = save_restore.restore_data( 'mg_villages_all_bu
|
||||||
mg_villages.BUILDINGS = {};
|
mg_villages.BUILDINGS = {};
|
||||||
local mts_path = mg_villages.modpath.."/schems/";
|
local mts_path = mg_villages.modpath.."/schems/";
|
||||||
-- determine the size of the given houses and other necessary values
|
-- determine the size of the given houses and other necessary values
|
||||||
for i,v in ipairs( buildings ) do
|
for i,v in pairs( buildings ) do
|
||||||
v.mts_path = mts_path;
|
v.mts_path = mts_path;
|
||||||
mg_villages.add_building( v, i );
|
mg_villages.add_building( v, i );
|
||||||
end
|
end
|
||||||
|
|
|
@ -177,7 +177,7 @@ mg_villages.fill_chest_random = function( pos, pr, building_nr, building_typ )
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
local inv_size = inv:get_size('main');
|
local inv_size = inv:get_size('main');
|
||||||
for i,v in ipairs( mg_villages.random_chest_content ) do
|
for i,v in pairs( mg_villages.random_chest_content ) do
|
||||||
-- repeat this many times
|
-- repeat this many times
|
||||||
for count=1, v[ 4 ] do
|
for count=1, v[ 4 ] do
|
||||||
-- to avoid too many things inside a chest, lower probability
|
-- to avoid too many things inside a chest, lower probability
|
||||||
|
|
|
@ -15,10 +15,10 @@ mg_villages.init_weights = function()
|
||||||
mg_villages.village_types[ #mg_villages.village_types+1 ] = 'single';
|
mg_villages.village_types[ #mg_villages.village_types+1 ] = 'single';
|
||||||
mg_villages.village_types[ #mg_villages.village_types+1 ] = 'fields';
|
mg_villages.village_types[ #mg_villages.village_types+1 ] = 'fields';
|
||||||
mg_villages.village_types[ #mg_villages.village_types+1 ] = 'tower';
|
mg_villages.village_types[ #mg_villages.village_types+1 ] = 'tower';
|
||||||
for j,v in ipairs( mg_villages.village_types ) do
|
for j,v in pairs( mg_villages.village_types ) do
|
||||||
|
|
||||||
local total_weight = 0
|
local total_weight = 0
|
||||||
for _, i in ipairs(mg_villages.BUILDINGS) do
|
for _, i in pairs(mg_villages.BUILDINGS) do
|
||||||
if( not( i.max_weight )) then
|
if( not( i.max_weight )) then
|
||||||
i.max_weight = {};
|
i.max_weight = {};
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ mg_villages.init_weights = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local multiplier = 3000/total_weight
|
local multiplier = 3000/total_weight
|
||||||
for _,i in ipairs(mg_villages.BUILDINGS) do
|
for _,i in pairs(mg_villages.BUILDINGS) do
|
||||||
if( i.weight and i.weight[ v ] and i.weight[ v ]>0 ) then
|
if( i.weight and i.weight[ v ] and i.weight[ v ]>0 ) then
|
||||||
i.max_weight[v] = i.max_weight[ v ]*multiplier
|
i.max_weight[v] = i.max_weight[ v ]*multiplier
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,7 +79,7 @@ mg_villages.map_of_world = function( pname )
|
||||||
if( type( surface_types )=='table' and false) then -- TODO: disabled for now
|
if( type( surface_types )=='table' and false) then -- TODO: disabled for now
|
||||||
dx = dx/5;
|
dx = dx/5;
|
||||||
dz = dz/5;
|
dz = dz/5;
|
||||||
for i,v in ipairs( surface_types ) do
|
for i,v in pairs( surface_types ) do
|
||||||
if( v ~= content_id ) then
|
if( v ~= content_id ) then
|
||||||
local x2 = x1+( math.floor( (i-1)/5 )*dx);
|
local x2 = x1+( math.floor( (i-1)/5 )*dx);
|
||||||
local z2 = z1+( math.floor( (i-1)%5 )*dz);
|
local z2 = z1+( math.floor( (i-1)%5 )*dz);
|
||||||
|
@ -161,7 +161,7 @@ mg_villages.map_of_world = function( pname )
|
||||||
formspec = formspec.."label[10,-0.4;Village types:]";
|
formspec = formspec.."label[10,-0.4;Village types:]";
|
||||||
-- explain the meaning of the textures
|
-- explain the meaning of the textures
|
||||||
if mg_villages.village_types ~= nil then
|
if mg_villages.village_types ~= nil then
|
||||||
for _,typ in ipairs(mg_villages.village_types) do
|
for _,typ in pairs(mg_villages.village_types) do
|
||||||
formspec = formspec.."label[10.5,"..tostring(i)..";"..tostring( typ ).."]"..
|
formspec = formspec.."label[10.5,"..tostring(i)..";"..tostring( typ ).."]"..
|
||||||
"image[10.0,"..tostring(i+0.1)..";0.4,0.4;"..tostring( mg_villages.village_type_data[ typ ].texture ).."]";
|
"image[10.0,"..tostring(i+0.1)..";0.4,0.4;"..tostring( mg_villages.village_type_data[ typ ].texture ).."]";
|
||||||
i = i+0.45;
|
i = i+0.45;
|
||||||
|
|
|
@ -84,7 +84,7 @@ mg_villages.villages_in_mapchunk = function( minp, mapchunk_size )
|
||||||
local villages = {}
|
local villages = {}
|
||||||
for xi = -vcr, vcr do
|
for xi = -vcr, vcr do
|
||||||
for zi = -vcr, vcr do
|
for zi = -vcr, vcr do
|
||||||
for _, village in ipairs(mg_villages.villages_at_point({x = minp.x + xi * mapchunk_size, z = minp.z + zi * mapchunk_size}, noise1raw)) do
|
for _, village in pairs(mg_villages.villages_at_point({x = minp.x + xi * mapchunk_size, z = minp.z + zi * mapchunk_size}, noise1raw)) do
|
||||||
villages[#villages+1] = village
|
villages[#villages+1] = village
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -109,11 +109,11 @@ mg_villages.check_if_ground = function( ci )
|
||||||
'default:pine_wood','default:pine_tree','default:acacia_wood','default:acacia_tree',
|
'default:pine_wood','default:pine_tree','default:acacia_wood','default:acacia_tree',
|
||||||
'ethereal:mushroom_pore','ethereal:mushroom_trunk','ethereal:bamboo', 'ethereal:mushroom'};
|
'ethereal:mushroom_pore','ethereal:mushroom_trunk','ethereal:bamboo', 'ethereal:mushroom'};
|
||||||
-- TODO: add all those other tree and leaf nodes that might be added by mapgen
|
-- TODO: add all those other tree and leaf nodes that might be added by mapgen
|
||||||
for _,name in ipairs( no_ground_nodes ) do
|
for _,name in pairs( no_ground_nodes ) do
|
||||||
replacements_group.node_is_ground[ minetest.get_content_id( name )] = false;
|
replacements_group.node_is_ground[ minetest.get_content_id( name )] = false;
|
||||||
end
|
end
|
||||||
local ground_nodes = {'ethereal:dry_dirt'};
|
local ground_nodes = {'ethereal:dry_dirt'};
|
||||||
for _,name in ipairs( ground_nodes ) do
|
for _,name in pairs( ground_nodes ) do
|
||||||
replacements_group.node_is_ground[ minetest.get_content_id( name )] = true;
|
replacements_group.node_is_ground[ minetest.get_content_id( name )] = true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -327,7 +327,7 @@ mg_villages.flatten_village_area = function( villages, minp, maxp, vm, data, par
|
||||||
local treepos = {};
|
local treepos = {};
|
||||||
for z = minp.z, maxp.z do
|
for z = minp.z, maxp.z do
|
||||||
for x = minp.x, maxp.x do
|
for x = minp.x, maxp.x do
|
||||||
for village_nr, village in ipairs(villages) do
|
for village_nr, village in pairs(villages) do
|
||||||
local force_ground = nil;
|
local force_ground = nil;
|
||||||
local force_underground = nil;
|
local force_underground = nil;
|
||||||
if( village.village_type
|
if( village.village_type
|
||||||
|
@ -367,7 +367,7 @@ mg_villages.flatten_village_area = function( villages, minp, maxp, vm, data, par
|
||||||
end
|
end
|
||||||
|
|
||||||
-- grow normal trees and jungletrees in those parts of the terrain where height blending occours
|
-- grow normal trees and jungletrees in those parts of the terrain where height blending occours
|
||||||
for _, tree in ipairs(treepos) do
|
for _, tree in pairs(treepos) do
|
||||||
local plant_id = cid.c_jsapling;
|
local plant_id = cid.c_jsapling;
|
||||||
if( tree.typ == 0 ) then
|
if( tree.typ == 0 ) then
|
||||||
plant_id = cid.c_sapling;
|
plant_id = cid.c_sapling;
|
||||||
|
@ -488,7 +488,7 @@ mg_villages.village_area_mark_buildings = function( village_area, village_nr, bp
|
||||||
-- 3: border around a road
|
-- 3: border around a road
|
||||||
-- 4: building
|
-- 4: building
|
||||||
-- 5: border around a building
|
-- 5: border around a building
|
||||||
for _, pos in ipairs( bpos ) do
|
for _, pos in pairs( bpos ) do
|
||||||
local reserved_for = 4; -- a building will be placed here
|
local reserved_for = 4; -- a building will be placed here
|
||||||
if( pos.btype and pos.btype == 'road' ) then
|
if( pos.btype and pos.btype == 'road' ) then
|
||||||
reserved_for = 2; -- the building will be a road
|
reserved_for = 2; -- the building will be a road
|
||||||
|
@ -513,7 +513,7 @@ end
|
||||||
mg_villages.village_area_mark_dirt_roads = function( village_area, village_nr, dirt_roads )
|
mg_villages.village_area_mark_dirt_roads = function( village_area, village_nr, dirt_roads )
|
||||||
-- mark the dirt roads
|
-- mark the dirt roads
|
||||||
-- 8: dirt road
|
-- 8: dirt road
|
||||||
for _, pos in ipairs(dirt_roads) do
|
for _, pos in pairs(dirt_roads) do
|
||||||
-- the building + a border of 1 around it
|
-- the building + a border of 1 around it
|
||||||
for x = 0, pos.bsizex-1 do
|
for x = 0, pos.bsizex-1 do
|
||||||
for z = 0, pos.bsizez-1 do
|
for z = 0, pos.bsizez-1 do
|
||||||
|
@ -538,7 +538,7 @@ mg_villages.village_area_mark_inside_village_area = function( village_area, vill
|
||||||
village_area[ x ][ z ] = { 0, 0 };
|
village_area[ x ][ z ] = { 0, 0 };
|
||||||
|
|
||||||
local n_rawnoise = village_noise:get2d({x = x, y = z}) -- create new blended terrain
|
local n_rawnoise = village_noise:get2d({x = x, y = z}) -- create new blended terrain
|
||||||
for village_nr, village in ipairs(villages) do
|
for village_nr, village in pairs(villages) do
|
||||||
local vn = mg_villages.get_vn(x, z, n_rawnoise, village);
|
local vn = mg_villages.get_vn(x, z, n_rawnoise, village);
|
||||||
if( village.is_single_house ) then
|
if( village.is_single_house ) then
|
||||||
-- do nothing here; the village area will be specificly marked later on
|
-- do nothing here; the village area will be specificly marked later on
|
||||||
|
@ -569,7 +569,7 @@ mg_villages.village_area_mark_inside_village_area = function( village_area, vill
|
||||||
|
|
||||||
-- single houses get their own form of terrain blend
|
-- single houses get their own form of terrain blend
|
||||||
local pr = PseudoRandom(mg_villages.get_bseed(minp));
|
local pr = PseudoRandom(mg_villages.get_bseed(minp));
|
||||||
for village_nr, village in ipairs( villages ) do
|
for village_nr, village in pairs( villages ) do
|
||||||
if( village and village.is_single_house and village.to_add_data and village.to_add_data.bpos and #village.to_add_data.bpos>=1) then
|
if( village and village.is_single_house and village.to_add_data and village.to_add_data.bpos and #village.to_add_data.bpos>=1) then
|
||||||
mg_villages.village_area_mark_single_house_area( village_area, minp, maxp, village.to_add_data.bpos[1], pr, village_nr, village );
|
mg_villages.village_area_mark_single_house_area( village_area, minp, maxp, village.to_add_data.bpos[1], pr, village_nr, village );
|
||||||
end
|
end
|
||||||
|
@ -584,7 +584,7 @@ mg_villages.village_area_get_height = function( village_area, villages, minp, ma
|
||||||
local height_count = {};
|
local height_count = {};
|
||||||
local height_statistic = {};
|
local height_statistic = {};
|
||||||
-- initialize the variables for counting
|
-- initialize the variables for counting
|
||||||
for village_nr, village in ipairs( villages ) do
|
for village_nr, village in pairs( villages ) do
|
||||||
height_sum[ village_nr ] = 0;
|
height_sum[ village_nr ] = 0;
|
||||||
height_count[ village_nr ] = 0;
|
height_count[ village_nr ] = 0;
|
||||||
height_statistic[ village_nr ] = {};
|
height_statistic[ village_nr ] = {};
|
||||||
|
@ -626,7 +626,7 @@ mg_villages.village_area_get_height = function( village_area, villages, minp, ma
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for village_nr, village in ipairs( villages ) do
|
for village_nr, village in pairs( villages ) do
|
||||||
|
|
||||||
local tmin = maxp.y;
|
local tmin = maxp.y;
|
||||||
local tmax = minp.y;
|
local tmax = minp.y;
|
||||||
|
@ -704,10 +704,10 @@ end
|
||||||
|
|
||||||
mg_villages.change_village_height = function( village, new_height )
|
mg_villages.change_village_height = function( village, new_height )
|
||||||
mg_villages.print( mg_villages.DEBUG_LEVEL_TIMING, 'CHANGING HEIGHT from '..tostring( village.vh )..' to '..tostring( new_height ));
|
mg_villages.print( mg_villages.DEBUG_LEVEL_TIMING, 'CHANGING HEIGHT from '..tostring( village.vh )..' to '..tostring( new_height ));
|
||||||
for _, pos in ipairs(village.to_add_data.bpos) do
|
for _, pos in pairs(village.to_add_data.bpos) do
|
||||||
pos.y = new_height;
|
pos.y = new_height;
|
||||||
end
|
end
|
||||||
for _, pos in ipairs(village.to_add_data.dirt_roads) do
|
for _, pos in pairs(village.to_add_data.dirt_roads) do
|
||||||
pos.y = new_height;
|
pos.y = new_height;
|
||||||
end
|
end
|
||||||
village.vh = new_height;
|
village.vh = new_height;
|
||||||
|
@ -802,7 +802,7 @@ mg_villages.village_area_fill_with_plants = function( village_area, villages, mi
|
||||||
local on_soil = false;
|
local on_soil = false;
|
||||||
local plant_selected = false;
|
local plant_selected = false;
|
||||||
local has_snow_cover = false;
|
local has_snow_cover = false;
|
||||||
for _,v in ipairs( village.to_add_data.plantlist ) do
|
for _,v in pairs( village.to_add_data.plantlist ) do
|
||||||
if( plant_id == cid.c_snow or g==cid.c_dirt_with_snow or g==cid.c_snowblock) then
|
if( plant_id == cid.c_snow or g==cid.c_dirt_with_snow or g==cid.c_snowblock) then
|
||||||
has_snow_cover = true;
|
has_snow_cover = true;
|
||||||
end
|
end
|
||||||
|
@ -941,7 +941,7 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||||
-- determine which coordinates are inside the village and which are not
|
-- determine which coordinates are inside the village and which are not
|
||||||
local village_area = {};
|
local village_area = {};
|
||||||
|
|
||||||
for village_nr, village in ipairs(villages) do
|
for village_nr, village in pairs(villages) do
|
||||||
-- generate the village structure: determine positions of buildings and roads
|
-- generate the village structure: determine positions of buildings and roads
|
||||||
mg_villages.generate_village( village, village_noise);
|
mg_villages.generate_village( village, village_noise);
|
||||||
|
|
||||||
|
@ -1023,7 +1023,7 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||||
|
|
||||||
-- change height of those villages where an optimal_height could be determined
|
-- change height of those villages where an optimal_height could be determined
|
||||||
local village_data_updated = false;
|
local village_data_updated = false;
|
||||||
for _,village in ipairs(villages) do
|
for _,village in pairs(villages) do
|
||||||
if( village.optimal_height and village.optimal_height > 0 and village.optimal_height ~= village.vh ) then
|
if( village.optimal_height and village.optimal_height > 0 and village.optimal_height ~= village.vh ) then
|
||||||
-- towers are usually found on elevated places
|
-- towers are usually found on elevated places
|
||||||
if( village.village_type == 'tower' ) then
|
if( village.village_type == 'tower' ) then
|
||||||
|
@ -1054,7 +1054,7 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||||
c_feldweg = minetest.get_content_id('default:cobble');
|
c_feldweg = minetest.get_content_id('default:cobble');
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, village in ipairs(villages) do
|
for _, village in pairs(villages) do
|
||||||
|
|
||||||
-- the village_id will be stored in the plot markers
|
-- the village_id will be stored in the plot markers
|
||||||
local village_id = tostring( village.vx )..':'..tostring( village.vz );
|
local village_id = tostring( village.vx )..':'..tostring( village.vz );
|
||||||
|
@ -1064,7 +1064,7 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||||
handle_schematics.place_dirt_roads( village, tmin, tmax, data, param2_data, a, c_feldweg);
|
handle_schematics.place_dirt_roads( village, tmin, tmax, data, param2_data, a, c_feldweg);
|
||||||
|
|
||||||
-- grow trees which are part of buildings into saplings
|
-- grow trees which are part of buildings into saplings
|
||||||
for _,v in ipairs( village.to_add_data.extra_calls.trees ) do
|
for _,v in pairs( village.to_add_data.extra_calls.trees ) do
|
||||||
mg_villages.grow_a_tree( v, v.typ, minp, maxp, data, a, cid, nil, v.snow ); -- TODO: supply pseudorandom value?
|
mg_villages.grow_a_tree( v, v.typ, minp, maxp, data, a, cid, nil, v.snow ); -- TODO: supply pseudorandom value?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1093,11 +1093,11 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||||
t1 = time_elapsed( t1, 'vm update liquids' );
|
t1 = time_elapsed( t1, 'vm update liquids' );
|
||||||
|
|
||||||
-- do on_construct calls AFTER the map data has been written - else i.e. realtest fences can not update themshevles
|
-- do on_construct calls AFTER the map data has been written - else i.e. realtest fences can not update themshevles
|
||||||
for _, village in ipairs(villages) do
|
for _, village in pairs(villages) do
|
||||||
for k, v in pairs( village.to_add_data.extra_calls.on_constr ) do
|
for k, v in pairs( village.to_add_data.extra_calls.on_constr ) do
|
||||||
local node_name = minetest.get_name_from_content_id( k );
|
local node_name = minetest.get_name_from_content_id( k );
|
||||||
if( minetest.registered_nodes[ node_name ].on_construct ) then
|
if( minetest.registered_nodes[ node_name ].on_construct ) then
|
||||||
for _, pos in ipairs(v) do
|
for _, pos in pairs(v) do
|
||||||
minetest.registered_nodes[ node_name ].on_construct( pos );
|
minetest.registered_nodes[ node_name ].on_construct( pos );
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1105,8 +1105,8 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||||
end
|
end
|
||||||
|
|
||||||
local pr = PseudoRandom(mg_villages.get_bseed(minp));
|
local pr = PseudoRandom(mg_villages.get_bseed(minp));
|
||||||
for _, village in ipairs(villages) do
|
for _, village in pairs(villages) do
|
||||||
for _,v in ipairs( village.to_add_data.extra_calls.chests ) do
|
for _,v in pairs( village.to_add_data.extra_calls.chests ) do
|
||||||
local building_nr = village.to_add_data.bpos[ v.bpos_i ];
|
local building_nr = village.to_add_data.bpos[ v.bpos_i ];
|
||||||
local building_typ = mg_villages.BUILDINGS[ building_nr.btype ].scm;
|
local building_typ = mg_villages.BUILDINGS[ building_nr.btype ].scm;
|
||||||
mg_villages.fill_chest_random( v, pr, building_nr, building_typ );
|
mg_villages.fill_chest_random( v, pr, building_nr, building_typ );
|
||||||
|
@ -1116,13 +1116,13 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||||
|
|
||||||
|
|
||||||
-- useful for spawning mobs etc.
|
-- useful for spawning mobs etc.
|
||||||
for _, village in ipairs(villages) do
|
for _, village in pairs(villages) do
|
||||||
mg_villages.part_of_village_spawned( village, minp, maxp, data, param2_data, a, cid );
|
mg_villages.part_of_village_spawned( village, minp, maxp, data, param2_data, a, cid );
|
||||||
end
|
end
|
||||||
|
|
||||||
-- initialize the pseudo random generator so that the chests will be filled in a reproducable pattern
|
-- initialize the pseudo random generator so that the chests will be filled in a reproducable pattern
|
||||||
local meta
|
local meta
|
||||||
for _, village in ipairs(villages) do
|
for _, village in pairs(villages) do
|
||||||
-- now add those buildings which are .mts files and need to be placed by minetest.place_schematic(...)
|
-- now add those buildings which are .mts files and need to be placed by minetest.place_schematic(...)
|
||||||
-- place_schematics is no longer needed
|
-- place_schematics is no longer needed
|
||||||
--mg_villages.place_schematics( village.to_add_data.bpos, village.to_add_data.replacements, a, pr );
|
--mg_villages.place_schematics( village.to_add_data.bpos, village.to_add_data.replacements, a, pr );
|
||||||
|
@ -1198,7 +1198,7 @@ mg_villages.on_generated = function(minp, maxp, seed)
|
||||||
|
|
||||||
-- check if the village exists already
|
-- check if the village exists already
|
||||||
local v_nr = 1;
|
local v_nr = 1;
|
||||||
for v_nr, village in ipairs(villages) do
|
for v_nr, village in pairs(villages) do
|
||||||
local village_id = tostring( village.vx )..':'..tostring( village.vz );
|
local village_id = tostring( village.vx )..':'..tostring( village.vz );
|
||||||
|
|
||||||
if( not( village.name ) or village.name == '') then
|
if( not( village.name ) or village.name == '') then
|
||||||
|
|
|
@ -42,12 +42,12 @@ minetest.is_protected = function(pos, name)
|
||||||
local village_id = mg_villages.get_town_id_at_pos( pos );
|
local village_id = mg_villages.get_town_id_at_pos( pos );
|
||||||
if( village_id ) then
|
if( village_id ) then
|
||||||
local is_houseowner = false;
|
local is_houseowner = false;
|
||||||
for nr, p in ipairs( mg_villages.all_villages[ village_id ].to_add_data.bpos ) do
|
for nr, p in pairs( mg_villages.all_villages[ village_id ].to_add_data.bpos ) do
|
||||||
|
|
||||||
trustedusers = p.can_edit
|
trustedusers = p.can_edit
|
||||||
trustedUser = false
|
trustedUser = false
|
||||||
if trustedusers ~= nil then
|
if trustedusers ~= nil then
|
||||||
for _,trusted in ipairs(trustedusers) do
|
for _,trusted in pairs(trustedusers) do
|
||||||
if trusted == name then
|
if trusted == name then
|
||||||
trustedUser = true
|
trustedUser = true
|
||||||
end
|
end
|
||||||
|
@ -251,7 +251,7 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||||
if previousTrustees == nil then
|
if previousTrustees == nil then
|
||||||
previousTrustees = {}
|
previousTrustees = {}
|
||||||
else
|
else
|
||||||
for _, player in ipairs(previousTrustees) do
|
for _, player in pairs(previousTrustees) do
|
||||||
output = output..player.."\n"
|
output = output..player.."\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -271,7 +271,7 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||||
end
|
end
|
||||||
|
|
||||||
local x = 1;
|
local x = 1;
|
||||||
for _, player in ipairs(fields.ownerplayers:split("\n")) do
|
for _, player in pairs(fields.ownerplayers:split("\n")) do
|
||||||
mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit[x] = player
|
mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit[x] = player
|
||||||
x = x + 1
|
x = x + 1
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@ if( minetest.get_modpath( 'trees' )
|
||||||
-- realtest is very special as far as stairs are concerned
|
-- realtest is very special as far as stairs are concerned
|
||||||
mg_villages.realtest_stairs = {'default:stone','default:stone_flat','default:stone_bricks',
|
mg_villages.realtest_stairs = {'default:stone','default:stone_flat','default:stone_bricks',
|
||||||
'default:desert_stone_flat','default:desert_stone_bricks'};
|
'default:desert_stone_flat','default:desert_stone_bricks'};
|
||||||
for i,v in ipairs(metals.list) do
|
for i,v in pairs(metals.list) do
|
||||||
table.insert( mg_villages.realtest_stairs, 'metals:'..v..'_block' );
|
table.insert( mg_villages.realtest_stairs, 'metals:'..v..'_block' );
|
||||||
end
|
end
|
||||||
-- the list of minteral names is local; so we can't add "decorations:"..mineral[1].."_block"
|
-- the list of minteral names is local; so we can't add "decorations:"..mineral[1].."_block"
|
||||||
|
@ -55,7 +55,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
|
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
for i,v in ipairs( prefixes ) do
|
for i,v in pairs( prefixes ) do
|
||||||
postfixes[i] = '';
|
postfixes[i] = '';
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -63,9 +63,9 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
local known_materials = {};
|
local known_materials = {};
|
||||||
local wood_found = false;
|
local wood_found = false;
|
||||||
-- for all alternate materials
|
-- for all alternate materials
|
||||||
for i,m in ipairs( materials ) do
|
for i,m in pairs( materials ) do
|
||||||
-- check if that material exists for each supplied prefix
|
-- check if that material exists for each supplied prefix
|
||||||
for j,p in ipairs( prefixes ) do
|
for j,p in pairs( prefixes ) do
|
||||||
-- if wood is present, later on try moretrees wood as well
|
-- if wood is present, later on try moretrees wood as well
|
||||||
if( 'default:wood' == m ) then
|
if( 'default:wood' == m ) then
|
||||||
wood_found = true;
|
wood_found = true;
|
||||||
|
@ -78,7 +78,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
|
|
||||||
-- support wooden planks from moretrees
|
-- support wooden planks from moretrees
|
||||||
if( wood_found and mg_villages.moretrees_treelist ) then
|
if( wood_found and mg_villages.moretrees_treelist ) then
|
||||||
for _,v in ipairs( mg_villages.moretrees_treelist ) do
|
for _,v in pairs( mg_villages.moretrees_treelist ) do
|
||||||
if( minetest.registered_nodes[ "moretrees:"..v[1].."_planks"] ) then
|
if( minetest.registered_nodes[ "moretrees:"..v[1].."_planks"] ) then
|
||||||
table.insert( known_materials, "moretrees:"..v[1].."_planks" );
|
table.insert( known_materials, "moretrees:"..v[1].."_planks" );
|
||||||
end
|
end
|
||||||
|
@ -89,7 +89,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
-- deco is used by BigFreakingDig; as that one lacks default nodes, it doesn't work out here
|
-- deco is used by BigFreakingDig; as that one lacks default nodes, it doesn't work out here
|
||||||
if( wood_found and minetest.get_modpath('deco')) then
|
if( wood_found and minetest.get_modpath('deco')) then
|
||||||
local bfd_treelist = {'birch', 'cherry', 'evergreen', 'oak' };
|
local bfd_treelist = {'birch', 'cherry', 'evergreen', 'oak' };
|
||||||
for _,v in ipairs( bfd_treelist ) do
|
for _,v in pairs( bfd_treelist ) do
|
||||||
if( minetest.registered_nodes[ "deco:"..v.."_plank"] ) then
|
if( minetest.registered_nodes[ "deco:"..v.."_plank"] ) then
|
||||||
table.insert( known_materials, "deco:"..v.."_plank" );
|
table.insert( known_materials, "deco:"..v.."_plank" );
|
||||||
end
|
end
|
||||||
|
@ -98,7 +98,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
if( wood_found and mg_villages.ethereal_trees ) then
|
if( wood_found and mg_villages.ethereal_trees ) then
|
||||||
for _,v in ipairs( mg_villages.ethereal_trees ) do
|
for _,v in pairs( mg_villages.ethereal_trees ) do
|
||||||
-- mushroom in ethereal is a pretty decorative material; increase its probability
|
-- mushroom in ethereal is a pretty decorative material; increase its probability
|
||||||
if( v == 'mushroom' ) then
|
if( v == 'mushroom' ) then
|
||||||
table.insert( known_materials, "ethereal:mushroom_pore" );
|
table.insert( known_materials, "ethereal:mushroom_pore" );
|
||||||
|
@ -114,7 +114,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
end
|
end
|
||||||
|
|
||||||
if( wood_found and mg_villages.forest_trees ) then
|
if( wood_found and mg_villages.forest_trees ) then
|
||||||
for _,v in ipairs( mg_villages.forest_trees ) do
|
for _,v in pairs( mg_villages.forest_trees ) do
|
||||||
if( minetest.registered_nodes[ 'forest:'..v..'_wood'] ) then
|
if( minetest.registered_nodes[ 'forest:'..v..'_wood'] ) then
|
||||||
table.insert( known_materials, 'forest:'..v..'_wood' );
|
table.insert( known_materials, 'forest:'..v..'_wood' );
|
||||||
end
|
end
|
||||||
|
@ -122,7 +122,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
end
|
end
|
||||||
|
|
||||||
if( wood_found and mg_villages.tinytrees_trees ) then
|
if( wood_found and mg_villages.tinytrees_trees ) then
|
||||||
for _,v in ipairs( mg_villages.tinytrees_trees ) do
|
for _,v in pairs( mg_villages.tinytrees_trees ) do
|
||||||
if( minetest.registered_nodes[ 'trees:wood_'..v] ) then
|
if( minetest.registered_nodes[ 'trees:wood_'..v] ) then
|
||||||
table.insert( known_materials, 'trees:wood_'..v );
|
table.insert( known_materials, 'trees:wood_'..v );
|
||||||
end
|
end
|
||||||
|
@ -130,7 +130,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
end
|
end
|
||||||
|
|
||||||
if( wood_found and mg_villages.realtest_trees ) then
|
if( wood_found and mg_villages.realtest_trees ) then
|
||||||
for _,v in ipairs( mg_villages.realtest_trees ) do
|
for _,v in pairs( mg_villages.realtest_trees ) do
|
||||||
if( minetest.registered_nodes[ 'trees:'..v..'_planks'] ) then
|
if( minetest.registered_nodes[ 'trees:'..v..'_planks'] ) then
|
||||||
table.insert( known_materials, 'trees:'..v..'_planks' );
|
table.insert( known_materials, 'trees:'..v..'_planks' );
|
||||||
end
|
end
|
||||||
|
@ -158,7 +158,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
return old_material;
|
return old_material;
|
||||||
end
|
end
|
||||||
|
|
||||||
for i,v in ipairs( prefixes ) do
|
for i,v in pairs( prefixes ) do
|
||||||
table.insert( replacements, { original_materials[ i ], v..new_material } );
|
table.insert( replacements, { original_materials[ i ], v..new_material } );
|
||||||
end
|
end
|
||||||
return new_material;
|
return new_material;
|
||||||
|
@ -178,7 +178,7 @@ mg_villages.replace_tree_trunk = function( replacements, wood_type )
|
||||||
table.insert( replacements, {'default:tree', 'mg:pinetree'});
|
table.insert( replacements, {'default:tree', 'mg:pinetree'});
|
||||||
|
|
||||||
elseif( mg_villages.moretrees_treelist ) then
|
elseif( mg_villages.moretrees_treelist ) then
|
||||||
for _,v in ipairs( mg_villages.moretrees_treelist ) do
|
for _,v in pairs( mg_villages.moretrees_treelist ) do
|
||||||
if( wood_type == "moretrees:"..v[1].."_planks" ) then
|
if( wood_type == "moretrees:"..v[1].."_planks" ) then
|
||||||
table.insert( replacements, {'default:tree', "moretrees:"..v[1].."_trunk"});
|
table.insert( replacements, {'default:tree', "moretrees:"..v[1].."_trunk"});
|
||||||
table.insert( replacements, {'default:leaves', "moretrees:"..v[1].."_leaves"});
|
table.insert( replacements, {'default:leaves', "moretrees:"..v[1].."_leaves"});
|
||||||
|
@ -201,28 +201,28 @@ mg_villages.replace_tree_trunk = function( replacements, wood_type )
|
||||||
table.insert( replacements, {'default:tree', "ethereal:mushroom_trunk"});
|
table.insert( replacements, {'default:tree', "ethereal:mushroom_trunk"});
|
||||||
|
|
||||||
elseif( mg_villages.ethereal_trees ) then
|
elseif( mg_villages.ethereal_trees ) then
|
||||||
for _,v in ipairs( mg_villages.ethereal_trees ) do
|
for _,v in pairs( mg_villages.ethereal_trees ) do
|
||||||
if( wood_type == "ethereal:"..v.."_wood" ) then
|
if( wood_type == "ethereal:"..v.."_wood" ) then
|
||||||
table.insert( replacements, {'default:tree', "ethereal:"..v.."_trunk"});
|
table.insert( replacements, {'default:tree', "ethereal:"..v.."_trunk"});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif( mg_villages.forest_trees ) then
|
elseif( mg_villages.forest_trees ) then
|
||||||
for _,v in ipairs( mg_villages.forest_trees ) do
|
for _,v in pairs( mg_villages.forest_trees ) do
|
||||||
if( wood_type == "forest:"..v.."_wood" ) then
|
if( wood_type == "forest:"..v.."_wood" ) then
|
||||||
table.insert( replacements, {'default:tree', "forest:"..v.."_tree"});
|
table.insert( replacements, {'default:tree', "forest:"..v.."_tree"});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif( mg_villages.tinytrees_trees ) then
|
elseif( mg_villages.tinytrees_trees ) then
|
||||||
for _,v in ipairs( mg_villages.tinytrees_trees ) do
|
for _,v in pairs( mg_villages.tinytrees_trees ) do
|
||||||
if( wood_type == "trees:wood_"..v ) then
|
if( wood_type == "trees:wood_"..v ) then
|
||||||
table.insert( replacements, {'default:tree', "trees:tree_"..v});
|
table.insert( replacements, {'default:tree', "trees:tree_"..v});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif( mg_villages.realtest_trees ) then
|
elseif( mg_villages.realtest_trees ) then
|
||||||
for _,v in ipairs( mg_villages.realtest_trees ) do
|
for _,v in pairs( mg_villages.realtest_trees ) do
|
||||||
if( wood_type == 'trees:'..v..'_planks' ) then
|
if( wood_type == 'trees:'..v..'_planks' ) then
|
||||||
table.insert( replacements, {'default:tree', "trees:"..v..'_log'});
|
table.insert( replacements, {'default:tree', "trees:"..v..'_log'});
|
||||||
-- realtest does not have most of the nodes from default, so we need to replace them as well
|
-- realtest does not have most of the nodes from default, so we need to replace them as well
|
||||||
|
@ -277,34 +277,34 @@ mg_villages.replace_saplings = function( replacements, wood_type )
|
||||||
elseif( wood_type == 'mg:pinewood' ) then
|
elseif( wood_type == 'mg:pinewood' ) then
|
||||||
table.insert( replacements, {'default:sapling', 'mg:pinesapling'});
|
table.insert( replacements, {'default:sapling', 'mg:pinesapling'});
|
||||||
elseif( mg_villages.moretrees_treelist ) then
|
elseif( mg_villages.moretrees_treelist ) then
|
||||||
for _,v in ipairs( mg_villages.moretrees_treelist ) do
|
for _,v in pairs( mg_villages.moretrees_treelist ) do
|
||||||
if( wood_type == "moretrees:"..v[1].."_planks" ) then
|
if( wood_type == "moretrees:"..v[1].."_planks" ) then
|
||||||
table.insert( replacements, {'default:sapling', "moretrees:"..v[1].."_sapling_ongen"});
|
table.insert( replacements, {'default:sapling', "moretrees:"..v[1].."_sapling_ongen"});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif( mg_villages.ethereal_trees ) then
|
elseif( mg_villages.ethereal_trees ) then
|
||||||
for _,v in ipairs( mg_villages.ethereal_trees ) do
|
for _,v in pairs( mg_villages.ethereal_trees ) do
|
||||||
if( wood_type == "ethereal:"..v.."_wood" ) then
|
if( wood_type == "ethereal:"..v.."_wood" ) then
|
||||||
table.insert( replacements, {'default:sapling', "ethereal:"..v.."_sapling"});
|
table.insert( replacements, {'default:sapling', "ethereal:"..v.."_sapling"});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif( mg_villages.forest_trees ) then
|
elseif( mg_villages.forest_trees ) then
|
||||||
for _,v in ipairs( mg_villages.forest_trees ) do
|
for _,v in pairs( mg_villages.forest_trees ) do
|
||||||
if( wood_type == "forest:"..v.."_wood" ) then
|
if( wood_type == "forest:"..v.."_wood" ) then
|
||||||
table.insert( replacements, {'default:sapling', "forest:"..v.."_sapling"});
|
table.insert( replacements, {'default:sapling', "forest:"..v.."_sapling"});
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif( mg_villages.tinytrees_trees ) then
|
elseif( mg_villages.tinytrees_trees ) then
|
||||||
for _,v in ipairs( mg_villages.tinytrees_trees ) do
|
for _,v in pairs( mg_villages.tinytrees_trees ) do
|
||||||
if( wood_type == "trees:wood_"..v ) then
|
if( wood_type == "trees:wood_"..v ) then
|
||||||
table.insert( replacements, {'default:sapling', "trees:sapling_"..v});
|
table.insert( replacements, {'default:sapling', "trees:sapling_"..v});
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
elseif( mg_villages.realtest_trees ) then
|
elseif( mg_villages.realtest_trees ) then
|
||||||
for _,v in ipairs( mg_villages.realtest_trees ) do
|
for _,v in pairs( mg_villages.realtest_trees ) do
|
||||||
if( wood_type == 'trees:'..v..'_planks' ) then
|
if( wood_type == 'trees:'..v..'_planks' ) then
|
||||||
table.insert( replacements, {'default:sapling', "trees:"..v.."_sapling"});
|
table.insert( replacements, {'default:sapling', "trees:"..v.."_sapling"});
|
||||||
table.insert( replacements, {'default:junglesapling', "trees:"..v.."_sapling"});
|
table.insert( replacements, {'default:junglesapling', "trees:"..v.."_sapling"});
|
||||||
|
@ -872,7 +872,7 @@ mg_villages.get_replacement_ids = function( housetype, pr )
|
||||||
|
|
||||||
local replace = {};
|
local replace = {};
|
||||||
local replacements = mg_villages.get_replacement_list( housetype, pr );
|
local replacements = mg_villages.get_replacement_list( housetype, pr );
|
||||||
for i,v in ipairs( replacements ) do
|
for i,v in pairs( replacements ) do
|
||||||
if( v and #v == 2 ) then
|
if( v and #v == 2 ) then
|
||||||
replace[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] );
|
replace[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] );
|
||||||
end
|
end
|
||||||
|
@ -899,7 +899,7 @@ mg_villages.get_replacement_table = function( housetype, pr, replacements )
|
||||||
table.insert( replacements, {'default:lava_flowing', 'mg_villages:lava_flowing_tamed'});
|
table.insert( replacements, {'default:lava_flowing', 'mg_villages:lava_flowing_tamed'});
|
||||||
end
|
end
|
||||||
|
|
||||||
for i,v in ipairs( replacements ) do
|
for i,v in pairs( replacements ) do
|
||||||
if( v and #v == 2 ) then
|
if( v and #v == 2 ) then
|
||||||
rtable[ v[1] ] = v[2];
|
rtable[ v[1] ] = v[2];
|
||||||
ids[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] );
|
ids[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] );
|
||||||
|
|
|
@ -16,7 +16,7 @@ function mg_villages.spawnplayer(player)
|
||||||
for bx = -20, 20 do
|
for bx = -20, 20 do
|
||||||
for bz = -20, 20 do
|
for bz = -20, 20 do
|
||||||
local minp = {x = min_pos.x + bx, y = -32, z = min_pos.z + bz}
|
local minp = {x = min_pos.x + bx, y = -32, z = min_pos.z + bz}
|
||||||
for _, village in ipairs(mg_villages.villages_at_point(minp, noise1)) do
|
for _, village in pairs(mg_villages.villages_at_point(minp, noise1)) do
|
||||||
if math.abs(village.vx) + math.abs(village.vz) < min_dist then
|
if math.abs(village.vx) + math.abs(village.vz) < min_dist then
|
||||||
min_pos = {x = village.vx, y = village.vh + 2, z = village.vz}
|
min_pos = {x = village.vx, y = village.vh + 2, z = village.vz}
|
||||||
-- some villages are later adjusted in height; adapt these changes
|
-- some villages are later adjusted in height; adapt these changes
|
||||||
|
|
|
@ -77,7 +77,7 @@ mg_villages.add_village_type = function( type_name, v )
|
||||||
if( not( v.mods )) then
|
if( not( v.mods )) then
|
||||||
v.mods = {};
|
v.mods = {};
|
||||||
end
|
end
|
||||||
for _,m in ipairs( v.mods ) do
|
for _,m in pairs( v.mods ) do
|
||||||
if( not( minetest.get_modpath( m ))) then
|
if( not( minetest.get_modpath( m ))) then
|
||||||
-- this village type will not be used because not all required mods are installed
|
-- this village type will not be used because not all required mods are installed
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -84,11 +84,11 @@ local function choose_building(l, pr, village_type)
|
||||||
-- ...and crash in the next few lines (because there is no real solution for this problem)
|
-- ...and crash in the next few lines (because there is no real solution for this problem)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, b in ipairs( mg_villages.village_type_data[ village_type ][ 'building_list'] ) do
|
for _, b in pairs( mg_villages.village_type_data[ village_type ][ 'building_list'] ) do
|
||||||
if ( mg_villages.BUILDINGS[ b ] and mg_villages.BUILDINGS[ b ].max_weight
|
if ( mg_villages.BUILDINGS[ b ] and mg_villages.BUILDINGS[ b ].max_weight
|
||||||
and mg_villages.BUILDINGS[ b ].max_weight[ village_type ] and mg_villages.BUILDINGS[ b ].max_weight[ village_type ] >= p) then
|
and mg_villages.BUILDINGS[ b ].max_weight[ village_type ] and mg_villages.BUILDINGS[ b ].max_weight[ village_type ] >= p) then
|
||||||
|
|
||||||
-- for b, i in ipairs(mg_villages.BUILDINGS) do
|
-- for b, i in pairs(mg_villages.BUILDINGS) do
|
||||||
-- if i.weight[ village_type ] and i.weight[ village_type ] > 0 and i.max_weight and i.max_weight[ village_type ] and i.max_weight[ village_type ] >= p then
|
-- if i.weight[ village_type ] and i.weight[ village_type ] > 0 and i.max_weight and i.max_weight[ village_type ] and i.max_weight[ village_type ] >= p then
|
||||||
btype = b
|
btype = b
|
||||||
break
|
break
|
||||||
|
@ -161,7 +161,7 @@ local function choose_building_rot(l, pr, orient, village_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function placeable(bx, bz, bsizex, bsizez, l, exclude_roads, orientation)
|
local function placeable(bx, bz, bsizex, bsizez, l, exclude_roads, orientation)
|
||||||
for _, a in ipairs(l) do
|
for _, a in pairs(l) do
|
||||||
-- with < instead of <=, space_between_buildings can be zero (important for towns where houses are closely packed)
|
-- with < instead of <=, space_between_buildings can be zero (important for towns where houses are closely packed)
|
||||||
if (a.btype ~= "road" or not exclude_roads) and math.abs(bx+bsizex/2-a.x-a.bsizex/2)<(bsizex+a.bsizex)/2 and math.abs(bz+bsizez/2-a.z-a.bsizez/2)<(bsizez+a.bsizez)/2 then
|
if (a.btype ~= "road" or not exclude_roads) and math.abs(bx+bsizex/2-a.x-a.bsizex/2)<(bsizex+a.bsizex)/2 and math.abs(bz+bsizez/2-a.z-a.bsizez/2)<(bsizez+a.bsizez)/2 then
|
||||||
-- dirt roads which go at a 90 degree angel to the current road are not a problem
|
-- dirt roads which go at a 90 degree angel to the current road are not a problem
|
||||||
|
@ -372,7 +372,7 @@ local function generate_road(village, l, pr, roadsize_list, road_materials, rx,
|
||||||
l[#l].road_material = minetest.get_content_id( road_materials[ iteration_depth ] );
|
l[#l].road_material = minetest.get_content_id( road_materials[ iteration_depth ] );
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, i in ipairs(calls_to_do) do
|
for _, i in pairs(calls_to_do) do
|
||||||
-- local new_roadsize = roadsize -- - 1
|
-- local new_roadsize = roadsize -- - 1
|
||||||
if pr:next(1, 100) <= mg_villages.BIG_ROAD_CHANCE then
|
if pr:next(1, 100) <= mg_villages.BIG_ROAD_CHANCE then
|
||||||
--new_roadsize = roadsize
|
--new_roadsize = roadsize
|
||||||
|
@ -391,13 +391,13 @@ local function generate_bpos(village, pr, vnoise, space_between_buildings)
|
||||||
local rx = vx - vs
|
local rx = vx - vs
|
||||||
--[=[local l={}
|
--[=[local l={}
|
||||||
local total_weight = 0
|
local total_weight = 0
|
||||||
for _, i in ipairs(mg_villages.BUILDINGS) do
|
for _, i in pairs(mg_villages.BUILDINGS) do
|
||||||
if i.weight == nil then i.weight = 1 end
|
if i.weight == nil then i.weight = 1 end
|
||||||
total_weight = total_weight+i.weight
|
total_weight = total_weight+i.weight
|
||||||
i.max_weight = total_weight
|
i.max_weight = total_weight
|
||||||
end
|
end
|
||||||
local multiplier = 3000/total_weight
|
local multiplier = 3000/total_weight
|
||||||
for _,i in ipairs(mg_villages.BUILDINGS) do
|
for _,i in pairs(mg_villages.BUILDINGS) do
|
||||||
i.max_weight = i.max_weight*multiplier
|
i.max_weight = i.max_weight*multiplier
|
||||||
end
|
end
|
||||||
for i=1, 2000 do
|
for i=1, 2000 do
|
||||||
|
@ -411,7 +411,7 @@ local function generate_bpos(village, pr, vnoise, space_between_buildings)
|
||||||
end
|
end
|
||||||
end]]
|
end]]
|
||||||
p = pr:next(1, 3000)
|
p = pr:next(1, 3000)
|
||||||
for b, i in ipairs(mg_villages.BUILDINGS) do
|
for b, i in pairs(mg_villages.BUILDINGS) do
|
||||||
if i.max_weight > p then
|
if i.max_weight > p then
|
||||||
btype = b
|
btype = b
|
||||||
break
|
break
|
||||||
|
@ -440,7 +440,7 @@ local function generate_bpos(village, pr, vnoise, space_between_buildings)
|
||||||
bsizex, bsizez = bsizez, bsizex
|
bsizex, bsizez = bsizez, bsizex
|
||||||
end
|
end
|
||||||
if dist_center2(bx-vx, bsizex, bz-vz, bsizez)>vs*vs then goto out end
|
if dist_center2(bx-vx, bsizex, bz-vz, bsizez)>vs*vs then goto out end
|
||||||
for _, a in ipairs(l) do
|
for _, a in pairs(l) do
|
||||||
if math.abs(bx-a.x)<=(bsizex+a.bsizex)/2+2 and math.abs(bz-a.z)<=(bsizez+a.bsizez)/2+2 then goto out end
|
if math.abs(bx-a.x)<=(bsizex+a.bsizex)/2+2 and math.abs(bz-a.z)<=(bsizez+a.bsizez)/2+2 then goto out end
|
||||||
end
|
end
|
||||||
l[#l+1] = {x=bx, y=vh, z=bz, btype=btype, bsizex=bsizex, bsizez=bsizez, brotate = rotation}
|
l[#l+1] = {x=bx, y=vh, z=bz, btype=btype, bsizex=bsizex, bsizez=bsizez, brotate = rotation}
|
||||||
|
@ -479,7 +479,7 @@ local function generate_dirt_roads( village, vnoise, bpos, secondary_dirt_roads
|
||||||
if( not( secondary_dirt_roads)) then
|
if( not( secondary_dirt_roads)) then
|
||||||
return dirt_roads;
|
return dirt_roads;
|
||||||
end
|
end
|
||||||
for _, pos in ipairs( bpos ) do
|
for _, pos in pairs( bpos ) do
|
||||||
|
|
||||||
local x = pos.x;
|
local x = pos.x;
|
||||||
local z = pos.z;
|
local z = pos.z;
|
||||||
|
@ -588,7 +588,7 @@ end
|
||||||
local MIN_DIST = 1
|
local MIN_DIST = 1
|
||||||
|
|
||||||
local function pos_far_buildings(x, z, l)
|
local function pos_far_buildings(x, z, l)
|
||||||
for _, a in ipairs(l) do
|
for _, a in pairs(l) do
|
||||||
if a.x - MIN_DIST <= x and x <= a.x + a.bsizex + MIN_DIST and
|
if a.x - MIN_DIST <= x and x <= a.x + a.bsizex + MIN_DIST and
|
||||||
a.z - MIN_DIST <= z and z <= a.z + a.bsizez + MIN_DIST then
|
a.z - MIN_DIST <= z and z <= a.z + a.bsizez + MIN_DIST then
|
||||||
return false
|
return false
|
||||||
|
@ -657,7 +657,7 @@ mg_villages.generate_village = function(village, vnoise)
|
||||||
|
|
||||||
-- set fruits for all buildings in the village that need it - regardless weather they will be spawned
|
-- set fruits for all buildings in the village that need it - regardless weather they will be spawned
|
||||||
-- now or later; after the first call to this function here, the village data will be final
|
-- now or later; after the first call to this function here, the village data will be final
|
||||||
for _, pos in ipairs( bpos ) do
|
for _, pos in pairs( bpos ) do
|
||||||
local binfo = mg_villages.BUILDINGS[pos.btype];
|
local binfo = mg_villages.BUILDINGS[pos.btype];
|
||||||
if( binfo.farming_plus and binfo.farming_plus == 1 and mg_villages.fruit_list and not pos.furit) then
|
if( binfo.farming_plus and binfo.farming_plus == 1 and mg_villages.fruit_list and not pos.furit) then
|
||||||
pos.fruit = mg_villages.fruit_list[ pr_village:next( 1, #mg_villages.fruit_list )];
|
pos.fruit = mg_villages.fruit_list[ pr_village:next( 1, #mg_villages.fruit_list )];
|
||||||
|
@ -705,7 +705,7 @@ mg_villages.count_inhabitated_buildings = function(village)
|
||||||
local bpos = village.to_add_data.bpos;
|
local bpos = village.to_add_data.bpos;
|
||||||
-- count the buildings
|
-- count the buildings
|
||||||
local anz_buildings = 0;
|
local anz_buildings = 0;
|
||||||
for i, pos in ipairs(bpos) do
|
for i, pos in pairs(bpos) do
|
||||||
if( pos.btype and not(pos.btype == 'road' )) then
|
if( pos.btype and not(pos.btype == 'road' )) then
|
||||||
local binfo = mg_villages.BUILDINGS[pos.btype];
|
local binfo = mg_villages.BUILDINGS[pos.btype];
|
||||||
-- count buildings which can house inhabitants as well as those requiring workers
|
-- count buildings which can house inhabitants as well as those requiring workers
|
||||||
|
@ -840,7 +840,7 @@ mg_villages.house_in_mapchunk_mark_intersection = function( villages, c, vnoise
|
||||||
local bsizez = c.to_add_data.bpos[1].bsizez;
|
local bsizez = c.to_add_data.bpos[1].bsizez;
|
||||||
|
|
||||||
-- make sure that the house does not intersect with the area of a village
|
-- make sure that the house does not intersect with the area of a village
|
||||||
for _,v in ipairs( villages ) do
|
for _,v in pairs( villages ) do
|
||||||
local id = v.vx..':'..v.vz;
|
local id = v.vx..':'..v.vz;
|
||||||
if( id and mg_villages.all_villages and mg_villages.all_villages[ id ] ) then
|
if( id and mg_villages.all_villages and mg_villages.all_villages[ id ] ) then
|
||||||
v = mg_villages.all_villages[ id ];
|
v = mg_villages.all_villages[ id ];
|
||||||
|
@ -896,7 +896,7 @@ mg_villages.houses_in_mapchunk = function( minp, mapchunk_size, villages )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,candidate in ipairs(village_candidates) do
|
for _,candidate in pairs(village_candidates) do
|
||||||
-- mark all one-house-village-candidates that intersect with villages in this mapchunk
|
-- mark all one-house-village-candidates that intersect with villages in this mapchunk
|
||||||
mg_villages.house_in_mapchunk_mark_intersection( villages, candidate, village_noise );
|
mg_villages.house_in_mapchunk_mark_intersection( villages, candidate, village_noise );
|
||||||
-- mark all one-house-village-candidates that intersect with other candidates in this mapchunk
|
-- mark all one-house-village-candidates that intersect with other candidates in this mapchunk
|
||||||
|
@ -905,7 +905,7 @@ mg_villages.houses_in_mapchunk = function( minp, mapchunk_size, villages )
|
||||||
|
|
||||||
-- now add those villages that do not intersect with others and which *may* at least be part of this mapchunk
|
-- now add those villages that do not intersect with others and which *may* at least be part of this mapchunk
|
||||||
local d = math.ceil( mapchunk_size / 2 );
|
local d = math.ceil( mapchunk_size / 2 );
|
||||||
for _,candidate in ipairs(village_candidates) do
|
for _,candidate in pairs(village_candidates) do
|
||||||
if( not( candidate.areas_intersect )
|
if( not( candidate.areas_intersect )
|
||||||
and (candidate.vx > minp.x - d or candidate.vx < (mapchunk_size+d) )
|
and (candidate.vx > minp.x - d or candidate.vx < (mapchunk_size+d) )
|
||||||
and (candidate.vz > minp.z - d or candidate.vz < (mapchunk_size+d) )) then
|
and (candidate.vz > minp.z - d or candidate.vz < (mapchunk_size+d) )) then
|
||||||
|
|
|
@ -53,7 +53,7 @@ armor.set_player_armor = function(self, player)
|
||||||
local textures = {}
|
local textures = {}
|
||||||
local elements = {}
|
local elements = {}
|
||||||
local physics_o = {}
|
local physics_o = {}
|
||||||
for i, v in ipairs(self.elements) do
|
for i, v in pairs(self.elements) do
|
||||||
local stack = player_inv:get_stack("armor_"..v, 1)
|
local stack = player_inv:get_stack("armor_"..v, 1)
|
||||||
local level = stack:get_definition().groups["armor_"..v]
|
local level = stack:get_definition().groups["armor_"..v]
|
||||||
local item = stack:get_name()
|
local item = stack:get_name()
|
||||||
|
@ -118,7 +118,7 @@ armor.update_armor = function(self, player)
|
||||||
local heal_max = 0
|
local heal_max = 0
|
||||||
local state = 0
|
local state = 0
|
||||||
local items = 0
|
local items = 0
|
||||||
for _,v in ipairs(self.elements) do
|
for _,v in pairs(self.elements) do
|
||||||
local stack = armor_inv:get_stack("armor_"..v, 1)
|
local stack = armor_inv:get_stack("armor_"..v, 1)
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
local use = stack:get_definition().groups["armor_use"] or 0
|
local use = stack:get_definition().groups["armor_use"] or 0
|
||||||
|
@ -218,7 +218,7 @@ minetest.register_on_joinplayer(function(player)
|
||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
for _,v in ipairs(armor.elements) do
|
for _,v in pairs(armor.elements) do
|
||||||
local list = "armor_"..v
|
local list = "armor_"..v
|
||||||
player_inv:set_size(list, 1)
|
player_inv:set_size(list, 1)
|
||||||
armor_inv:set_size(list, 1)
|
armor_inv:set_size(list, 1)
|
||||||
|
|
|
@ -79,7 +79,7 @@ skins.formspec.main = function(name)
|
||||||
end
|
end
|
||||||
local index = 0
|
local index = 0
|
||||||
local skip = 0 -- Skip skins, used for pages
|
local skip = 0 -- Skip skins, used for pages
|
||||||
for i, skin in ipairs(skins.list) do
|
for i, skin in pairs(skins.list) do
|
||||||
if skip < page*16 then skip = skip + 1 else
|
if skip < page*16 then skip = skip + 1 else
|
||||||
if index < 16 then
|
if index < 16 then
|
||||||
formspec = formspec .. "image_button["..(index%8)..","..((math.floor(index/8))*2+3)..";1,2;"..skin
|
formspec = formspec .. "image_button["..(index%8)..","..((math.floor(index/8))*2+3)..";1,2;"..skin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
skins.meta = {}
|
skins.meta = {}
|
||||||
for _, i in ipairs(skins.list) do
|
for _, i in pairs(skins.list) do
|
||||||
skins.meta[i] = {}
|
skins.meta[i] = {}
|
||||||
local f = io.open(skins.modpath.."/meta/"..i..".txt", "r")
|
local f = io.open(skins.modpath.."/meta/"..i..".txt", "r")
|
||||||
local data = nil
|
local data = nil
|
||||||
|
|
|
@ -7,7 +7,7 @@ skins.load = function()
|
||||||
end
|
end
|
||||||
if data and data ~= "" then
|
if data and data ~= "" then
|
||||||
local lines = string.split(data,"\n")
|
local lines = string.split(data,"\n")
|
||||||
for _, line in ipairs(lines) do
|
for _, line in pairs(lines) do
|
||||||
data = string.split(line, ' ', 2)
|
data = string.split(line, ' ', 2)
|
||||||
skins.skins[data[1]] = data[2]
|
skins.skins[data[1]] = data[2]
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ zcg.items_in_group = function(group)
|
||||||
for name, item in pairs(minetest.registered_items) do
|
for name, item in pairs(minetest.registered_items) do
|
||||||
-- the node should be in all groups
|
-- the node should be in all groups
|
||||||
ok = true
|
ok = true
|
||||||
for _, g in ipairs(group:split(',')) do
|
for _, g in pairs(group:split(',')) do
|
||||||
if not item.groups[g] then
|
if not item.groups[g] then
|
||||||
ok = false
|
ok = false
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,7 @@ zcg.add_craft = function(input, output, groups)
|
||||||
if groups[groupname] ~= nil then
|
if groups[groupname] ~= nil then
|
||||||
c.items[i] = groups[groupname]
|
c.items[i] = groups[groupname]
|
||||||
else
|
else
|
||||||
for _, gi in ipairs(zcg.items_in_group(groupname)) do
|
for _, gi in pairs(zcg.items_in_group(groupname)) do
|
||||||
local g2 = groups
|
local g2 = groups
|
||||||
g2[groupname] = gi
|
g2[groupname] = gi
|
||||||
zcg.add_craft({
|
zcg.add_craft({
|
||||||
|
@ -69,7 +69,7 @@ zcg.load_crafts = function(name)
|
||||||
zcg.crafts[name] = {}
|
zcg.crafts[name] = {}
|
||||||
local _recipes = minetest.get_all_craft_recipes(name)
|
local _recipes = minetest.get_all_craft_recipes(name)
|
||||||
if _recipes then
|
if _recipes then
|
||||||
for i, recipe in ipairs(_recipes) do
|
for i, recipe in pairs(_recipes) do
|
||||||
if (recipe and recipe.items and recipe.type) then
|
if (recipe and recipe.items and recipe.type) then
|
||||||
zcg.add_craft(recipe, name)
|
zcg.add_craft(recipe, name)
|
||||||
end
|
end
|
||||||
|
@ -149,7 +149,7 @@ zcg.formspec = function(pn)
|
||||||
local npp = 8*3 -- nodes per page
|
local npp = 8*3 -- nodes per page
|
||||||
local i = 0 -- for positionning buttons
|
local i = 0 -- for positionning buttons
|
||||||
local s = 0 -- for skipping pages
|
local s = 0 -- for skipping pages
|
||||||
for _, name in ipairs(zcg.itemlist) do
|
for _, name in pairs(zcg.itemlist) do
|
||||||
if s < page*npp then s = s+1 else
|
if s < page*npp then s = s+1 else
|
||||||
if i >= npp then break end
|
if i >= npp then break end
|
||||||
formspec = formspec .. "item_image_button["..(i%8)..","..(math.floor(i/8)+3.5)..";1,1;"..name..";zcg:"..name..";]"
|
formspec = formspec .. "item_image_button["..(i%8)..","..(math.floor(i/8)+3.5)..";1,1;"..name..";zcg:"..name..";]"
|
||||||
|
|
|
@ -344,7 +344,7 @@ function mobs:register_mob(name, def)
|
||||||
if hitter and hitter:is_player() and hitter:get_inventory() then
|
if hitter and hitter:is_player() and hitter:get_inventory() then
|
||||||
local name = hitter:get_player_name()
|
local name = hitter:get_player_name()
|
||||||
pd.increment(name,STAT_KILLS,1)
|
pd.increment(name,STAT_KILLS,1)
|
||||||
for _,drop in ipairs(self.drops) do
|
for _,drop in pairs(self.drops) do
|
||||||
if math.random(1, 100) < drop.chance then
|
if math.random(1, 100) < drop.chance then
|
||||||
local d = ItemStack(drop.name.." "..math.random(drop.min, drop.max))
|
local d = ItemStack(drop.name.." "..math.random(drop.min, drop.max))
|
||||||
default.drop_item(pos,d)
|
default.drop_item(pos,d)
|
||||||
|
@ -363,7 +363,7 @@ function mobs:register_mob(name, def)
|
||||||
local expGained = math.random(self.exp_min, emax)
|
local expGained = math.random(self.exp_min, emax)
|
||||||
skills.add_exp(hitter:get_player_name(),expGained)
|
skills.add_exp(hitter:get_player_name(),expGained)
|
||||||
local expStack = experience.exp_to_items(expGained)
|
local expStack = experience.exp_to_items(expGained)
|
||||||
for _,stack in ipairs(expStack) do
|
for _,stack in pairs(expStack) do
|
||||||
default.drop_item(pos,stack)
|
default.drop_item(pos,stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -97,7 +97,7 @@ mobs:register_mob("mobs:kid_lost", {
|
||||||
local o = minetest.get_objects_inside_radius(self.object:getpos(), 3)
|
local o = minetest.get_objects_inside_radius(self.object:getpos(), 3)
|
||||||
|
|
||||||
local yaw = 0
|
local yaw = 0
|
||||||
for _,o in ipairs(o) do
|
for _,o in pairs(o) do
|
||||||
if o:is_player() then
|
if o:is_player() then
|
||||||
lp = o:getpos()
|
lp = o:getpos()
|
||||||
break
|
break
|
||||||
|
|
|
@ -267,7 +267,7 @@ type = "npc_special",
|
||||||
local o = minetest.get_objects_inside_radius(self.object:getpos(), 3)
|
local o = minetest.get_objects_inside_radius(self.object:getpos(), 3)
|
||||||
|
|
||||||
local yaw = 0
|
local yaw = 0
|
||||||
for _,o in ipairs(o) do
|
for _,o in pairs(o) do
|
||||||
if o:is_player() then
|
if o:is_player() then
|
||||||
lp = o:getpos()
|
lp = o:getpos()
|
||||||
break
|
break
|
||||||
|
|
|
@ -8,7 +8,7 @@ function mobs.on_step(self,dtime)
|
||||||
self.lifetimer = self.lifetimer - dtime
|
self.lifetimer = self.lifetimer - dtime
|
||||||
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
|
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
|
||||||
local player_count = 0
|
local player_count = 0
|
||||||
for _,obj in ipairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do
|
for _,obj in pairs(minetest.get_objects_inside_radius(self.object:getpos(), 10)) do
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
player_count = player_count+1
|
player_count = player_count+1
|
||||||
end
|
end
|
||||||
|
@ -270,7 +270,7 @@ function mobs.on_step(self,dtime)
|
||||||
local inradius = minetest.get_objects_inside_radius(s,self.view_range)
|
local inradius = minetest.get_objects_inside_radius(s,self.view_range)
|
||||||
local player = nil
|
local player = nil
|
||||||
local type = nil
|
local type = nil
|
||||||
for _,oir in ipairs(inradius) do
|
for _,oir in pairs(inradius) do
|
||||||
if oir:is_player() then
|
if oir:is_player() then
|
||||||
player = oir
|
player = oir
|
||||||
type = "player"
|
type = "player"
|
||||||
|
@ -392,7 +392,7 @@ function mobs.on_step(self,dtime)
|
||||||
local o = minetest.get_objects_inside_radius(self.object:getpos(), 3)
|
local o = minetest.get_objects_inside_radius(self.object:getpos(), 3)
|
||||||
|
|
||||||
local yaw = 0
|
local yaw = 0
|
||||||
for _,o in ipairs(o) do
|
for _,o in pairs(o) do
|
||||||
if o:is_player() then
|
if o:is_player() then
|
||||||
lp = o:getpos()
|
lp = o:getpos()
|
||||||
break
|
break
|
||||||
|
|
|
@ -100,7 +100,7 @@ quests.treasure.generateQuest = function()
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
local allair = true
|
local allair = true
|
||||||
for _,d in ipairs(data) do
|
for _,d in pairs(data) do
|
||||||
if d ~= c_air and d ~= c_ignore then
|
if d ~= c_air and d ~= c_ignore then
|
||||||
allair = false
|
allair = false
|
||||||
end
|
end
|
||||||
|
@ -162,7 +162,7 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
function is_ground_node(nodeid)
|
function is_ground_node(nodeid)
|
||||||
for _,n in ipairs(ground_nodes) do
|
for _,n in pairs(ground_nodes) do
|
||||||
if minetest.get_content_id(n) == nodeid then
|
if minetest.get_content_id(n) == nodeid then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ local shoot_timer = {}
|
||||||
|
|
||||||
local throwing_shoot_arrow = function(itemstack, player)
|
local throwing_shoot_arrow = function(itemstack, player)
|
||||||
if shoot_timer[player:get_player_name()] <= 0 or shoot_timer[player:get_player_name()] == nil then
|
if shoot_timer[player:get_player_name()] <= 0 or shoot_timer[player:get_player_name()] == nil then
|
||||||
for _,arrow in ipairs(arrows) do
|
for _,arrow in pairs(arrows) do
|
||||||
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
|
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
player:get_inventory():remove_item("main", arrow[1])
|
player:get_inventory():remove_item("main", arrow[1])
|
||||||
|
|
|
@ -42,7 +42,7 @@ end
|
||||||
|
|
||||||
-- helper functions
|
-- helper functions
|
||||||
local function player_near(pos)
|
local function player_near(pos)
|
||||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, VIEW_DISTANCE)) do
|
for _,object in pairs(minetest.get_objects_inside_radius(pos, VIEW_DISTANCE)) do
|
||||||
if object:is_player() then
|
if object:is_player() then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ function whoison.createFile(loopit)
|
||||||
local file = io.open(filename, "w")
|
local file = io.open(filename, "w")
|
||||||
file:write(os.time().."\n")
|
file:write(os.time().."\n")
|
||||||
file:write(minetest.get_server_status().."\n")
|
file:write(minetest.get_server_status().."\n")
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
whoison.updateStats(name)
|
whoison.updateStats(name)
|
||||||
|
@ -118,7 +118,7 @@ minetest.register_chatcommand("timeonline",{
|
||||||
function breakdowntime(t)
|
function breakdowntime(t)
|
||||||
local eng = {"Seconds","Minutes","Hours","Days","Weeks","Months","Years"}
|
local eng = {"Seconds","Minutes","Hours","Days","Weeks","Months","Years"}
|
||||||
local inc = {60,60,24,7,4,12,1}
|
local inc = {60,60,24,7,4,12,1}
|
||||||
for k,v in ipairs(inc) do
|
for k,v in pairs(inc) do
|
||||||
if ( t > v ) then
|
if ( t > v ) then
|
||||||
t = math.floor( (t / v) )
|
t = math.floor( (t / v) )
|
||||||
else
|
else
|
||||||
|
|
|
@ -26,7 +26,7 @@ wool.dyes = {
|
||||||
{"dark_green", "Dark Green", "unicolor_dark_green"},
|
{"dark_green", "Dark Green", "unicolor_dark_green"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, row in ipairs(wool.dyes) do
|
for _, row in pairs(wool.dyes) do
|
||||||
local name = row[1]
|
local name = row[1]
|
||||||
local desc = row[2]
|
local desc = row[2]
|
||||||
local craft_color_group = row[3]
|
local craft_color_group = row[3]
|
||||||
|
|
Loading…
Reference in New Issue