| 11-01-2005, 12:53 PM | #1 |
I am reading a map. And I find this funny function which work actually. Code:
function funny takes integer i, integer j returns string
local string s = I2S(i - j - 'O000') // its O zero zero zero
return s
endfunctionHowever, there may be some tricks that I missed since I've failed to try it myself. How does it work? |
| 11-02-2005, 09:43 AM | #2 |
Code:
takes integer i, integer j returns string
//This line is what defines what the function "takes", i and j are 2 integers passed throgh the function
//eg: funnyfunctionn(1, 2)
local string s = I2S(i - j - 'O000') // its O zero zero zero
//s is a local string variable. I2S converts and integer to a string, because doing something like this:
//local string s = i - j - 0000
//Wont work, because you are mixing 2 data types.
return s
//Return the variable so it may be used, eg:
//local string a = funnyfunction(3, 4)now, i dont really understand the point of this function, but thats what it doas... it takes 2 integers, and returns a string. |
| 11-03-2005, 01:47 PM | #3 |
JASS:function I2Sp takes integer i, integer iLen returns string local string s = I2S(i) loop exitwhen StringLength(s) >= iLen set s = "0" + s endloop return s endfunction function Checksum takes integer X1, integer X2, integer X3, integer Y1, integer X4, integer Y2, integer Z5 returns string local string s = I2Sp(X1 + (X2 - X3 - 'O000') + X4*X4 + RedDiv(Z5, 1000), 4) local integer i = IMinBJ(Y1, 3) set Y2 = Y2 + 1 loop exitwhen i == 3 set s = SubString(s, 1, 4) + SubString(s, 0, 1) set i = i + 1 endloop set i = S2I(s) if i > 5999 then return I2Sp(i - Y2*(1+ModuloInteger(Z5, 1000)), 4) else return I2Sp(i + Y2*(1+ModuloInteger(Z5, 1000)), 4) endif endfunction X2 = 2 X3 = 0 X4 = 2 Y1 = 2 Y2 = 2 Z5 = 17444 Checksum return = 4175 That's all. Nothing special, except the "integer + string" action. |
| 11-03-2005, 01:48 PM | #4 |
My question is : How do the war3 machine subtract string and integer ? Will it read them as hex and do it? or, how do it work with them? I can only imagine the adding up of string but not a subtraction... |
| 11-03-2005, 02:26 PM | #5 |
something between ' and ' isnt a string, but an integer, just look @ unit id's, those are integers 2 just check out what they are by displaying I2S('O000') |
| 11-03-2005, 03:11 PM | #6 |
ah! Then, I think its a handle. A unit type is called O000 |
| 11-04-2005, 08:20 AM | #7 |
ops finally I've found it out. THe machine just read 'O000' string into memory, and then do calculation as hex "4F30 3030" with other integer. argh... what a stupid...thing in ' ' aren't really a hex or string or handle. If you display it directly, system will hang once you click the map in creating room. If you display (o + ' '), it will become integer. If you treat it like string, it will become string...... |
