- Home /
Cannot convert 'callable(int) as float' to 'float'.
What is the correct way to do this type of conversion?
What im doing is getting information from an XML file, converting that text into a float with parseFloat. Trying to pass this number directly into a yield waitForSeconds(); call gives me the following error:
Cannot convert 'callable(int) as float' to 'float'.
What am i doing wrong here? Simple mistake? Thanks for your time!
EDIT- here you go, scripts to follow.
xml get data script :
var waitTimeNext: float;
function start() { var tempWaitTimeNext: String = stepNode.GetValue("wait>2>_text"); tempStepObj.waitTimeNext = parseFloat(tempWaitTimeNext); }
script with yield :
var c : float = (lessonDataScript.getStepWaitTimeNext);
yield WaitForSeconds (c);
Answer by burnumd · May 12, 2010 at 07:29 PM
What is "getStepWaitTimeNext?" Is that a function that returns the value in "tempStepObj.waitTimeNext?" If so, you need to put parentheses after it to call it. Otherwise, you're trying to put a callable (or function definition) into that float value, c.
As a sidenote, this issue is an example of when proper formatting can really help. If "getStepWaitTimeNext" were a function that started with a capital letter (as should "start ()" in your example above), we could see right away that it ought to have parentheses after it. As it is, I don't know if getStepWaitTimeNext is a function or a variable that ought to be a float, but I'm guessing that's what the problem is.
You guys are right, i forgot the () after getStepWaitTimeNext.. sheesh. Sorry about the stupid question :/
Everyone does it sometimes, and it's a difficult error message to figure out if you don't realize that "callable" essentially means "function" (for certain definitions of "function"). :)
Your answer
Follow this Question
Related Questions
Convert Text to float 3 Answers
Convert a char to int / float 2 Answers
Turn float to int 2 Answers
Possible to convert a Float into an Int? 3 Answers