Merge branch 'release/5.10.0' into dev

This commit is contained in:
Cooldude2606
2019-10-18 17:42:27 +01:00
5 changed files with 64 additions and 18 deletions

View File

@@ -47,15 +47,17 @@ Explosive Gaming (often ExpGaming) is a server hosting community with a strong f
All are welcome to make pull requests and issues for this scenario, if you are in any doubt please ask someone in our [discord]. If you do not know lua and don't feel like learning you can always make a [feature request]. All our docs can be found [here][docs]. Please keep in mind while making code changes:
* New features should have the branch names: `feature/feature-name`
* New features are merged into `dev` after it has been completed.
* After a number of features have been added a release branch is made: `release/X.Y.0`; this branch should have no new features and only bug fixes or localization.
* A release is merged into `master` on the following friday in time for the the weekly reset.
* Patches may be named `patch/X.Y.Z` and fill be merged into `master` and `dev` when appropriate.
* New features are merged into `dev` after it has been completed, this can be done through a pull request.
* After a number of features have been added a release branch is made: `release/X.Y.0`
* Bug fixes and localization can be made to the release branch with a pull request rather than into dev.
* A release is merged into `master` on the following friday after it is considered stable.
* Patches may be named `patch/X.Y.Z` and will be merged into `dev` and then `master` when appropriate.
## Releases
| Scenario Version* | Version Name | Factorio Version** |
|---|---|---|
| [v5.10][s5.10] | Data Store Rewrite | [v0.17.71][f0.17.71] |
| [v5.9][s5.9] | Control Modules and Documentation | [v0.17.63][f0.17.63] |
| [v5.8][s5.8] | Home and Chat Bot | [v0.17.47][f0.17.49] |
| [v5.7][s5.7] | Warp System | [v0.17.47][f0.17.47] |
@@ -76,6 +78,7 @@ All are welcome to make pull requests and issues for this scenario, if you are i
\*\* Factorio versions show the version they were made for, often the minimum requirement.
[s5.10]: https://github.com/explosivegaming/scenario/releases/tag/5.10.0
[s5.9]: https://github.com/explosivegaming/scenario/releases/tag/5.9.0
[s5.8]: https://github.com/explosivegaming/scenario/releases/tag/5.8.0
[s5.7]: https://github.com/explosivegaming/scenario/releases/tag/5.7.0
@@ -92,6 +95,7 @@ All are welcome to make pull requests and issues for this scenario, if you are i
[s1.0]: https://github.com/explosivegaming/scenario/releases/tag/v1.0
[s0.1]: https://github.com/explosivegaming/scenario/releases/tag/v0.1
[f0.17.71]: https://wiki.factorio.com/Version_history/0.17.0#0.17.71
[f0.17.63]: https://wiki.factorio.com/Version_history/0.17.0#0.17.63
[f0.17.49]: https://wiki.factorio.com/Version_history/0.17.0#0.17.49
[f0.17.47]: https://wiki.factorio.com/Version_history/0.17.0#0.17.47

View File

@@ -277,7 +277,9 @@ function Store.clear(store,key)
-- Check if there is a key being used
if key then
data_store[store][key] = nil
if type(data_store[store]) == 'table' then
data_store[store][key] = nil
end
else
data_store[store] = nil
end

View File

@@ -304,14 +304,14 @@ function Warps.add_warp(force_name,surface,position,player_name,warp_name)
warp_name = warp_name or 'New warp'
-- Get the existing warps for this force
local warps = force_warps[force_name]
if not warps then
force_warps[force_name] = {}
warps = force_warps[force_name]
local warp_ids = force_warps[force_name]
if not warp_ids then
warp_ids = {}
force_warps[force_name] = warp_ids
end
-- Insert the warp id into the force warps
table.insert(warps,warp_id)
table.insert(warp_ids,warp_id)
-- Create the editing table
local editing = {}

View File

@@ -326,7 +326,7 @@ Tasks.on_update(function(task,task_id)
local players
if task then
local force = game.forces[task.force_name]
players = force.players
players = force.connected_players
else
players = game.connected_players
end
@@ -338,6 +338,9 @@ Tasks.on_update(function(task,task_id)
end
end)
--- Update the tasks when the player joins
Event.add(defines.events.on_player_joined_game,task_list 'redraw')
--- Makes sure the right buttons are present when roles change
Event.add(Roles.events.on_role_assigned,task_list 'redraw')
Event.add(Roles.events.on_role_unassigned,task_list 'redraw')

View File

@@ -94,7 +94,7 @@ end)
Warps.teleport_player(warp_id,player)
-- Reset the warp cooldown if the player does not have unlimited warps
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)
Store.trigger(player_in_range_store,player)
end
@@ -434,7 +434,43 @@ end)
end)
--- When the name of a warp is updated this is triggered
Warps.on_update(warp_list 'update_all')
Warps.on_update(function(warp)
local players
local force_name
if warp then
local force = game.forces[warp.force_name]
players = force.connected_players
force_name = warp.force_name
else
players = game.connected_players
end
-- Update the gui for selected players
local force_warps = {}
for _,player in pairs(players) do
local frame = warp_list:get_frame(player)
local element = frame.container.scroll.table
-- Get the warp ids for the players force
force_name = force_name or player.force.name
local warp_ids = force_warps[force_name]
if not warp_ids then
warp_ids = Warps.get_force_warp_ids(force_name)
force_warps[force_name] = warp_ids
end
-- Update the gui
element.clear()
for _,warp_id in ipairs(warp_ids) do
generate_warp(player,element,warp_id)
end
end
end)
--- Update the warps when the player joins
Event.add(defines.events.on_player_joined_game,warp_list 'redraw')
Event.add(Roles.events.on_role_assigned,warp_list 'redraw')
Event.add(Roles.events.on_role_unassigned,warp_list 'redraw')
--- When the player leaves or enters range of a warp this is triggered
Store.watch(player_in_range_store,function(value,player_name)
@@ -459,7 +495,7 @@ Store.watch(player_in_range_store,function(value,player_name)
if element and element.valid then
element.enabled = state
if state then
local position = Warps.get_details(warp_id).position
local position = Warps.get_warp(warp_id).position
element.tooltip = {'warp-list.goto-tooltip',position.x,position.y}
else
element.tooltip = {'warp-list.goto-disabled'}
@@ -483,7 +519,7 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing),function()
local was_in_range = Store.get(player_in_range_store,player)
-- Get the ids of all the warps on the players force
local force_name = player.force
local force_name = player.force.name
local warp_ids = force_warps[force_name]
if not warp_ids then
warp_ids = Warps.get_force_warp_ids(force_name)
@@ -497,11 +533,11 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing),function()
local px,py = pos.x,pos.y
-- Loop over each warp
for _,warp_id in pairs(warp_ids) do
for _,warp_id in ipairs(warp_ids) do
-- Check if warp id is chached
local warp = warps[warp_id]
if not warp then
warp = Warps.get(warp_id)
warp = Warps.get_warp(warp_id)
warps[warp_id] = warp
end
@@ -509,11 +545,12 @@ Event.on_nth_tick(math.floor(60/config.update_smoothing),function()
local warp_pos = warp.position
if warp.surface == surface then
local dx, dy = px-warp_pos.x, py-warp_pos.y
if (dx*dx)+(dy*dy) < rs2 or (dx*dx)+(dy*dy) < r2 then
if (warp_id == warp_ids.spawn and (dx*dx)+(dy*dy) < rs2) or (dx*dx)+(dy*dy) < r2 then
-- Set in range to true if the player was preiovusly out of range
if not was_in_range then
Store.set(player_in_range_store,player,true)
end
was_in_range = false -- stops setting back to false below
break
end
end