• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Save/Load Text File Data

Status
Not open for further replies.
Level 9
Joined
Dec 16, 2017
Messages
343
Hello guys, i decided to stick with this save/load system, Help

I want to add more data in the text file, and here is what i did so far, but it seems like i don't get it into how to transform agi/str/int/gold/lumber into data properly(i am newbie in jass, i just make the gui variable and transform it into custom text and put it to the header, and with what i tried for above mentioned stats i get this error)
Screenshot 2022-03-22 115231.png



JASS:
function CreateTextFile takes nothing returns nothing
    local integer p = GetPlayerId(GetTriggerPlayer())+1
    local integer heroLevel = GetHeroLevel(udg_Hero[p])
    local integer heroGold = GetPlayerState(GetOwningPlayer(udg_Hero[p]), PLAYER_STATE_RESOURCE_GOLD)
    local string mapName = udg_Map_Creator_Name
    local string heroName = GetUnitName(udg_Hero[p])
    local string heroProperName = GetHeroProperName(udg_Hero[p])
    local string playerName = GetPlayerName(GetTriggerPlayer())
    local string HeroItem1 = GetItemName(UnitItemInSlotBJ(udg_Hero[p], 1))
    local string HeroItem2 = GetItemName(UnitItemInSlotBJ(udg_Hero[p], 2))    
    local string HeroItem3 = GetItemName(UnitItemInSlotBJ(udg_Hero[p], 3))
    local string HeroItem4 = GetItemName(UnitItemInSlotBJ(udg_Hero[p], 4))    
    local string HeroItem5 = GetItemName(UnitItemInSlotBJ(udg_Hero[p], 5))    
    local string HeroItem6 = GetItemName(UnitItemInSlotBJ(udg_Hero[p], 6))
    
    call PreloadGenClear()
    call PreloadGenStart()
    call Preload("--------------------------Save Code--------------------------")
    call Preload("-load" + udg_NPS_Password)
    call Preload("--------------------------Data Saved--------------------------")
    call Preload("Hero Class: " + heroName)
    call Preload("Hero Name: " + heroProperName)
    call Preload("Level: " + I2S(heroLevel))
    call Preload("Player Name: " + playerName)
    call Preload("Gold: " + heroGold)
    call Preload("Lumber: ")
    call Preload("Strength: ")
    call Preload("Agility: ")
    call Preload("Intelligence: ")
    call Preload("Hero Item Slot 1: " + HeroItem1)
    call Preload("Hero Item Slot 2: " + HeroItem2)
    call Preload("Hero Item Slot 3: " + HeroItem3)
    call Preload("Hero Item Slot 4: " + HeroItem4)
    call Preload("Hero Item Slot 5: " + HeroItem5)
    call Preload("Hero Item Slot 6: " + HeroItem6)
    call Preload("Bag Item Slot 1: ")
    call Preload("Bag Item Slot 2: ")
    call Preload("Bag Item Slot 3: ")
    call Preload("Bag Item Slot 4: ")
    call Preload("Bag Item Slot 5: ")
    call Preload("Bag Item Slot 6: ")
    
    
    call PreloadGenEnd(mapName + "\\v0.2\\" + playerName + " - " + heroName + " - " + I2S(heroLevel) + ".txt")
endfunction
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
As you allready do with heroLevel you also have to convert your heroGold to a string. Just use I2S like you do with heroLevel.
 
Level 9
Joined
Dec 16, 2017
Messages
343
Oh, yeah, makes sense now, the I2S is already a converted string in the code and it's used to all data that is integer based and i want to transform it..seems nice.
How could i differentiate the courier from hero in the save? The courier is a stash that you buy once and i want to save the item for it aswell.
Shall i base the stash of a structure or leave it as unit that can't move?
 
Status
Not open for further replies.
Top