HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

About S2I

07-15-2006, 12:50 PM#1
Mezzer
Which integer does this return exactly? I know it'll spit out something seemingly unrelated, but I'd like to know what
07-15-2006, 02:11 PM#2
shadow1500
S2I will convert a integer written in string form to an integer. Like S2I("123") will become 123.
07-15-2006, 02:58 PM#3
Mezzer
Obviously, but "hat" would return what?
07-15-2006, 02:59 PM#4
iNfraNe
0
07-15-2006, 03:11 PM#5
Mezzer
So it doesn't do anything intelligent with strings that contain anything other than numbers? Is there a built in function that does maybe?
07-15-2006, 03:54 PM#6
Hemlock
you can fill integers with strings, would be the first thing that pops up in my mind
07-15-2006, 04:48 PM#7
BertTheJasser
To make something usefull out of "hat" you would have to use return bug exploiters (this is a 100% sure method, as iI do it myself - you can it even convert vice versa with return bug and get the intial string recreated).
07-15-2006, 04:49 PM#8
Vexorian
That's not 100% safe at all
07-15-2006, 04:52 PM#9
Mezzer
Exactly, that's why I asked if anyone knew precisely what the function did, since the return bug thing ain't working right
07-15-2006, 04:54 PM#10
Vexorian
you can just hash the string to get a number in a range that is different for different strings
07-15-2006, 05:02 PM#11
Mezzer
That's exactly what I need, except I have no idea how to do it
07-15-2006, 05:02 PM#12
BertTheJasser
Oh! I use it in this way and till now it has done its job perfectly
Collapse JASS:
function i2s takes integer i returns string
return i
return ""
endfunction

function s2i takes string s returns integer
return s
return 0
endfunction

function Msg takes string s returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,s)
endfunction


function ...
local string blah=i2s(bj_forLoopAIndex)
call Msg(blah)
..
endfunction

function ...
set bj_forLoopAIndex=i2s("halligalli is a great game!")
call ExecuteFunc("the func above")
As said, it works

Btw. did you look at the extended damage options?
07-15-2006, 05:02 PM#13
Vexorian
Oh my god, using return bug on strings seems to work now, even i2s(0) doesn't crash anymore, blizzard might have updated this

(I tested it myself before reading to bert's post)

A while ago I was using it since storing integers in gamecache is faster than storing strings. But it was crashing all the time.

Edit: It still crashes when using an integer that is not a string. Better try to reproduce the index clearing bug
07-15-2006, 05:06 PM#14
BertTheJasser
As i've said. It works PERFECTLY!
07-15-2006, 05:07 PM#15
Vexorian
The other time strings were getting lost after a while and it crashed. I think I even have a post about that in wc3jass.com but that was a while ago