Landmark 81 comments about lagging state
Moderator: Plugin Moderators
Landmark 81 comments about lagging state
When setting to night with that plugin, the game might be laggy and people don't like it fair enough.
- JustAnyone
- Developer
- Reactions:
- Posts: 3480
- Joined: 23 Jul 2017, 12:45
- Location: Easter Island
- Plugins: Showcase Store
-
Platform
Re: Landmark 81 comments about lagging state
They're not wrong there. The plugin animations during the night create around 24k draw calls while without the Lua code, only around 300. You can build a few dozen of these buildings on PC to benchmark the hardware you own
Re: Landmark 81 comments about lagging state
Ahhh ok I get itJustAnyone wrote: ↑28 Jul 2022, 23:26They're not wrong there. The plugin animations during the night create around 24k draw calls while without the Lua code, only around 300. You can build a few dozen of these buildings on PC to benchmark the hardware you own
I don't know why do they say that his night animation looks weird and very lag...
But good thing that plugin still be featured or have more chance to have been downloaded...
- Lobby
- Developer
- Reactions:
- Posts: 3705
- Joined: 26 Oct 2008, 12:34
- Plugins: Showcase Store
- Version: Beta
-
Platform
Re: Landmark 81 comments about lagging state
The plugin heavily relies on Lua to draw the lit windows. This is normally not an issue unless you start to overdo it (like in this case with more than 20,000 windows). In this case the best optimization is to try to reduce the amount of drawn images e.g. by merging the frames together into bigger ones.
On the Lua side of things there's usually also room for optimization. For plugin creators: Replace all Drawing.somefunction calls with local variables that get initialized once at the beginning of the script. Like that:
If you are calling these functions often it should improve the performance of your code quite significantly. The reason for this is how Lua works. If things are stored in a table the runtime has to look up the value for a key in each call. In this case it has to always first resolve the value of Drawing in the global table, and then look within that table for the corresponding function entry. In contrast, when storing values/functions in local variables the game can put them in fixed memory slots and therefore exactly know where to look for them.
On the Lua side of things there's usually also room for optimization. For plugin creators: Replace all Drawing.somefunction calls with local variables that get initialized once at the beginning of the script. Like that:
Code: Select all Reset
local setAdditive = Drawing.setAdditive local setAlpha = Drawing.setAlpha local setColor = Drawing.setColor local setTile = Drawing.setTile local drawImage = Drawing.drawImage function script:draw(x, y) -- ... drawImage(...) --Here you use the local variable drawImage instead of Drawing.drawImage -- ... end
Interactive Lua editor