A long time ago you introduced "namespaces" - system that allows to have semi-isolated scripts in one Lua VM to reduce memory consumption and increase script to script communication.
But you didn't use this mechanics for system upgrades. And I'm sure they eat a lot of memory, because ship/station can have up to 15 of them.
I want to help, so I changed "basesystem.lua" and all vanilla upgrades to utilize system that you used in your "shop.lua".
I'm talking about this:
ScriptNamespace = ShopAPI.CreateNamespace()
Plus I made some changes to make transition more smooth.
Which upgrades benefit from this the most:
Unique systems such as Xsotan upgrades.
Upgrades that don't stack: Wormhole Power Diverter, Minig System, Shield Impenetrator, Smuggler Blocker, Trading Overview, Valuables Detector, Velocity Bypass.
Other upgrades will require less memory too for the first one installed.
Example (arbitrarytcs.lua):
package.path = package.path .. ";data/scripts/systems/?.lua"
package.path = package.path .. ";data/scripts/lib/?.lua"
local BaseSystem = require ("basesystem")
require ("utility")
-- Don't remove or alter the following comment, it tells the game the namespace this script lives in. If you remove it, the script will break.
-- namespace ArbitraryTcs
ArbitraryTcs = {}
ArbitraryTcs = BaseSystem.CreateNamespace()
-- optimization so that energy requirement doesn't have to be read every frame
ArbitraryTcs.FixedEnergyRequirement = true
function ArbitraryTcs.getNumBonusTurrets(seed, rarity, permanent)
if permanent then
return math.max(1, math.floor(rarity.value / 2))
end
return 0
end
function ArbitraryTcs.getNumTurrets(seed, rarity, permanent)
return math.max(1, rarity.value) + ArbitraryTcs.getNumBonusTurrets(seed, rarity, permanent)
end
function ArbitraryTcs.onInstalled(seed, rarity, permanent)
ArbitraryTcs.addMultiplyableBias(StatsBonuses.ArbitraryTurrets, ArbitraryTcs.getNumTurrets(seed, rarity, permanent))
end
function ArbitraryTcs.onUninstalled(seed, rarity, permanent)
end
function ArbitraryTcs.getName(seed, rarity)
return "Turret Control System A-TCS-${num}"%_t % {num = ArbitraryTcs.getNumTurrets(seed, rarity, permanent)}
end
function ArbitraryTcs.getIcon(seed, rarity)
return "data/textures/icons/turret.png"
end
function ArbitraryTcs.getEnergy(seed, rarity, permanent)
local num = ArbitraryTcs.getNumTurrets(seed, rarity, permanent)
return num * 350 * 1000 * 1000 / (1.1 ^ rarity.value)
end
function ArbitraryTcs.getPrice(seed, rarity)
local num = ArbitraryTcs.getNumTurrets(seed, rarity, permanent)
local price = 7500 * num;
return price * 2.5 ^ rarity.value
end
function ArbitraryTcs.getTooltipLines(seed, rarity, permanent)
return
{
{ltext = "Armed or Unarmed Turret Slots"%_t, rtext = "+" .. ArbitraryTcs.getNumTurrets(seed, rarity, permanent), icon = "data/textures/icons/turret.png", boosted = permanent}
},
{
{ltext = "Armed or Unarmed Turret Slots"%_t, rtext = "+" .. ArbitraryTcs.getNumBonusTurrets(seed, rarity, true), icon = "data/textures/icons/turret.png"}
}
end
function ArbitraryTcs.getDescriptionLines(seed, rarity, permanent)
return
{
{ltext = "All-round Turret Control System"%_t, rtext = "", icon = ""},
{ltext = "Adds slots for armed and unarmed turrets"%_t, rtext = "", icon = ""}
}
end
You can download the archive with all files in the attachments.
Suggestion
Rinart73
A long time ago you introduced "namespaces" - system that allows to have semi-isolated scripts in one Lua VM to reduce memory consumption and increase script to script communication.
But you didn't use this mechanics for system upgrades. And I'm sure they eat a lot of memory, because ship/station can have up to 15 of them.
I want to help, so I changed "basesystem.lua" and all vanilla upgrades to utilize system that you used in your "shop.lua".
I'm talking about this:
Plus I made some changes to make transition more smooth.
Which upgrades benefit from this the most:
Other upgrades will require less memory too for the first one installed.
Example (arbitrarytcs.lua):
You can download the archive with all files in the attachments.
It also includes fix for this bug.
I hope that you'll find time to integrate it in the vanilla.
new-systems-0.19.1.zip
Link to comment
Share on other sites
0 answers to this suggestion
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now