Starting to create games again, stumble at first hurdle, Could find not function 'ToInt(Int32)'

After a LONG break I've decided to get back into game making, Starting simple with stuff...and yet, I stumble into a bug I can't figure out for the life of me what's wrong. It worked recently, then did something unrelated and seems to have messed it up somehow...

if (ToInt(player.Luck + player.Str + player.Agi+ player.Charm) >= 50) {
  msg ("No admission for those with a total score over 50")
}
else {
  MoveObject (player, The Main Hub)
}

I get a
Error running script: Error compiling expression 'ToInt(player.Luck + player.Str + player.Agi+ player.Charm) >= 50': FunctionCallElement: Could find not function 'ToInt(Int32)'

The oddest part though is this error only comes when the "Else" part of the script fires, when the stats are over 50 it checks and bars admission no problem.. I'd think the else would be the most simple possible part..


If I didn't know better...I'd think I somehow deleted a core library of some sort... but that seems unlikely

edit
Decided to do more testing, Have triggered on a turnscript to check if a player entered negative stats to try to game the system), I'm getting the same error

if (ToInt(player.Str)<0) {
  msg ("Strength to low, you dead")
}
else if (ToInt(player.Agi)<0) {
  msg ("Agility to low, you Dead")
}
else if (ToInt(player.Charm)<0) {
  msg ("Charm to low, you dead")
}
else if (ToInt(player.Luck)<0) {
  msg ("Luck to Low, you dead!")
}

It really looks like somehow I've lost the ToInt functionality as a core function


Could find not function 'ToInt(Int32)'

ToInt is a function which takes a string, and turns it into an int.

You're calling it on a variable which is already an int. So it tells you that there isn't a ToInt function that accepts an Int32 parameter. I assume these are things the player typed in, but you already used ToInt to convert them. If you hadn't, you wouldn't be able to add them together.

Most of the built in (hard coded) functions work like this - the function only accepts a particular type of parameter, and it will complain if you try to run it on something of a different type.

My suggestion is just to remove the ToInt, and just do:

if (player.Luck + player.Str + player.Agi + player.Charm >= 50) {

Thank you Mrangel, That worked....and I'm glad.

but the strange stuff in my mind is that is exactly what I had done before I looked up the ToInt, I was getting an error about not being able to use the function on a non integer.. I'm going to chalk this whole episode up to the slings and arrows of trying to fix a small problem and ending up making it worse.... I'm sure every coder gets that at some point in their career...


I accidentally broke it again, however I found out what the core of the problems, It only happened AFTER I set attributes ..thus when setting attributes from the generator I had to use convert to int, the programing I had used to let the player type in their attribute was overwriting the set Integer attribute I had established on the player object.

It just took a moment of logic to narrow down if the character creator was causing problems down the line


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums