Landmark 81 comments about lagging state

Plugin specific problems will be solved here.

Moderator: Plugin Moderators

User avatar
Memebooms
Inhabitant of a Megacity
Reactions:
Posts: 311
Joined: 23 Oct 2021, 07:20

Landmark 81 comments about lagging state

#1

Post by Memebooms »

Screenshot_20220719_065643.jpg
Screenshot_20220719_065659.jpg
The night animation is the problem...
When setting to night with that plugin, the game might be laggy and people don't like it fair enough.

User avatar
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

#2

Post by JustAnyone »

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 :)

User avatar
Memebooms
Inhabitant of a Megacity
Reactions:
Posts: 311
Joined: 23 Oct 2021, 07:20

Re: Landmark 81 comments about lagging state

#3

Post by Memebooms »

JustAnyone wrote:
28 Jul 2022, 23:26
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 :)
Ahhh ok I get it
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...

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Landmark 81 comments about lagging state

#4

Post by Lobby »

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:

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
Run
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. :teach

Post Reply Previous topicNext topic

Return to “Problems”