Is there a Mid function ?

Status
Not open for further replies.

kram337

Member
Joined
Aug 10, 2006
Messages
155
Reaction score
0
Points
16
Hey again,

On my HUD I have a list of near by npc and pc's along with distance. My issue with it is that distance comes in with 2 decimal places as an integer. I want to clean up the view a bit and get it to just be the whole number.

Is there a MID(string, start, length) type function? (thats from VB and other languages) or can I simply change the distance variable to a different type and it'll drop the extra numbers?

Thanks,
~Kram
 
kram337 said:
Hey again,

On my HUD I have a list of near by npc and pc's along with distance. My issue with it is that distance comes in with 2 decimal places as an integer. I want to clean up the view a bit and get it to just be the whole number.

Is there a MID(string, start, length) type function? (thats from VB and other languages) or can I simply change the distance variable to a different type and it'll drop the extra numbers?

Thanks,
~Kram


http://www.macroquest2.com/wiki/index.php/DataType:string

Look at the examples there. Yes Mid does exist, as does Left and Right, just like in most programming languages.

Code:
/declare TestString abcdebc
/echo ${TestString.Find[bc]}          Will return 2
/echo ${TestString.Left[2]}           Will return "ab"
/echo ${TestString.Left[-2]}          Will return "abcde"
/echo ${TestString.Mid[2,3]}          Will return "bcd"
/echo ${TestString.Right[2]}          Will return "bc"
/echo ${TestString.Right[-2]}         Will return "cdebc"
 
Excellent, that does the job. Thanks for the help again.

~Kram
 
I'm still having trouble. As a noob it's to be expected. But heres my line:

${If[${NearestSpawn[2,pc].Name.NotEqual["NULL"]},${NearestSpawn[2,pc].Distance},]}

The line posted above works just fine, it prints the distance as a number with 2 decimal places. I've tried to add in there in a few places .Left[-3] which should remove period and both decimals.

But alas, it just tells me there is no such float member "Left"

Is it even possible to use Left in this line? or am I missing the point. Thinking about it, Left seems to be a function for a string, where I'm trying to use it on a numerical variable. If that makes any sense.

~Kram
 
${If[${NearestSpawn[2,pc].Name.NotEqual["NULL"]},${Int[${NearestSpawn[2,pc].Distance}]},]}

May do the job your wanting
 
I had a feeling I could change the type to drop the decimals. I just wasn't sure how heh.

thanks,
~Kram
 
Status
Not open for further replies.