| 09-02-2006, 10:27 AM | #1 |
JASS:globals integer array udg_LH_SDARS endglobals function Set_SDARS takes integer ID,integer OffSet,integer Value returns nothing local integer RawID = ID local integer RawSet = OffSet local integer RawValue = Value if RawID > 511 then set RawID = 511 endif if RawID < 0 then set RawID = 0 endif if RawSet > 15 then set RawSet = 15 endif if RawSet < 0 then set RawSet = 0 endif set udg_LH_SDARS[RawID+512*RawSet] = Value endfunction function SDARS takes integer ID, string Data returns boolean local integer Set = 0 local integer IsInt = 0 local string Temp = "" local string Check = "" local boolean IsTrue = false local integer Slot = 0 local integer Last = 1 if SubString(Data,0,1) != "$" then return false endif loop set IsTrue = false set Set = Set+1 set Temp = SubString(Data,Set,Set+1) set IsInt = S2I(Temp) set Check = I2S(IsInt) if Temp == Check then set IsTrue = true endif if Temp == ":" then set IsTrue = true call Set_SDARS(ID,Slot,S2I(SubString(Data,Last,Set))) set Last = Set + 1 set Slot = Slot + 1 endif exitwhen IsTrue == false endloop call Set_SDARS(ID,Slot,S2I(SubString(Data,Last,Set))) return true endfunction function GetSDARS takes integer ID, integer OffSet returns integer return udg_LH_SDARS[ID+512*OffSet] endfunction This is simple parser for integers. JASS:call SDARS(66,"$20:99:129:11") call GetSDARS(66,0) == 20 call GetSDARS(66,1) == 99 call GetSDARS(66,2) == 129 call GetSDARS(66,3) == 11 This using single array and allow 512 data sets for 16 values. |
| 09-02-2006, 03:59 PM | #2 |
That's a very static system, and if you do not need always 16 value slots, this system is actually a waste of space. On the other hand, it would come in handy for some special things that need alweays the same amount of space. the string add is not that good, as rawcode add via the strings is, as far as I can see, impossible. I personally prefer dynamical arrays. |
| 09-02-2006, 04:34 PM | #3 |
This is for data storage for spells.... But you can cache game data by enering new string. You have spell with ID=6 and 100 damage per level. Make some trigger and change spells damage ingame. This is FOR DEBUG ONLY. if you balansing spells or other stuff, you can easy change its data onfly with out editing the map. 16 values is enoth for ANY SPELL. I done it after reading JESP standart. |
| 09-04-2006, 11:24 AM | #4 |
DioD my USP is better... but it's a question of time =) http://xgm.ru/forum/attachment.php?attachmentid=8756 PS to use cache for parsers like this is better... |
| 09-04-2006, 11:52 AM | #5 |
This parser for chat string, it do not cause lag on its call and do not use returnbug |
