haxball / haxball-issues

115 stars 43 forks source link

onTimeElapsed #309

Open gsnadav opened 6 years ago

gsnadav commented 6 years ago

An event which is called when the time on the clock is elapsed. Currently only onGameTick is available, but onGameTick is called also when the clock is stopped (after scoring a goal and before touching the ball once again) so there's no coherent way to do something on time.

basro commented 6 years ago

You can do this using the getScores() function which returns a struct with time and timeLimit in it. Here's an example: https://github.com/haxball/haxball-issues/blob/master/headless/examples/gameTime.js

gsnadav commented 6 years ago

Yes, but would you recommend to call it on every tick? Isn't it a little expensive?

basro commented 6 years ago

It should be fine, haxball does a lot of things way more expensive than this per tick.

But I guess adding an event for when the time limit is reached wouldn't hurt, so I'm reopening this issue.

Leo-MapCreator commented 6 years ago

@basro I have a doubt about what gsnadava said, about expensiveness, where do i ask you about this? Create a new topic or in this topic, even though this topic is about another thing?

Leo-MapCreator commented 6 years ago

@basro I have an variable in the angle of the uniform, and it changes per kick, making it a rotating uniform, is this expensive? Cause sometimes I feel the ping rises when this is enabled