diff --git a/config/warps.lua b/config/warps.lua index 378b6340..c4e2b2c8 100644 --- a/config/warps.lua +++ b/config/warps.lua @@ -1,17 +1,17 @@ --- This file contains all the different settings for the warp system and gui return { recharge_time = 60, -- The amount of time in seconds that the player must wait between warps, acts as a balance - update_smoothing = 10, -- Higher is better, the amount of smothing applied to recharge timer and other gui updates, max is 60 + update_smoothing = 10, -- Higher is better, the amount of smoothing applied to recharge timer and other gui updates, max is 60 minimum_distance = 100, -- The minimum distance that must be between warp points, creating new ones is blocked when too close - activation_range = 4, -- The distance the player must be to a warp in order to use the warp gui, gui can still be viewd but not used + activation_range = 4, -- The distance the player must be to a warp in order to use the warp gui, gui can still be viewed but not used spawn_activation_range = 20, -- A second activation range which is used for the forces spawn point default_icon = 'discharge-defense-equipment', -- The deafult icon which is used by warps; must be an item name user_can_edit_own_warps = false, -- When true the user can always edit warps which they created regaudless of other settings any_user_can_add_new_warp = false, -- When true any user is able to create new warps, however editing may still be restricted only_admins_can_edit = false, -- When true only admins can edit warps - edit_warps_role_permision = 'gui/warp-list/edit', -- Role permission used by the role system to allow editing warps - bypass_warp_limits_permision = 'gui/warp-list/no-limit', -- Role permission used by the role system to allow bypassing the time and distance restrctions - entities = { -- The entites which are created for warps + edit_warps_role_permission = 'gui/warp-list/edit', -- Role permission used by the role system to allow editing warps + bypass_warp_limits_permission = 'gui/warp-list/no-limit', -- Role permission used by the role system to allow bypassing the time and distance restrictions + entities = { -- The entities which are created for warps {'small-lamp',-3,-2},{'small-lamp',-3,2},{'small-lamp',3,-2},{'small-lamp',3,2}, {'small-lamp',-2,-3},{'small-lamp',2,-3},{'small-lamp',-2,3},{'small-lamp',2,3}, {'small-electric-pole',-3,-3},{'small-electric-pole',3,3},{'small-electric-pole',-3,3},{'small-electric-pole',3,-3} diff --git a/modules/gui/warp-list.lua b/modules/gui/warp-list.lua index 7b85835b..ce2ebc66 100644 --- a/modules/gui/warp-list.lua +++ b/modules/gui/warp-list.lua @@ -47,7 +47,7 @@ local function player_allowed_edit(player,warp_id) return false end - if config.edit_warps_role_permision and not Roles.player_allowed(player,config.edit_warps_role_permision) then + if config.edit_warps_role_permission and not Roles.player_allowed(player,config.edit_warps_role_permission) then return false end @@ -87,8 +87,8 @@ local function make_warp_area(warp_id) if not warp then return end local position = warp.position - local posx = position.x - local posy = position.y + local px = position.x + local py = position.y local surface = warp.surface local radius = config.activation_range local radius2 = radius^2 @@ -104,7 +104,7 @@ local function make_warp_area(warp_id) for y = -radius, radius do local y2 = y^2 if x2+y2 < radius2 then - table.insert(base_tiles,{name=base_tile,position={x+posx,y+posy}}) + table.insert(base_tiles,{name=base_tile,position={x+px,y+py}}) end end end @@ -113,15 +113,15 @@ local function make_warp_area(warp_id) -- this adds the tile pattern local tiles = {} for _,pos in pairs(config.tiles) do - table.insert(tiles,{name=base_tile,position={pos[1]+posx,pos[2]+posy}}) + table.insert(tiles,{name=base_tile,position={pos[1]+px,pos[2]+py}}) end surface.set_tiles(tiles) - -- this adds the enitites + -- this adds the entities for _,entity in pairs(config.entities) do entity = surface.create_entity{ name=entity[1], - position={entity[2]+posx,entity[3]+posy}, + position={entity[2]+px,entity[3]+py}, force='neutral' } entity.destructible = false @@ -155,7 +155,7 @@ local function clear_warp_area(warp_id) end surface.set_tiles(tiles) - -- removes all entites (in the area) on the neutral force + -- removes all entities (in the area) on the neutral force local entities = surface.find_entities_filtered{ force='neutral', area={ @@ -168,7 +168,7 @@ local function clear_warp_area(warp_id) if warp.tag and warp.tag.valid then warp.tag.destroy() end end ---- Speaial case for the warps; adds the spawn warp which cant be removed +--- Special case for the warps; adds the spawn warp which cant be removed local function add_spawn(player) local warp_id = tostring(Token.uid()) local force = player.force @@ -229,7 +229,7 @@ local function add_warp(player) make_warp_area(warp_id) end ---- Removes all refrences to a warp +--- Removes all references to a warp local function remove_warp(warp_id) local force_name = warp_details[warp_id].force local key = table.index_of(force_warps[force_name],warp_id) @@ -287,7 +287,7 @@ end) if player.driving then player.driving = false end player.teleport(goto_position,surface) - if config.bypass_warp_limits_permision and not Roles.player_allowed(player,config.bypass_warp_limits_permision) then + if config.bypass_warp_limits_permission and not Roles.player_allowed(player,config.bypass_warp_limits_permission) then warp_timer:set_store(player.name,0) -- this is to force an update of the buttons local in_range = Store.get(warp_player_in_range_store,player.name) @@ -307,15 +307,15 @@ Gui.new_button() end) :on_click(function(player,element) local position = player.position - local posx = position.x - local posy = position.y + local px = position.x + local py = position.y local dist2 = config.minimum_distance^2 local warps = Store.get_children(warp_name_store) for _,warp_id in pairs(warps) do local warp = warp_details[warp_id] local pos = warp.position - if (posx-pos.x)^2+(posy-pos.y)^2 < dist2 then + if (px-pos.x)^2+(py-pos.y)^2 < dist2 then local warp_name = Store.get(warp_name_store,warp_id) player.print{'warp-list.too-close',warp_name} return @@ -493,7 +493,7 @@ function generate_warp(player,element,warp_id) local timer = warp_timer:get_store(player.name) local enabled = not timer and Store.get(warp_player_in_range_store,player.name) - or Roles.player_allowed(player,config.bypass_warp_limits_permision) + or Roles.player_allowed(player,config.bypass_warp_limits_permission) if not enabled then btn.enabled = false btn.tooltip = {'warp-list.goto-disabled'} @@ -513,7 +513,7 @@ function generate_warp(player,element,warp_id) label.style.maximal_width = 150 elseif editing and element_type ~= 'textfield' then - -- create the text field, edit mode, update it omited as value is being edited + -- create the text field, edit mode, update it omitted as value is being edited if edit_area then edit_area[edit_warp.name].enabled = false end @@ -685,7 +685,7 @@ Store.register(warp_player_in_range_store,function(value,player_name) Gui.toggle_left_frame(warp_list.name,player,value) end - if Roles.player_allowed(player,config.bypass_warp_limits_permision) then + if Roles.player_allowed(player,config.bypass_warp_limits_permission) then return end @@ -725,9 +725,9 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing),function() local px,py = pos.x,pos.y for _,warp_id in pairs(warps) do local warp = warp_details[warp_id] - local wpos = warp.position + local warp_pos = warp.position if warp.surface.index == surface then - local dx,dy = px-wpos.x,py-wpos.y + local dx,dy = px-warp_pos.x,py-warp_pos.y if not warp.editing and (dx*dx)+(dy*dy) < rs2 or (dx*dx)+(dy*dy) < r2 then if not was_in_range then Store.set(warp_player_in_range_store,player.name,true) @@ -751,7 +751,7 @@ Event.add(defines.events.on_player_created,function(event) local player = Game.get_player_by_index(event.player_index) local force_name = player.force.name - local allowed = config.bypass_warp_limits_permision and Roles.player_allowed(player,config.bypass_warp_limits_permision) or false + local allowed = config.bypass_warp_limits_permission and Roles.player_allowed(player,config.bypass_warp_limits_permission) or false Store.set(warp_player_in_range_store,player.name,allowed) if allowed then warp_timer:set_store(player.name,1)