var/pop=text2num(copytext(kk,findtext(kk,"*")))
src.lp=antigo*pop
src.lp is becoming 0 when I type *2 or *40 or anything.
var/pop=text2num(copytext(kk,findtext(kk,"*"))) src.lp is becoming 0 when I type *2 or *40 or anything. |
Feb 5 2012, 5:31 pm (Edited on Feb 5 2012, 5:36 pm)
|
|
What is copytext() for? It's not needed, because findtext() returns the number for you.
|
Well derp. Any number multiplied by zero is equal to zero. You might be strafing copy text too early so maybe something like this could work:
var/pop=text2num(copytext(kk,findtext(kk,"*")+1)) |
In response to Neimo
|
|
Neimo wrote:
What is copytext() for? It's not needed, because findtext() returns the number for you. var/pop = text2num(findtext(kk, "*")) If that is the case then text2num isn't necessary either, it might actually cause an error. |
In response to ExPixel
|
|
ExPixel wrote:
Neimo wrote: var/pop = text2num(findtext(kk, "*")) If that is the case then text2num isn't necessary either, it might actually cause an error. Didn't return any errors for me, but you're more than right. |
Without any context, it's kind of hard to tell what you're trying to do. It looks kinda like you want to parse a text string for a multiplication operator and operand, and apply it to an "old" ("antigo") value.
If so, the issue is your copytext is including the '*' character, which is causing text2num() to fail. So as ExPixel originally suggested, you just need to add 1 to your starting index: var/pop=text2num(copytext(kk,findtext(kk,"*")+1)) |