• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Saving/Loading ability in/from hashtable

Status
Not open for further replies.
Level 12
Joined
Mar 24, 2011
Messages
1,082
So I need to save and load abilities in hashtable. I found a few threads about this matter but I somehow can't figure the custom scripts.
For saving
  • Skills Copy 2
    • Events
      • Unit - A unit Learns a skill
    • Conditions
    • Actions
      • Set TempInteger = (Player number of (Triggering player))
      • Set TempInteger2 = SkillPlInt[TempInteger]
      • Custom script: set udg_TempSkill = GetLearnedSkillBJ()
      • Custom script: set udg_TempInteger3 = AbilityID(GetLearnedSkillBJ()) //the problem is in this line. It looks like this after numerous changes.
      • For each (Integer Temp_integer) from 1 to TempInteger2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load TempInteger of Temp_integer from SkillsHash) Equal to TempInteger3
            • Then - Actions
              • Skip remaining actions
            • Else - Actions
      • Set SkillPlInt[TempInteger] = (SkillPlInt[TempInteger] + 1)
      • Hashtable - Save TempInteger3 as TempInteger of TempInteger2 in SkillsHash
      • Game - Display to (All players) the text: (Name of TempSkill)
And what shouls I do for loading ?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
JASS:
constant native AbilityId takes string abilityIdString returns integer

function GetLearnedSkillBJ takes nothing returns integer
    return GetLearnedSkill()
endfunction

you are passing integer, you dont need to call that function
actually, what should tempinteger3 represent?
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
you want to get it in form of a000 or 176455724(etc)?
Mmm do ppl normaly use not the a000 ? I mean... whats the difference except the first is 4 dig... characters *?* and can be taken from world edit ?

Edit//You see I don't know which I need but I know that ability can't be saved/loaded directly into hashtable so I try as integer as some ppl said in some threads I found around.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
ascii values are wrapped in ' ' so its like 'Hpal' for paladin etc
also keep in mind you can only do 1 character or 4, using other numbers will give you error
I think to save ability to hashtable, if you want to read that ability you need to use custom script for that
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here's an example:
  • Untitled Trigger 081
    • Events
      • Unit - A unit Learns a skill
    • Conditions
    • Actions
      • Custom script: set udg_i1 = GetLearnedSkill()
      • Custom script: set udg_ID = GetHandleId(GetTriggerUnit())
      • Hashtable - Save i1 as 0 of ID in hash
      • Wait 0.00 seconds
      • Set i2 = (Load 0 of ID from hash)
      • Custom script: set udg_abil = udg_i2
      • Game - Display to Player Group - Player 1 (Red) for 2.00 seconds the text: (String((Level of abil for (Triggering unit))))
 
Status
Not open for further replies.
Top