From 2c30633bf0fbfd9ae07053995d7a048e7698757a Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 27 May 2016 17:25:00 -0500 Subject: [PATCH] Remove ipairs, lower fast speed --- minetest.conf | 2 +- mods/affects/api.lua | 2 +- mods/arena/init.lua | 2 +- mods/builtin_item/init.lua | 2 +- mods/bushes/init.lua | 2 +- mods/campfire/init.lua | 2 +- mods/cottages/nodes_doorlike.lua | 2 +- mods/creative/init.lua | 4 +- mods/default/functions.lua | 4 +- mods/default/nodes.lua | 2 +- mods/dye/init.lua | 4 +- mods/farming_plus/init.lua | 4 +- mods/farming_plus/pumpkin.lua | 8 +-- mods/handle_schematics/analyze_mts_file.lua | 2 +- mods/handle_schematics/analyze_we_file.lua | 2 +- mods/handle_schematics/build_chest.lua | 6 +-- .../build_chest_add_schems_by_directory.lua | 20 ++++---- .../build_chest_handle_replacements.lua | 16 +++--- .../build_chest_preview_image.lua | 10 ++-- .../handle_schematics_meta.lua | 8 +-- mods/handle_schematics/place_buildings.lua | 8 +-- .../replacements_farming.lua | 8 +-- .../replacements_get_table.lua | 2 +- .../replacements_realtest.lua | 4 +- mods/handle_schematics/replacements_roof.lua | 8 +-- mods/handle_schematics/replacements_wood.lua | 6 +-- mods/handle_schematics/rotate.lua | 2 +- mods/handle_schematics/worldedit_file.lua | 2 +- mods/hunger/food.lua | 2 +- mods/item_drop/init.lua | 4 +- mods/magic/thunder.lua | 2 +- mods/mg/dungeons.lua | 10 ++-- mods/mg_villages/buildings.lua | 4 +- mods/mg_villages/fill_chest.lua | 2 +- mods/mg_villages/init_weights.lua | 6 +-- mods/mg_villages/map_of_world.lua | 4 +- mods/mg_villages/mapgen.lua | 50 +++++++++---------- mods/mg_villages/protection.lua | 8 +-- mods/mg_villages/replacements.lua | 46 ++++++++--------- mods/mg_villages/spawn_player.lua | 2 +- mods/mg_villages/village_types.lua | 2 +- mods/mg_villages/villages.lua | 30 +++++------ mods/minetest-3d_armor/3d_armor/armor.lua | 6 +-- mods/minetest-skins/skins/init.lua | 2 +- mods/minetest-skins/skins/meta.lua | 2 +- mods/minetest-skins/skins/players.lua | 2 +- mods/minetest-zcg/zcg/init.lua | 8 +-- mods/mobs/api.lua | 4 +- mods/mobs/npcs/kids.lua | 2 +- mods/mobs/npcs/women.lua | 2 +- mods/mobs/step.lua | 6 +-- mods/quests/treasure.lua | 4 +- mods/throwing/init.lua | 2 +- mods/torches/mc_style.lua | 2 +- mods/whoison/init.lua | 4 +- mods/wool/init.lua | 2 +- 56 files changed, 182 insertions(+), 182 deletions(-) diff --git a/minetest.conf b/minetest.conf index 8df3536..3562104 100644 --- a/minetest.conf +++ b/minetest.conf @@ -17,7 +17,7 @@ movement_acceleration_air = 2.1 movement_acceleration_fast = 2.4 movement_speed_walk = 4.2 movement_speed_crouch = 2.1 -movement_speed_fast = 22 +movement_speed_fast = 6.8 movement_speed_climb = 2.2 movement_speed_jump = 6.9 movement_speed_descend = 6 diff --git a/mods/affects/api.lua b/mods/affects/api.lua index a66287d..26239be 100644 --- a/mods/affects/api.lua +++ b/mods/affects/api.lua @@ -75,7 +75,7 @@ end function affects.player_died(player) local name = player:get_player_name() - for _,a in ipairs(affects._removeOnDieAffects) do + for _,a in pairs(affects._removeOnDieAffects) do affects.removeAffect(name,a) end end diff --git a/mods/arena/init.lua b/mods/arena/init.lua index fdc63f8..26e226d 100644 --- a/mods/arena/init.lua +++ b/mods/arena/init.lua @@ -44,7 +44,7 @@ function arena.list(name) end function arena.in_arena(name) - for _,event in ipairs(events) do + for _,event in pairs(events) do if ( event.participants[name] == true ) then return event end diff --git a/mods/builtin_item/init.lua b/mods/builtin_item/init.lua index a9470c7..7c5c51c 100644 --- a/mods/builtin_item/init.lua +++ b/mods/builtin_item/init.lua @@ -252,7 +252,7 @@ core.register_entity(":__builtin:item", { if self.physical_state then local own_stack = ItemStack(self.object:get_luaentity().itemstring) -- 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() if obj and obj.name == "__builtin:item" and obj.physical_state == false then diff --git a/mods/bushes/init.lua b/mods/bushes/init.lua index 265cc17..3ec54bc 100644 --- a/mods/bushes/init.lua +++ b/mods/bushes/init.lua @@ -6,7 +6,7 @@ local BUSHES_DESCRIPTIONS = { "Strawberry", } -for i, bush_name in ipairs(BUSHES) do +for i, bush_name in pairs(BUSHES) do minetest.register_node("bushes:" .. bush_name .. "_bush", { description = BUSHES_DESCRIPTIONS[i] .. " bush", drawtype = "plantlike", diff --git a/mods/campfire/init.lua b/mods/campfire/init.lua index 6cfab2d..2eac71e 100644 --- a/mods/campfire/init.lua +++ b/mods/campfire/init.lua @@ -176,7 +176,7 @@ minetest.register_abm({ chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local meta = minetest.get_meta(pos) - for i, name in ipairs({ + for i, name in pairs({ "fuel_totaltime", "fuel_time", "src_totaltime", diff --git a/mods/cottages/nodes_doorlike.lua b/mods/cottages/nodes_doorlike.lua index 61a1bfb..e18ab67 100644 --- a/mods/cottages/nodes_doorlike.lua +++ b/mods/cottages/nodes_doorlike.lua @@ -23,7 +23,7 @@ cottages_window_sutter_operate = function( pos, old_node_state_name, new_node_st local stop_up = 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 } ); if( node and node.name and node.name==old_node_state_name diff --git a/mods/creative/init.lua b/mods/creative/init.lua index fa26348..8e91b2e 100644 --- a/mods/creative/init.lua +++ b/mods/creative/init.lua @@ -44,7 +44,7 @@ minetest.after(0, function() end table.sort(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)) end creative_inventory.creative_inventory_size = #creative_list @@ -153,7 +153,7 @@ if minetest.setting_getbool("creative_mode") then end local inv = digger:get_inventory() if inv then - for _,item in ipairs(drops) do + for _,item in pairs(drops) do item = ItemStack(item):get_name() if not inv:contains_item("main", item) then inv:add_item("main", item) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 7474246..0fc48a6 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -324,7 +324,7 @@ minetest.register_abm({ if not do_preserve then -- Drop stuff other than the node itself 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 itemname ~= n0.name then local p_drop = { @@ -373,7 +373,7 @@ function default.dump_inv(pos,listname,inv) inv = meta:get_inventory() end 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) stack:clear() inv:set_stack(listname, i, stack) diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 2c464f7..351e385 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -1173,7 +1173,7 @@ minetest.register_abm({ chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local meta = minetest.get_meta(pos) - for i, name in ipairs({ + for i, name in pairs({ "fuel_totaltime", "fuel_time", "src_totaltime", diff --git a/mods/dye/init.lua b/mods/dye/init.lua index ebdc938..d4febff 100644 --- a/mods/dye/init.lua +++ b/mods/dye/init.lua @@ -81,7 +81,7 @@ dyelocal.dyes = { } -- Define items -for _, row in ipairs(dyelocal.dyes) do +for _, row in pairs(dyelocal.dyes) do local name = row[1] local description = row[2] local groups = row[3] @@ -123,7 +123,7 @@ dyelocal.mixes = { } 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] minetest.register_craft({ type = "shapeless", diff --git a/mods/farming_plus/init.lua b/mods/farming_plus/init.lua index 3f7e2e0..a55269a 100644 --- a/mods/farming_plus/init.lua +++ b/mods/farming_plus/init.lua @@ -27,7 +27,7 @@ function farming:add_plant(full_grown, names, interval, chance) return end local step = nil - for i,name in ipairs(names) do + for i,name in pairs(names) do if name == node.name then step = i break @@ -56,7 +56,7 @@ function farming:generate_tree(pos, trunk, leaves, underground, replacements) pos.y = pos.y-1 local nodename = minetest.get_node(pos).name local ret = true - for _,name in ipairs(underground) do + for _,name in pairs(underground) do if nodename == name then ret = false break diff --git a/mods/farming_plus/pumpkin.lua b/mods/farming_plus/pumpkin.lua index 834722b..1c39c64 100644 --- a/mods/farming_plus/pumpkin.lua +++ b/mods/farming_plus/pumpkin.lua @@ -262,15 +262,15 @@ local box2 = { {-5, -2, -5, 5, 8, 5} } -for j,list in ipairs(box1) do - for i,int in ipairs(list) do +for j,list in pairs(box1) do + for i,int in pairs(list) do list[i] = int/16 end box1[j] = list end -for j,list in ipairs(box2) do - for i,int in ipairs(list) do +for j,list in pairs(box2) do + for i,int in pairs(list) do list[i] = int/16 end box2[j] = list diff --git a/mods/handle_schematics/analyze_mts_file.lua b/mods/handle_schematics/analyze_mts_file.lua index cecb9cd..72488de 100644 --- a/mods/handle_schematics/analyze_mts_file.lua +++ b/mods/handle_schematics/analyze_mts_file.lua @@ -131,7 +131,7 @@ handle_schematics.analyze_mts_file = function( path ) local needs_on_constr = {}; local is_air = 0; -- 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 ); needs_on_constr[ i ] = false; if( minetest.registered_nodes[ v ] and minetest.registered_nodes[ v ].on_construct ) then diff --git a/mods/handle_schematics/analyze_we_file.lua b/mods/handle_schematics/analyze_we_file.lua index 20f134c..cbd5974 100644 --- a/mods/handle_schematics/analyze_we_file.lua +++ b/mods/handle_schematics/analyze_we_file.lua @@ -23,7 +23,7 @@ handle_schematics.analyze_we_file = function(scm, we_origin) -- create a list of nodenames local nodenames = {}; 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 nodenames_id[ ent.name ] = #nodenames + 1; nodenames[ nodenames_id[ ent.name ] ] = ent.name; diff --git a/mods/handle_schematics/build_chest.lua b/mods/handle_schematics/build_chest.lua index 4cf3a24..93b7f2f 100644 --- a/mods/handle_schematics/build_chest.lua +++ b/mods/handle_schematics/build_chest.lua @@ -36,7 +36,7 @@ build_chest.add_entry = function( path ) end 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 sub_menu[ v ] = {}; end @@ -379,7 +379,7 @@ build_chest.update_formspec = function( pos, page, player, fields ) -- find out where we currently are in the menu tree 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 menu = menu[ v ]; end @@ -464,7 +464,7 @@ build_chest.update_formspec = function( pos, page, player, fields ) -- order alphabeticly 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; diff --git a/mods/handle_schematics/build_chest_add_schems_by_directory.lua b/mods/handle_schematics/build_chest_add_schems_by_directory.lua index 4359d64..9086d41 100644 --- a/mods/handle_schematics/build_chest_add_schems_by_directory.lua +++ b/mods/handle_schematics/build_chest_add_schems_by_directory.lua @@ -41,12 +41,12 @@ end -- 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 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 ); - 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 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( filename, path..'/mods/'..modname..'/'..subdir..'/', @@ -56,10 +56,10 @@ local build_chest_check_all_directories_mods_and_modpacks = function( path, menu end -- it might be a modpack 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 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( filename, 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 local d1 = minetest.get_dir_list( worldpath, true ); - for _,worldname in ipairs( d1 ) do + for _,worldname in pairs( d1 ) do -- get list of subdirectories 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 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( filename, worldpath..'/'..worldname..'/schems/', @@ -137,7 +137,7 @@ local build_chest_check_all_directories = function() -- search in all GAMES/* folders for mods containing schematics local game_path = main_path..'/games'; 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 ); end end @@ -149,7 +149,7 @@ if( minetest.setting_getbool( 'secure.enable_security' )) then local worldpath = minetest.get_worldpath(); local d3 = minetest.get_dir_list( worldpath..'/schems', false ); if( d3 ) then - for _,filename in ipairs( d3 ) do + for _,filename in pairs( d3 ) do build_chest_add_files_to_menu_from_directory( filename, worldpath..'/schems/', diff --git a/mods/handle_schematics/build_chest_handle_replacements.lua b/mods/handle_schematics/build_chest_handle_replacements.lua index f09e0a3..4d596dc 100644 --- a/mods/handle_schematics/build_chest_handle_replacements.lua +++ b/mods/handle_schematics/build_chest_handle_replacements.lua @@ -6,13 +6,13 @@ 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 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 if( name == w ) then found_type = w; -- no primary node found; there may still be subordinate types 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 found_type = w; end @@ -85,14 +85,14 @@ build_chest.replacements_get_list_formspec = function( pos, selected_row ) local types_found_list_roof = {}; 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]]; -- 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 local anz = v[2]; -- find out if this node name gets replaced local repl = name; - for j,r in ipairs( replacements ) do + for j,r in pairs( replacements ) do if( r and r[1]==name ) then repl = r[2]; end @@ -172,13 +172,13 @@ build_chest.replacements_replace_rest_with_air = function( pos, meta ) return; end 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]]; -- 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 -- find out if this node name gets replaced 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 repl = r[2]; -- 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 if( new_material=='air' or minetest.registered_nodes[ new_material ] ) then 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 v[2] = new_material; found = true; @@ -224,7 +224,7 @@ end build_chest.replacements_get_group_list_formspec = function( pos, group, button_name ) 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)..",".. tostring(3+math.floor((i-1)/8))..";1,1;".. tostring( v )..";"..tostring( button_name )..";"..tostring(i).."]"; diff --git a/mods/handle_schematics/build_chest_preview_image.lua b/mods/handle_schematics/build_chest_preview_image.lua index 82eae3e..44cae9c 100644 --- a/mods/handle_schematics/build_chest_preview_image.lua +++ b/mods/handle_schematics/build_chest_preview_image.lua @@ -134,7 +134,7 @@ build_chest.preview_image_formspec = function( building_name, replacements, side local side_names = {"front","right","back","left","top"}; 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 side = i; end @@ -154,9 +154,9 @@ build_chest.preview_image_formspec = function( building_name, replacements, side -- the draw_tile function is based on content_id local content_ids = {}; - for i,v in ipairs( data.nodenames ) do + for i,v in pairs( data.nodenames ) do 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 found = true; 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.]"; return formspec; end - for y,y_values in ipairs( preview ) do - for l,v in ipairs( y_values ) do + for y,y_values in pairs( preview ) do + for l,v in pairs( y_values ) do -- air, ignore and mg:ignore are not stored 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); diff --git a/mods/handle_schematics/handle_schematics_meta.lua b/mods/handle_schematics/handle_schematics_meta.lua index 5af66eb..7a763e2 100644 --- a/mods/handle_schematics/handle_schematics_meta.lua +++ b/mods/handle_schematics/handle_schematics_meta.lua @@ -30,7 +30,7 @@ local handle_schematics_get_meta_table = function( pos, all_meta, start_pos ) for name, list in pairs( m.inventory ) do invlist[ name ] = {}; 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 invlist[ name ][ i ] = stack:to_string(); 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 ); 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 ); end else @@ -114,7 +114,7 @@ handle_schematics.clear_meta = function( start_pos, end_pos ) local empty_meta = { inventory = {}, fields = {} }; 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 ); meta:from_table( empty_meta ); end @@ -130,7 +130,7 @@ handle_schematics.restore_meta = function( filename, all_meta, start_pos, end_po if( not( all_meta ) and filename ) then all_meta = save_restore.restore_data( 'schems/'..filename..'.meta' ); end - for _,pos in ipairs( all_meta ) do + for _,pos in pairs( all_meta ) do local p = {}; 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}; diff --git a/mods/handle_schematics/place_buildings.lua b/mods/handle_schematics/place_buildings.lua index f6109f5..0cd133c 100644 --- a/mods/handle_schematics/place_buildings.lua +++ b/mods/handle_schematics/place_buildings.lua @@ -140,7 +140,7 @@ local function generate_building_translate_nodenames( nodenames, replacements, c local i; local v; 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 @@ -578,7 +578,7 @@ handle_schematics.place_buildings = function(village, minp, maxp, data, param2_d local extranodes = {} 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 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 @@ -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 local node_name = minetest.get_name_from_content_id( k ); 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 ); end end @@ -783,7 +783,7 @@ end -- add the dirt roads handle_schematics.place_dirt_roads = function(village, minp, maxp, data, param2_data, a, c_road_node) 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 ); end end diff --git a/mods/handle_schematics/replacements_farming.lua b/mods/handle_schematics/replacements_farming.lua index 3763139..7a8d5a6 100644 --- a/mods/handle_schematics/replacements_farming.lua +++ b/mods/handle_schematics/replacements_farming.lua @@ -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 new = new_nodes[i]; local found = false; - for i,v in ipairs(replacements) do + for i,v in pairs(replacements) do if( v and v[1]==old ) then v[2] = new; 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) 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 ); if( id and id ~= c_ignore ) then 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 'tomato', 'corn' }; - for i,fruit in ipairs( fruits ) do + for i,fruit in pairs( fruits ) do if( minetest.registered_nodes[ 'farming_plus:'..fruit ] and minetest.registered_nodes[ 'farming_plus:'..fruit..'_1' ] 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 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:', '', '' ); end end diff --git a/mods/handle_schematics/replacements_get_table.lua b/mods/handle_schematics/replacements_get_table.lua index c07e81a..7585dce 100644 --- a/mods/handle_schematics/replacements_get_table.lua +++ b/mods/handle_schematics/replacements_get_table.lua @@ -10,7 +10,7 @@ handle_schematics.get_replacement_table = function( housetype, pr, replacements if( minetest.registered_nodes[ 'mg_villages:torch']) then table.insert( replacements, {'default:torch', 'mg_villages:torch'}); end - for i,v in ipairs( replacements ) do + for i,v in pairs( replacements ) do if( v and #v == 2 ) then rtable[ v[1] ] = v[2]; ids[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] ); diff --git a/mods/handle_schematics/replacements_realtest.lua b/mods/handle_schematics/replacements_realtest.lua index 7ba3261..df4d2f0 100644 --- a/mods/handle_schematics/replacements_realtest.lua +++ b/mods/handle_schematics/replacements_realtest.lua @@ -63,10 +63,10 @@ replacements_group['realtest'].replace = function( replacements ) 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 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 w[2] = v[2]; found = true; diff --git a/mods/handle_schematics/replacements_roof.lua b/mods/handle_schematics/replacements_roof.lua index 44e3215..3948399 100644 --- a/mods/handle_schematics/replacements_roof.lua +++ b/mods/handle_schematics/replacements_roof.lua @@ -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 new = new_nodes[i]; local found = false; - for i,v in ipairs(replacements) do + for i,v in pairs(replacements) do if( v and v[1]==old ) then v[2] = new; found = true; @@ -64,7 +64,7 @@ replacements_group['roof'].construct_roof_type_list = function() -- roof from cottages 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( { 'cottages:roof_connector_'..v, 'cottages:roof_flat_'..v, @@ -76,7 +76,7 @@ replacements_group['roof'].construct_roof_type_list = function() -- from dryplants roofs = {'reed', 'wetreed'}; - for i,v in ipairs( roofs ) do + for i,v in pairs( roofs ) do replacements_group['roof'].add_material( { 'dryplants:'..v..'_roof', 'dryplants:'..v..'_slab', @@ -88,7 +88,7 @@ replacements_group['roof'].construct_roof_type_list = function() end -- roof from homedecor roofs = {'wood', 'terracotta', 'asphalt', 'glass'}; - for i,v in ipairs( roofs ) do + for i,v in pairs( roofs ) do replacements_group['roof'].add_material( { 'homedecor:shingle_side_'..v, 'homedecor:shingles_'..v, diff --git a/mods/handle_schematics/replacements_wood.lua b/mods/handle_schematics/replacements_wood.lua index 483162c..4a2dc9b 100644 --- a/mods/handle_schematics/replacements_wood.lua +++ b/mods/handle_schematics/replacements_wood.lua @@ -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 new = new_nodes[i]; local found = false; - for i,v in ipairs(replacements) do + for i,v in pairs(replacements) do if( v and v[1]==old ) then v[2] = new; found = true; @@ -59,7 +59,7 @@ replacements_group['wood'].add_material = function( candidate_list, mod_prefix, if( not( candidate_list )) then return; end - for _,v in ipairs( candidate_list ) do + for _,v in pairs( candidate_list ) do local is_loaded = false; local wood_name = mod_prefix..w_pre..v..w_post; -- 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 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 ); if( id and id ~= c_ignore ) then replacements_group.node_is_ground[ id ] = false; diff --git a/mods/handle_schematics/rotate.lua b/mods/handle_schematics/rotate.lua index 91d6abd..e33ee7b 100644 --- a/mods/handle_schematics/rotate.lua +++ b/mods/handle_schematics/rotate.lua @@ -61,7 +61,7 @@ handle_schematics.add_mirrored_node_type = function( name, mirrored_name ) end 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..'_t_1', 'doors:door_'..material..'_t_2' ); handle_schematics.add_mirrored_node_type( 'doors:door_'..material..'_b_2', 'doors:door_'..material..'_b_1' ); diff --git a/mods/handle_schematics/worldedit_file.lua b/mods/handle_schematics/worldedit_file.lua index 9f421dd..90bb6de 100644 --- a/mods/handle_schematics/worldedit_file.lua +++ b/mods/handle_schematics/worldedit_file.lua @@ -82,7 +82,7 @@ function worldedit_file.load_schematic(value, we_origin) nodes = tables[1] 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] entry.x, entry.y, entry.z = pos.x, pos.y, pos.z entry[1] = nil diff --git a/mods/hunger/food.lua b/mods/hunger/food.lua index 01092a1..6dc481d 100644 --- a/mods/hunger/food.lua +++ b/mods/hunger/food.lua @@ -92,7 +92,7 @@ if minetest.get_modpath("bushes_classic") then "raspberry", "gooseberry", "mixed_berry"} - for _, berry in ipairs(berries) do + for _, berry in pairs(berries) do if berry ~= "mixed_berry" then register_food("bushes:"..berry, 1) end diff --git a/mods/item_drop/init.lua b/mods/item_drop/init.lua index a7d3b72..6ed3328 100644 --- a/mods/item_drop/init.lua +++ b/mods/item_drop/init.lua @@ -4,7 +4,7 @@ function itemdrop_globalstep(player,name,dtime) pos.y = pos.y+0.5 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 inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then inv:add_item("main", ItemStack(object:get_luaentity().itemstring)) @@ -20,7 +20,7 @@ function itemdrop_globalstep(player,name,dtime) 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 object:get_luaentity().collect then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then diff --git a/mods/magic/thunder.lua b/mods/magic/thunder.lua index 7ea5431..ef3257b 100644 --- a/mods/magic/thunder.lua +++ b/mods/magic/thunder.lua @@ -11,7 +11,7 @@ local thunder = { local rad = 15 * ( sk.level / 10 ) local damage = ( 25 * ( sk.level / skb.max_level ) ) 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 obj:punch(p, 1.0, { full_punch_interval=1.0, diff --git a/mods/mg/dungeons.lua b/mods/mg/dungeons.lua index 65f5a54..ed2ce66 100644 --- a/mods/mg/dungeons.lua +++ b/mods/mg/dungeons.lua @@ -43,7 +43,7 @@ minetest.register_on_generated( function (minp, maxp, blockseed) local spawn = {} local chests = {} 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)) -- find the size of this room --if v.y < 0 then @@ -153,16 +153,16 @@ minetest.register_on_generated( function (minp, maxp, blockseed) vm:set_data(data) vm:calc_lighting() vm:write_to_map(data) - for _,v in ipairs(spawn) do + for _,v in pairs(spawn) do mobs:spawn_mob(v.pos,v.mob) end - for _,cpos in ipairs(chests) do + for _,cpos in pairs(chests) do minetest.place_node(cpos,{name="default:chest"}) local meta = minetest.get_meta( cpos ); local inv = meta:get_inventory(); 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 local qty = math.random(1,item[3]) 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 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)) end end diff --git a/mods/mg_villages/buildings.lua b/mods/mg_villages/buildings.lua index ed8a161..909f3e5 100644 --- a/mods/mg_villages/buildings.lua +++ b/mods/mg_villages/buildings.lua @@ -367,7 +367,7 @@ mg_villages.add_building = function( building_data ) 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 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 -- we found the building building_nr = i; @@ -420,7 +420,7 @@ mg_villages.all_buildings_list = save_restore.restore_data( 'mg_villages_all_bu mg_villages.BUILDINGS = {}; local mts_path = mg_villages.modpath.."/schems/"; -- 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; mg_villages.add_building( v, i ); end diff --git a/mods/mg_villages/fill_chest.lua b/mods/mg_villages/fill_chest.lua index 4eeb455..d7e5286 100644 --- a/mods/mg_villages/fill_chest.lua +++ b/mods/mg_villages/fill_chest.lua @@ -177,7 +177,7 @@ mg_villages.fill_chest_random = function( pos, pr, building_nr, building_typ ) return; end 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 for count=1, v[ 4 ] do -- to avoid too many things inside a chest, lower probability diff --git a/mods/mg_villages/init_weights.lua b/mods/mg_villages/init_weights.lua index 3068ea2..f787c8e 100644 --- a/mods/mg_villages/init_weights.lua +++ b/mods/mg_villages/init_weights.lua @@ -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 ] = 'fields'; 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 - for _, i in ipairs(mg_villages.BUILDINGS) do + for _, i in pairs(mg_villages.BUILDINGS) do if( not( i.max_weight )) then i.max_weight = {}; end @@ -28,7 +28,7 @@ mg_villages.init_weights = function() end end 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 i.max_weight[v] = i.max_weight[ v ]*multiplier end diff --git a/mods/mg_villages/map_of_world.lua b/mods/mg_villages/map_of_world.lua index 71cd64c..7df3c40 100644 --- a/mods/mg_villages/map_of_world.lua +++ b/mods/mg_villages/map_of_world.lua @@ -79,7 +79,7 @@ mg_villages.map_of_world = function( pname ) if( type( surface_types )=='table' and false) then -- TODO: disabled for now dx = dx/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 local x2 = x1+( math.floor( (i-1)/5 )*dx); 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:]"; -- explain the meaning of the textures 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 ).."]".. "image[10.0,"..tostring(i+0.1)..";0.4,0.4;"..tostring( mg_villages.village_type_data[ typ ].texture ).."]"; i = i+0.45; diff --git a/mods/mg_villages/mapgen.lua b/mods/mg_villages/mapgen.lua index 00fdd36..3104812 100644 --- a/mods/mg_villages/mapgen.lua +++ b/mods/mg_villages/mapgen.lua @@ -84,7 +84,7 @@ mg_villages.villages_in_mapchunk = function( minp, mapchunk_size ) local villages = {} for xi = -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 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', '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 - 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; end 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; end end @@ -327,7 +327,7 @@ mg_villages.flatten_village_area = function( villages, minp, maxp, vm, data, par local treepos = {}; for z = minp.z, maxp.z 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_underground = nil; if( village.village_type @@ -367,7 +367,7 @@ mg_villages.flatten_village_area = function( villages, minp, maxp, vm, data, par end -- 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; if( tree.typ == 0 ) then 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 -- 4: 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 if( pos.btype and pos.btype == 'road' ) then 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 ) -- mark the dirt roads -- 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 for x = 0, pos.bsizex-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 }; 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); if( village.is_single_house ) then -- 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 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 mg_villages.village_area_mark_single_house_area( village_area, minp, maxp, village.to_add_data.bpos[1], pr, village_nr, village ); end @@ -584,7 +584,7 @@ mg_villages.village_area_get_height = function( village_area, villages, minp, ma local height_count = {}; local height_statistic = {}; -- 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_count[ village_nr ] = 0; height_statistic[ village_nr ] = {}; @@ -626,7 +626,7 @@ mg_villages.village_area_get_height = function( village_area, villages, minp, ma end end end - for village_nr, village in ipairs( villages ) do + for village_nr, village in pairs( villages ) do local tmin = maxp.y; local tmax = minp.y; @@ -704,10 +704,10 @@ end 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 )); - for _, pos in ipairs(village.to_add_data.bpos) do + for _, pos in pairs(village.to_add_data.bpos) do pos.y = new_height; 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; end 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 plant_selected = 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 has_snow_cover = true; 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 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 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 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 -- towers are usually found on elevated places 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'); end - for _, village in ipairs(villages) do + for _, village in pairs(villages) do -- the village_id will be stored in the plot markers 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); -- 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? end end @@ -1093,11 +1093,11 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm, 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 - 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 local node_name = minetest.get_name_from_content_id( k ); 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 ); end end @@ -1105,8 +1105,8 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm, end local pr = PseudoRandom(mg_villages.get_bseed(minp)); - for _, village in ipairs(villages) do - for _,v in ipairs( village.to_add_data.extra_calls.chests ) do + for _, village in pairs(villages) 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_typ = mg_villages.BUILDINGS[ building_nr.btype ].scm; 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. - 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 ); end -- initialize the pseudo random generator so that the chests will be filled in a reproducable pattern 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(...) -- place_schematics is no longer needed --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 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 ); if( not( village.name ) or village.name == '') then diff --git a/mods/mg_villages/protection.lua b/mods/mg_villages/protection.lua index 3feab50..c8bdc47 100644 --- a/mods/mg_villages/protection.lua +++ b/mods/mg_villages/protection.lua @@ -42,12 +42,12 @@ minetest.is_protected = function(pos, name) local village_id = mg_villages.get_town_id_at_pos( pos ); if( village_id ) then 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 trustedUser = false if trustedusers ~= nil then - for _,trusted in ipairs(trustedusers) do + for _,trusted in pairs(trustedusers) do if trusted == name then trustedUser = true end @@ -251,7 +251,7 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player ) if previousTrustees == nil then previousTrustees = {} else - for _, player in ipairs(previousTrustees) do + for _, player in pairs(previousTrustees) do output = output..player.."\n" end end @@ -271,7 +271,7 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player ) end 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 x = x + 1 end diff --git a/mods/mg_villages/replacements.lua b/mods/mg_villages/replacements.lua index 6f5903c..2474ab9 100644 --- a/mods/mg_villages/replacements.lua +++ b/mods/mg_villages/replacements.lua @@ -26,7 +26,7 @@ if( minetest.get_modpath( 'trees' ) -- realtest is very special as far as stairs are concerned mg_villages.realtest_stairs = {'default:stone','default:stone_flat','default: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' ); end -- 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; else - for i,v in ipairs( prefixes ) do + for i,v in pairs( prefixes ) do postfixes[i] = ''; end end @@ -63,9 +63,9 @@ mg_villages.replace_materials = function( replacements, pr, original_materials, local known_materials = {}; local wood_found = false; -- 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 - 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( 'default:wood' == m ) then wood_found = true; @@ -78,7 +78,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials, -- support wooden planks from moretrees 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 table.insert( known_materials, "moretrees:"..v[1].."_planks" ); 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 if( wood_found and minetest.get_modpath('deco')) then 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 table.insert( known_materials, "deco:"..v.."_plank" ); end @@ -98,7 +98,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials, --]] 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 if( v == 'mushroom' ) then table.insert( known_materials, "ethereal:mushroom_pore" ); @@ -114,7 +114,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials, end 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 table.insert( known_materials, 'forest:'..v..'_wood' ); end @@ -122,7 +122,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials, end 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 table.insert( known_materials, 'trees:wood_'..v ); end @@ -130,7 +130,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials, end 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 table.insert( known_materials, 'trees:'..v..'_planks' ); end @@ -158,7 +158,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials, return old_material; end - for i,v in ipairs( prefixes ) do + for i,v in pairs( prefixes ) do table.insert( replacements, { original_materials[ i ], v..new_material } ); end return new_material; @@ -178,7 +178,7 @@ mg_villages.replace_tree_trunk = function( replacements, wood_type ) table.insert( replacements, {'default:tree', 'mg:pinetree'}); 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 table.insert( replacements, {'default:tree', "moretrees:"..v[1].."_trunk"}); 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"}); 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 table.insert( replacements, {'default:tree', "ethereal:"..v.."_trunk"}); end end 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 table.insert( replacements, {'default:tree', "forest:"..v.."_tree"}); end end 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 table.insert( replacements, {'default:tree', "trees:tree_"..v}); end end 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 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 @@ -277,34 +277,34 @@ mg_villages.replace_saplings = function( replacements, wood_type ) elseif( wood_type == 'mg:pinewood' ) then table.insert( replacements, {'default:sapling', 'mg:pinesapling'}); 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 table.insert( replacements, {'default:sapling', "moretrees:"..v[1].."_sapling_ongen"}); end end 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 table.insert( replacements, {'default:sapling', "ethereal:"..v.."_sapling"}); end end 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 table.insert( replacements, {'default:sapling', "forest:"..v.."_sapling"}); end end 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 table.insert( replacements, {'default:sapling', "trees:sapling_"..v}); end end 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 table.insert( replacements, {'default:sapling', "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 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 replace[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] ); 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'}); end - for i,v in ipairs( replacements ) do + for i,v in pairs( replacements ) do if( v and #v == 2 ) then rtable[ v[1] ] = v[2]; ids[ minetest.get_content_id( v[1] )] = minetest.get_content_id( v[2] ); diff --git a/mods/mg_villages/spawn_player.lua b/mods/mg_villages/spawn_player.lua index f7065d2..ae17f79 100644 --- a/mods/mg_villages/spawn_player.lua +++ b/mods/mg_villages/spawn_player.lua @@ -16,7 +16,7 @@ function mg_villages.spawnplayer(player) for bx = -20, 20 do for bz = -20, 20 do 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 min_pos = {x = village.vx, y = village.vh + 2, z = village.vz} -- some villages are later adjusted in height; adapt these changes diff --git a/mods/mg_villages/village_types.lua b/mods/mg_villages/village_types.lua index 84c5e94..ec42997 100644 --- a/mods/mg_villages/village_types.lua +++ b/mods/mg_villages/village_types.lua @@ -77,7 +77,7 @@ mg_villages.add_village_type = function( type_name, v ) if( not( v.mods )) then v.mods = {}; end - for _,m in ipairs( v.mods ) do + for _,m in pairs( v.mods ) do if( not( minetest.get_modpath( m ))) then -- this village type will not be used because not all required mods are installed return false; diff --git a/mods/mg_villages/villages.lua b/mods/mg_villages/villages.lua index 14d9dac..4bbe9e4 100644 --- a/mods/mg_villages/villages.lua +++ b/mods/mg_villages/villages.lua @@ -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) 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 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 btype = b break @@ -161,7 +161,7 @@ local function choose_building_rot(l, pr, orient, village_type) end 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) 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 @@ -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 ] ); end - for _, i in ipairs(calls_to_do) do + for _, i in pairs(calls_to_do) do -- local new_roadsize = roadsize -- - 1 if pr:next(1, 100) <= mg_villages.BIG_ROAD_CHANCE then --new_roadsize = roadsize @@ -391,13 +391,13 @@ local function generate_bpos(village, pr, vnoise, space_between_buildings) local rx = vx - vs --[=[local l={} 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 total_weight = total_weight+i.weight i.max_weight = total_weight end 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 end for i=1, 2000 do @@ -411,7 +411,7 @@ local function generate_bpos(village, pr, vnoise, space_between_buildings) end end]] 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 btype = b break @@ -440,7 +440,7 @@ local function generate_bpos(village, pr, vnoise, space_between_buildings) bsizex, bsizez = bsizez, bsizex 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 end 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 return dirt_roads; end - for _, pos in ipairs( bpos ) do + for _, pos in pairs( bpos ) do local x = pos.x; local z = pos.z; @@ -588,7 +588,7 @@ end local MIN_DIST = 1 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 a.z - MIN_DIST <= z and z <= a.z + a.bsizez + MIN_DIST then 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 -- 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]; 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 )]; @@ -705,7 +705,7 @@ mg_villages.count_inhabitated_buildings = function(village) local bpos = village.to_add_data.bpos; -- count the buildings 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 local binfo = mg_villages.BUILDINGS[pos.btype]; -- 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; -- 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; if( id and mg_villages.all_villages and mg_villages.all_villages[ id ] ) then v = mg_villages.all_villages[ id ]; @@ -896,7 +896,7 @@ mg_villages.houses_in_mapchunk = function( minp, mapchunk_size, villages ) 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 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 @@ -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 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 ) 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 diff --git a/mods/minetest-3d_armor/3d_armor/armor.lua b/mods/minetest-3d_armor/3d_armor/armor.lua index 35c1aab..ed7373a 100644 --- a/mods/minetest-3d_armor/3d_armor/armor.lua +++ b/mods/minetest-3d_armor/3d_armor/armor.lua @@ -53,7 +53,7 @@ armor.set_player_armor = function(self, player) local textures = {} local elements = {} 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 level = stack:get_definition().groups["armor_"..v] local item = stack:get_name() @@ -118,7 +118,7 @@ armor.update_armor = function(self, player) local heal_max = 0 local state = 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) if stack:get_count() > 0 then local use = stack:get_definition().groups["armor_use"] or 0 @@ -218,7 +218,7 @@ minetest.register_on_joinplayer(function(player) return 0 end, }) - for _,v in ipairs(armor.elements) do + for _,v in pairs(armor.elements) do local list = "armor_"..v player_inv:set_size(list, 1) armor_inv:set_size(list, 1) diff --git a/mods/minetest-skins/skins/init.lua b/mods/minetest-skins/skins/init.lua index 10d383f..b88fe5a 100644 --- a/mods/minetest-skins/skins/init.lua +++ b/mods/minetest-skins/skins/init.lua @@ -79,7 +79,7 @@ skins.formspec.main = function(name) end local index = 0 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 index < 16 then formspec = formspec .. "image_button["..(index%8)..","..((math.floor(index/8))*2+3)..";1,2;"..skin diff --git a/mods/minetest-skins/skins/meta.lua b/mods/minetest-skins/skins/meta.lua index 7f98372..2407ea9 100644 --- a/mods/minetest-skins/skins/meta.lua +++ b/mods/minetest-skins/skins/meta.lua @@ -1,5 +1,5 @@ skins.meta = {} -for _, i in ipairs(skins.list) do +for _, i in pairs(skins.list) do skins.meta[i] = {} local f = io.open(skins.modpath.."/meta/"..i..".txt", "r") local data = nil diff --git a/mods/minetest-skins/skins/players.lua b/mods/minetest-skins/skins/players.lua index a0e1950..76bc47b 100644 --- a/mods/minetest-skins/skins/players.lua +++ b/mods/minetest-skins/skins/players.lua @@ -7,7 +7,7 @@ skins.load = function() end if data and data ~= "" then local lines = string.split(data,"\n") - for _, line in ipairs(lines) do + for _, line in pairs(lines) do data = string.split(line, ' ', 2) skins.skins[data[1]] = data[2] end diff --git a/mods/minetest-zcg/zcg/init.lua b/mods/minetest-zcg/zcg/init.lua index b8318c5..98ec1a9 100644 --- a/mods/minetest-zcg/zcg/init.lua +++ b/mods/minetest-zcg/zcg/init.lua @@ -14,7 +14,7 @@ zcg.items_in_group = function(group) for name, item in pairs(minetest.registered_items) do -- the node should be in all groups ok = true - for _, g in ipairs(group:split(',')) do + for _, g in pairs(group:split(',')) do if not item.groups[g] then ok = false end @@ -48,7 +48,7 @@ zcg.add_craft = function(input, output, groups) if groups[groupname] ~= nil then c.items[i] = groups[groupname] else - for _, gi in ipairs(zcg.items_in_group(groupname)) do + for _, gi in pairs(zcg.items_in_group(groupname)) do local g2 = groups g2[groupname] = gi zcg.add_craft({ @@ -69,7 +69,7 @@ zcg.load_crafts = function(name) zcg.crafts[name] = {} local _recipes = minetest.get_all_craft_recipes(name) 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 zcg.add_craft(recipe, name) end @@ -149,7 +149,7 @@ zcg.formspec = function(pn) local npp = 8*3 -- nodes per page local i = 0 -- for positionning buttons 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 i >= npp then break end formspec = formspec .. "item_image_button["..(i%8)..","..(math.floor(i/8)+3.5)..";1,1;"..name..";zcg:"..name..";]" diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index bc76840..4d1244c 100644 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -344,7 +344,7 @@ function mobs:register_mob(name, def) if hitter and hitter:is_player() and hitter:get_inventory() then local name = hitter:get_player_name() 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 local d = ItemStack(drop.name.." "..math.random(drop.min, drop.max)) default.drop_item(pos,d) @@ -363,7 +363,7 @@ function mobs:register_mob(name, def) local expGained = math.random(self.exp_min, emax) skills.add_exp(hitter:get_player_name(),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) end end diff --git a/mods/mobs/npcs/kids.lua b/mods/mobs/npcs/kids.lua index 28ae8ea..629ad70 100644 --- a/mods/mobs/npcs/kids.lua +++ b/mods/mobs/npcs/kids.lua @@ -97,7 +97,7 @@ mobs:register_mob("mobs:kid_lost", { local o = minetest.get_objects_inside_radius(self.object:getpos(), 3) local yaw = 0 - for _,o in ipairs(o) do + for _,o in pairs(o) do if o:is_player() then lp = o:getpos() break diff --git a/mods/mobs/npcs/women.lua b/mods/mobs/npcs/women.lua index 15c7429..3b27157 100644 --- a/mods/mobs/npcs/women.lua +++ b/mods/mobs/npcs/women.lua @@ -267,7 +267,7 @@ type = "npc_special", local o = minetest.get_objects_inside_radius(self.object:getpos(), 3) local yaw = 0 - for _,o in ipairs(o) do + for _,o in pairs(o) do if o:is_player() then lp = o:getpos() break diff --git a/mods/mobs/step.lua b/mods/mobs/step.lua index 4b70b34..2c0e38a 100644 --- a/mods/mobs/step.lua +++ b/mods/mobs/step.lua @@ -8,7 +8,7 @@ function mobs.on_step(self,dtime) self.lifetimer = self.lifetimer - dtime if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then 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 player_count = player_count+1 end @@ -270,7 +270,7 @@ function mobs.on_step(self,dtime) local inradius = minetest.get_objects_inside_radius(s,self.view_range) local player = nil local type = nil - for _,oir in ipairs(inradius) do + for _,oir in pairs(inradius) do if oir:is_player() then player = oir type = "player" @@ -392,7 +392,7 @@ function mobs.on_step(self,dtime) local o = minetest.get_objects_inside_radius(self.object:getpos(), 3) local yaw = 0 - for _,o in ipairs(o) do + for _,o in pairs(o) do if o:is_player() then lp = o:getpos() break diff --git a/mods/quests/treasure.lua b/mods/quests/treasure.lua index a2f8fe4..dbdfc41 100644 --- a/mods/quests/treasure.lua +++ b/mods/quests/treasure.lua @@ -100,7 +100,7 @@ quests.treasure.generateQuest = function() local data = vm:get_data() local allair = true - for _,d in ipairs(data) do + for _,d in pairs(data) do if d ~= c_air and d ~= c_ignore then allair = false end @@ -162,7 +162,7 @@ else end 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 return true end diff --git a/mods/throwing/init.lua b/mods/throwing/init.lua index 368579d..8291dbe 100644 --- a/mods/throwing/init.lua +++ b/mods/throwing/init.lua @@ -8,7 +8,7 @@ local shoot_timer = {} local throwing_shoot_arrow = function(itemstack, player) 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 not minetest.setting_getbool("creative_mode") then player:get_inventory():remove_item("main", arrow[1]) diff --git a/mods/torches/mc_style.lua b/mods/torches/mc_style.lua index f984d67..e210f89 100644 --- a/mods/torches/mc_style.lua +++ b/mods/torches/mc_style.lua @@ -42,7 +42,7 @@ end -- helper functions 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 return true end diff --git a/mods/whoison/init.lua b/mods/whoison/init.lua index c4e975d..7b3d387 100644 --- a/mods/whoison/init.lua +++ b/mods/whoison/init.lua @@ -9,7 +9,7 @@ function whoison.createFile(loopit) local file = io.open(filename, "w") file:write(os.time().."\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() whoison.updateStats(name) @@ -118,7 +118,7 @@ minetest.register_chatcommand("timeonline",{ function breakdowntime(t) local eng = {"Seconds","Minutes","Hours","Days","Weeks","Months","Years"} 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 t = math.floor( (t / v) ) else diff --git a/mods/wool/init.lua b/mods/wool/init.lua index 14cffa5..c17b55e 100644 --- a/mods/wool/init.lua +++ b/mods/wool/init.lua @@ -26,7 +26,7 @@ wool.dyes = { {"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 desc = row[2] local craft_color_group = row[3]