ID:254110
 
(See the best response by DarkCampainger.)
var/pop=text2num(copytext(kk,findtext(kk,"*")))
src.lp=antigo*pop


src.lp is becoming 0 when I type *2 or *40 or anything.
What is copytext() for? It's not needed, because findtext() returns the number for you.

var/pop = findtext(kk, "*")
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:
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.

Didn't return any errors for me, but you're more than right.
Best response
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))
src.lp=antigo*pop