Avorion Wiki
Explore
Main Page
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Admin noticeboard
Avorion Community
Official forum
Discord
Twitter
Reddit
Facebook
Steam
Gamepedia
Gamepedia support
Report a bad ad
Help Wiki
Contact us
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Avorion Wiki
356
pages
Explore
Main Page
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Admin noticeboard
Avorion Community
Official forum
Discord
Twitter
Reddit
Facebook
Steam
Gamepedia
Gamepedia support
Report a bad ad
Help Wiki
Contact us
Editing
Performance Optimization
(section)
Back to page
Edit
VisualEditor
View history
Talk (0)
Edit Page
Performance Optimization
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Use move Functions == '''Note:''' This is a rather advanced topic and should only be done by programmers who have already heard of [https://www.google.com/search?q=move+semantics move semantics]. Some classes of the Avorion [[Scripting API]] have special <code>move()</code> functions, that ''move internal data around, instead of copying it.'' This is useful, when you want to use large amounts of data (like a <code>BlockPlan</code> in a new place, like a new Entity. Take the following code excerpt from <code>stationfounder.lua</code> for example: <source lang="lua"> -- create the station -- get plan of ship local plan = ship:getPlan() -- this creates a copy of the plan -> slow! local crew = ship.crew -- create station local desc = StationDescriptor() desc.factionIndex = ship.factionIndex desc:setPlan(plan) -- this creates another copy of the plan -> slow! desc.position = ship.position desc.name = ship.name ship.name = "" local station = Sector():createEntity(desc) </source> <source lang="lua"> -- create the station -- get plan of ship local plan = ship:getMovePlan() -- moves the internal data out of the ship -> only reassigns a few pointers -> fast! -- now, the plan of the ship is only a single block, the actual plan is inside the local variable plan! local crew = ship.crew -- create station local desc = StationDescriptor() desc.factionIndex = ship.factionIndex desc:setMovePlan(plan) -- moves the internal data from the 'plan' variable into the descriptor -- 'plan' is still a valid variable, but it's an empty plan now, all data is in 'desc' desc.position = ship.position desc.name = ship.name ship.name = "" local station = Sector():createEntity(desc) </source> Moving data around is a fast and easy way of getting large amounts of data from one location to another, just keep in mind that, when you do this, you '''also modify the source object'''!
Summary:
Please note that all contributions to the Avorion Wiki are considered to be released under the CC BY-SA 3.0
Cancel
Editing help
(opens in new window)
Follow on IG
TikTok
Join Fan Lab