-
-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Implement set_time_left
in Timer node
#107920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Implement set_time_left
in Timer node
#107920
Conversation
It does seem like an oversight, since this functionality is already supported in the newer SceneTreeTimer class. I would suggest to keep the property setter simple, just like SceneTreeTimer. Always set time_left to what is passed in. There can be reasons to override it. Why disallow this? Until this is merged, users can use SceneTreeTimer which you can make with get_tree().create_timer(), which does support the property setter |
How different would this be to just calling |
My preference is to approve this pull request because in general properties ( |
set_time_left
in Timer node
Documentation needs update. |
This change aims to keep the node state as clean and consistent as possible. Setting a |
I was wondering this is going to need to change if we can change
Should we use ?
|
18fbfd6
to
b756a1c
Compare
b756a1c
to
ed852f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly want to see it perform the same as SceneTreeTimer, but the implementation of is_stopped()
is a bit unexpectedly different. I wouldn't mind seeing it changed to return processing
if it has mostly the same effect, since it would be easier to reason about.
For example, think about a case where I set a repeating timer to repeat every 0.1 seconds, but I am at less than 10 FPS. In this case, the timer will become negative and stay negative, and is_stopped() will be false, and get_time_left() will lie and say 0 even though the value is negative, yet a timeout event will be fired every frame. It's unclear what should happen but the current feels a bit wrong to me.
Anyway I'm not saying we should fix everything about the timer class at once, just that we should try our best to make its behavior consistent.
I think the last check is telling me to deprecate We could change it to |
ed852f9
to
0f5d46b
Compare
033180f
to
ec9e8f8
Compare
20653f2
to
c917550
Compare
73577dd
to
96d8848
Compare
96d8848
to
99bbcde
Compare
99bbcde
to
7f1b435
Compare
97deb7f
to
7cc0c26
Compare
74c8f72
to
7cc0c26
Compare
7cc0c26
to
88b9932
Compare
ea5f987
to
c8db7e6
Compare
sorry about the PR mess |
52e7178
to
3562c99
Compare
3562c99
to
79ebc9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is more accurate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the property while stopped does nothing and prints an error.
If new time_left is bigger than wait_time, sets wait_time value
Updates
scene\main\timer.cpp
scene\main\timer.h
time_left
property setter in Timer node godot-proposals#12655