Skip to content

Commit

Permalink
Changed a valid check for thrown items to occur only when a surface i…
Browse files Browse the repository at this point in the history
…s deleted instead of during the item's flight
  • Loading branch information
Kiplacon committed Mar 8, 2023
1 parent 1fbb555 commit 34a7454
Show file tree
Hide file tree
Showing 6 changed files with 436 additions and 367 deletions.
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "factoriomod",
"request": "launch",
"name": "Factorio Mod Debug"
},
{
"type": "factoriomod",
"request": "launch",
"name": "Factorio Mod Debug (Settings & Data)",
"hookSettings": true,
"hookData": true
},
{
"type": "factoriomod",
"request": "launch",
"name": "Factorio Mod Debug (Profile)",
"hookMode": "profile"
}
]
}
33 changes: 33 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"factorio.versions": [
{
"name": "Steam Install",
"factorioPath": "d:\\Steam\\steamapps\\common\\Factorio\\bin\\x64\\factorio.exe",
"active": true
}
],
"Lua.workspace.library": [
"d:\\Steam\\steamapps\\common\\Factorio\\data",
"c:/Users/xiaox/AppData/Roaming/Code/User/workspaceStorage/f34a32745aa52066e3ffde1bd64d08ef/justarandomgeek.factoriomod-debug/sumneko-3rd/factorio/library"
],
"Lua.workspace.userThirdParty": [
"c:\\Users\\xiaox\\AppData\\Roaming\\Code\\User\\workspaceStorage\\f34a32745aa52066e3ffde1bd64d08ef\\justarandomgeek.factoriomod-debug\\sumneko-3rd"
],
"Lua.diagnostics.globals": [
"__DebugAdapter",
"__Profiler"
],
"Lua.runtime.builtin": {
"io": "disable",
"os": "disable",
"math": "disable",
"debug": "disable",
"coroutine": "disable",
"package": "disable"
},
"Lua.runtime.version": "Lua 5.2",
"Lua.runtime.special": {
"__object_name": "type"
},
"Lua.runtime.plugin": "c:/Users/xiaox/AppData/Roaming/Code/User/workspaceStorage/f34a32745aa52066e3ffde1bd64d08ef/justarandomgeek.factoriomod-debug/sumneko-3rd/factorio/plugin.lua"
}
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 1.1.11
Date: 3/7/2023
Changes:
- Changed a valid check for thrown items to occur only when a surface is deleted instead of during the item's flight. Should help with lag. The check was originally added to fix a crash when a surface with thrown items on it was deleted (like warptorio). Having the check only happen on surface deletion is less comprehensive but I've seen more comments about lag recently so I think it's worth a try
---------------------------------------------------------------------------------------------------
Version: 1.1.10
Date: 1/14/2023
Changes:
Expand Down
21 changes: 19 additions & 2 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ script.on_nth_tick(3,
function(event)
if (global.CatapultList ~= {}) then
for catapultID, properties in pairs(global.CatapultList) do

local catapult = properties.entity

BurnerSelfRefuelCompensation = 0.2
if (catapult.valid and catapult.burner == nil and catapult.fluidbox == nil and catapult.energy/catapult.electric_buffer_size >= 0.9) then
catapult.active = true
Expand Down Expand Up @@ -456,3 +454,22 @@ function(event)
end
end)

script.on_event(defines.events.on_pre_surface_deleted,
--surface_index :: uint
--name :: defines.events Identifier of the event
--tick :: uint Tick the event was generated.
function(event)
for each, FlyingItem in pairs(global.FlyingItems) do
if (rendering.get_surface(FlyingItem.sprite).index == event.surface_index) then
rendering.destroy(FlyingItem.sprite)
rendering.destroy(FlyingItem.shadow)
if (FlyingItem.destination ~= nil and global.OnTheWay[FlyingItem.destination]) then
global.OnTheWay[FlyingItem.destination][FlyingItem.item] = global.OnTheWay[FlyingItem.destination][FlyingItem.item] - FlyingItem.amount
end
if (FlyingItem.player) then
SwapBackFromGhost(FlyingItem.player, FlyingItem)
end
global.FlyingItems[each] = nil
end
end
end)
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "RenaiTransportation",
"version": "1.1.10",
"version": "1.1.11",
"title": "Renai Transportation",
"author": "Kiplacon",
"factorio_version": "1.1",
Expand Down
Loading

0 comments on commit 34a7454

Please sign in to comment.