0 votes

Hi! I am very new to godot and am attempting to play around with functions.
and my dilemma is this:

func text(delta):
$conTEXT.percent
visible += 1
pass

func onTimer_timeout():
_text()
pass

it says for this code, "too few arguments to for _text() call" and when I throw in like this

func onTimer_timeout():
_text(delta)
pass

it says that the function doesn't exist in that class...

so now i have input the delta next to timer_timeout() and have thrown it in as it's own variable... please help me fix this

Godot version 3.2
in Engine by (20 points)

Hi not sure what you are trying to do, however is some feedback

  • you need to ensure you match the name used in the function definition and call exactly. It looks like you are defining the function with name "text" and calling it with "_text"

  • I recommend not using text as a function name since Godot often uses that as a property name, so it might get a bit confusing.

  • I can not see how you defined the timer, however I assume that will keep running and you want it to keep calling your onTimer_timeout function, right?

  • Note, that percentvisible is a float number between 0 and 1, not a percentage (that's a bit confusing). By default this is 1.0, so unless you set that to 0.0 somewhere else, it will already be at maximum - your code adds 1 to it, so if you set it to 0.0 somewhere, it will go to fully visible after one call. If your objective is just to switch visibilty fully on after a timer, maybe you can use the visible property instead of percentvisible - that is either on or off. If you want it to fade in slowly, you can use percentvisible call it repeatedly on a timer, increasing by a small amount (for example 0.1) each time. Or you can read up on Animations and use that to fade in. That will reduce the amount of coding you need.

  • You probably do not need those "pass" commands. It just means "do nothing" and you usually use that when you working on defining functions but did not write the code yet. It's a placeholder.

  • delta is a special variable which contains the time since the last frame. Godot will call code which you define in process or physics_process with this variable so your code can know how long it was since the last frame. If you do not need that, you do not need to pass it to your function. In your case I assume you are using a timer to measure time, so you probably do not need to care about the time since the last frame, and you can ignore delta.

Try this

func increase_visible():
    $conTEXT.percentvisible += 1

func onTimer_timeout():
    increase_visible()

(Of course, since increasevisible only contains 1 line of code, you could simplify by just putting that directly inside the onTimertimeout function, but I think you wanted to know how to call another function )

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.