| 10-23-2003, 02:33 PM | #1 |
Oke people, how do I covert a hexidecimal number like 02dc into a regular decimal number through the editor? |
| 10-23-2003, 02:34 PM | #2 |
You could use conbine substrings and mathmatical equations. |
| 10-23-2003, 02:35 PM | #3 |
Never saw a function like that actually, why do you want to do that? Also i'm sure you can make your own function to convert hexdecimal numbers to decimal numbers if you know how to convert it. (I don't know how otherwise i might have been able to make a function for you :P) |
| 10-23-2003, 02:45 PM | #4 |
I'm making a map that simulates first person view. It's pretty far in development, the camera follows the unit correctly except when the unit's Z axis (height) changes. Because of this, I'm forced to make the map flat, which sucks. In order to fix this problem I need to find the Z axis of the units being followed. Ari has a nice method to find the Z axis of a unit, but I need to be able to convert hexidecimal numbers into decimal number in order to use it. Therefor, please, tell me how to do this!! |
| 10-23-2003, 02:52 PM | #5 |
Because it needs to be done ingame, there is no ingame calculator that supports hex and decimal. |
| 10-23-2003, 03:10 PM | #6 |
Okay try this JASS code (see 'Note' at the end of this post!): Code:
// Uses global declared string array: udg_HNums // You should execute this function on map initialization: [color=coral] function HInit takes nothing returns nothing set udg_HNums[0] = "0" set udg_HNums[1] = "1" set udg_HNums[2] = "2" [/color] // 3,4,5,6,7,8 here [color=coral] set udg_HNums[9] = "9" set udg_HNums[10] = "A" set udg_HNums[11] = "B" set udg_HNums[12] = "C" set udg_HNums[13] = "D" set udg_HNums[14] = "E" set udg_HNums[15] = "F" endfunction [/color] [color=coral] function HSymbol takes string Str returns integer local integer i = 0 loop exitwhen (udg_HNums[i] == null) or (udg_HNums[i] == Str) set i = i + 1 endloop if udg_HNums[i] == null then return -1 else return i endif endfunction function HexToDec takes string Hex returns integer local integer i = 0 local integer Sum = 0 local integer LocalIndex = 0 local integer Size = 0 loop exitwhen SubString(Size,Size+1) == "" set Size = Size + 1 endloop loop set LocalIndex = HSymbol(SubString(Str,i,i+1)) exitwhen LocalIndex == -1 set Sum = Sum + LocalIndex * Power(16,Size - i - 1) set i = i + 1 endloop if SubString(Str, i, i+1) != "" then return 0 else return Sum endif endfunction [/color] Just call HexToDec("ABCD0") to get its decimal integer value. NOTE! I wrote this 'from scratch' without editor so this function may not work at all. I'm not sure about function name - Power(x,y) - please specify its name! I'll try it on real map then fix bugs if I find them. Don't even try to convert hex numbers more than FFFFFFFF!!! No integer overflow check exists! And negative numbers aren't supported! If you need this feature, send me PM. |
| 10-23-2003, 04:09 PM | #7 |
I don't know anything about jass editing so that do me any good but I already made a converter myself. Implemented in a map that outputs the height of the tile closest to a curtain footman. I've attached the map. I'll post the next version of my map as soon as it's finished. It'll include a working first person view:) After that, if I'm not too lazy, I'll make a guide on how to implement my first person view triggers for you own map. |
| 10-23-2003, 05:48 PM | #8 |
Hmm I got stuck, again! I posted the question in http://www.wc3campaigns.com/forums/s...881#post306881 |
| 10-23-2003, 08:43 PM | #9 |
So what is my script for? I will never post scripts anymore if I'm not sure that thread author REALLY needs it! |
