Page MenuHomeFeedback Tracker

Optimize "addAction"
Closed, ResolvedPublic

Description

addAction command has condition field which has to return true in order for the user added action to show in action menu (mouse wheel scroll). This condition field is evaluated every frame, so if you have 60 FPS the code in it will run 60 times a second.

With 10 custom actions added you get 600 script executions a second for absolutely no reason. What is the point to run condition check on action that is hidden when action menu is not in use? Why not to make it like with map "DRAW" event, execute only when menu is visible?

Details

Legacy ID
147803361
Severity
None
Resolution
Fixed
Reproducibility
Always
Category
Performance
Steps To Reproduce

run this in debug console

player addAction ["SOME ACTION!", {}, "", 10, false, true, "", "hintSilent str time; true"];

you will instantly see hint showing changing time. this is because action condition gets checked every frame already.

Expected hint to show only when user scrolls mouse wheel

Event Timeline

Killzone_Kid edited Additional Information. (Show Details)
Killzone_Kid set Category to Performance.
Killzone_Kid set Reproducibility to Always.
Killzone_Kid set Severity to None.
Killzone_Kid set Resolution to Fixed.
Killzone_Kid set Legacy ID to 147803361.May 7 2016, 5:48 PM
Killzone_Kid added a subscriber: Killzone_Kid.

Forgot to add these are non scheduled condition evaluations as well, which will take priority over other scripts

I have added a note to wiki about there being a condition before condition is evaluated. This does not apply to when action is added to player, so the optimization request stands.

"NOTE: condition in general is evaluated every frame. If action is added to some object and not to player, condition will only get evaluated IF player is closer than 15m to the object AND is looking at the object. If action is added to player, the condition evaluated all the time."

http://community.bistudio.com/wiki/addAction

While the way addaction works with other objects is very good, I fear asking to optimise it to benefit adding action to player may break this functionality. So I'm closing the ticket, leave it as it is.