• 🏆 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!

Txt Trigger

Status
Not open for further replies.
Level 8
Joined
Feb 20, 2020
Messages
200
Hello guys,
i just need when the player type -save from my save system, that generates a TXT file in the war3 directory with the code, i tried some of the methods here in hive but doesnot work because the code have collours so it save also the collour code and doesnot show the code.
someone could please help me??
i'm using this save load:

  • SaveLoad Initialization All
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet MaxLoads[1] = 0
      • Set VariableSet MaxLoads[2] = 0
      • Set VariableSet MaxLoads[3] = 0
      • Set VariableSet MaxLoads[4] = 0
      • Set VariableSet MaxLoads[5] = 0
      • Set VariableSet MaxLoads[6] = 0
      • Set VariableSet RegioPlayer[1] = Player 1 <gen>
      • Set VariableSet RegioPlayer[2] = Player 2 <gen>
      • Set VariableSet RegioPlayer[3] = Player 3 <gen>
      • Set VariableSet RegioPlayer[4] = Player 4 <gen>
      • Set VariableSet RegioPlayer[5] = Player 5 <gen>
      • Set VariableSet RegioPlayer[6] = Player 6 <gen>
      • -------- List of Heroes --------
      • Set VariableSet SaveLoad_Heroes[1] = Trainer
      • Set VariableSet SaveLoad_Heroes[2] = Trainer Female
      • Set VariableSet SaveLoad_Heroes[3] = |cff0000ffAquatic|r Laqua
      • Set VariableSet SaveLoad_Heroes[4] = |cff0000ffAquatic|r Laquid
      • Set VariableSet SaveLoad_Heroes[5] = |cff0000ffAquatic|r Lydro
      • Set VariableSet SaveLoad_Heroes[6] = |cff0000ffAquatic|r / |cff008000Nature|r Lydreef
      • Set VariableSet SaveLoad_Heroes[7] = |cff0000ffAquatic|r Zeanus
      • Set VariableSet SaveLoad_Heroes[8] = |cff0000ffAquatic|r / |cff008000Nature|r Coreal
      • Set VariableSet SaveLoad_Heroes[9] = |cff008000Nature|r Trent
      • Set VariableSet SaveLoad_Heroes[10] = |cff008000Nature|r Trentop
      • Set VariableSet SaveLoad_Heroes[11] = |cff008000Nature|r Trentus
      • Set VariableSet SaveLoad_Heroes[12] = |cff008000Nature|r Lorvi
      • Set VariableSet SaveLoad_Heroes[13] = |cff008000Nature|r Lurvin
      • Set VariableSet SaveLoad_Heroes[14] = |cff008000Nature|r Capod
      • Set VariableSet SaveLoad_Heroes[15] = |cff008000Nature|r Crocun
      • Set VariableSet SaveLoad_Heroes[16] = |cff008000Nature|r / |cff00ffffAir|r Wespah
      • Set VariableSet SaveLoad_Heroes[17] = |cff008000Nature|r / |cff00ffffAir|r Moonfree
      • Set VariableSet SaveLoad_Heroes[18] = |cff0000ffAquatic|r Cruby
      • Set VariableSet SaveLoad_Heroes[19] = |cff0000ffAquatic|r Crabbo
      • Set VariableSet SaveLoad_Heroes[20] = |cff0000ffAquatic|r Kinrub
      • -------- Number of Heroes --------
      • Set VariableSet SaveLoad_Heroes_LastIndex = 20
      • -------- List of Items --------
      • Set VariableSet SaveLoad_Items[1] = Catchball
      • Set VariableSet SaveLoad_Items[2] = Great Catchball
      • Set VariableSet SaveLoad_Items[3] = Ultra Catchball
      • Set VariableSet SaveLoad_Items[4] = Magic Key Chain
      • Set VariableSet SaveLoad_Items[5] = Kelen's Dagger of Escape
      • Set VariableSet SaveLoad_Items[6] = Rusty Mining Pick
      • -------- Number of Items --------
      • Set VariableSet SaveLoad_Items_LastIndex = 6
      • -------- List of Abilities --------
      • -------- Number of Abilities --------
      • Set VariableSet SaveLoad_Abilities_LastIndex = 4
      • -------- These three lines may be changed if needed --------
      • Set VariableSet SaveLoad_Alphabet = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&
      • Set VariableSet SaveLoad_CaseSensitive = True
      • Set VariableSet SaveLoad_UsePlayername = True
      • -------- Required: false --------
      • Set VariableSet SaveLoad_Initialized = False
      • -------- Leave as is. Used to autocreate variables when copy & pasting to a new map --------
      • Set VariableSet Code = AceHart
      • Set VariableSet Save[1] = 0
      • Set VariableSet SaveCount = 1
      • Set VariableSet Validate = False
      • Set VariableSet SaveLoad_Compress[1] = 0
      • Set VariableSet SaveLoad_Uncompress[1] = 0

  • SaveLoad Save All
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
      • Player - Player 2 (Blue) types a chat message containing -save as An exact match
      • Player - Player 3 (Teal) types a chat message containing -save as An exact match
      • Player - Player 4 (Purple) types a chat message containing -save as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -save as An exact match
      • Player - Player 6 (Orange) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • -------- Prepare the save array with this player's Hero --------
      • Set VariableSet SaveCount = 0
      • -------- Player's Gold --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet Save[SaveCount] = ((Triggering player) Current gold)
      • -------- Take all Heroes --------
      • Set VariableSet UnitGroup = (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).)
      • Set VariableSet SaveCount = (SaveCount + 1)
      • Set VariableSet Save[SaveCount] = (Number of units in UnitGroup)
      • Unit Group - Pick every unit in UnitGroup and do (Actions)
        • Loop - Actions
          • -------- Save the Hero --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet TempUnit = (Picked unit)
          • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Unit2Integer( udg_TempUnit )
          • -------- Hero Experience --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Hero experience of (Picked unit))
          • -------- Hero Position X --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Integer((X of (Position of (Picked unit)))))
          • -------- Hero Position Y --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Integer((Y of (Position of (Picked unit)))))
          • -------- How many items does he carry --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Set VariableSet Save[SaveCount] = (Number of items carried by (Picked unit))
          • -------- Add all items --------
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Item carried by (Picked unit) in slot (Integer A)) is owned) Equal to True
                • Then - Actions
                  • -------- The actual item --------
                  • Set VariableSet SaveCount = (SaveCount + 1)
                  • Set VariableSet TempItem = (Item carried by (Picked unit) in slot (Integer A))
                  • Custom script: set udg_Save[udg_SaveCount] = SaveLoad_Item2Integer( udg_TempItem )
                  • -------- The number of charges it has --------
                  • Set VariableSet SaveCount = (SaveCount + 1)
                  • Set VariableSet Save[SaveCount] = (Charges remaining in (Item carried by (Picked unit) in slot (Integer A)))
                • Else - Actions
      • -------- Turn values into code --------
      • Custom script: set udg_Code = SaveLoad_Encode()
      • Set VariableSet newCode = Code
      • Custom script: call CreateTextFile(udg_newCode)
      • -------- Show code to player --------
      • Quest - Display to (Player group((Triggering player))) the Secret message: Your code:
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
  • SaveLoad Load All
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
      • Player - Player 2 (Blue) types a chat message containing -load as A substring
      • Player - Player 3 (Teal) types a chat message containing -load as A substring
      • Player - Player 4 (Purple) types a chat message containing -load as A substring
      • Player - Player 5 (Yellow) types a chat message containing -load as A substring
      • Player - Player 6 (Orange) types a chat message containing -load as A substring
    • Conditions
      • MaxLoads[(Player number of (Triggering player))] Less than or equal to 3
      • (Substring((Entered chat string), 1, 6)) Equal to (Matched chat string)
      • (Length of (Entered chat string)) Greater than 6
    • Actions
      • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = 0
      • Set VariableSet MonstersCountforPlayer[(Team number of (Triggering player))] = 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MaxLoads[(Player number of (Triggering player))] Greater than 3
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) the text: You tryed more than...
          • Skip remaining actions
        • Else - Actions
      • Set VariableSet MaxLoads[(Player number of (Triggering player))] = (MaxLoads[(Player number of (Triggering player))] + 1)
      • -------- Try to decode what was typed --------
      • Set VariableSet Code = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
      • Custom script: set udg_Validate = SaveLoad_Decode( udg_Code )
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Validate Equal to False
        • Then - Actions
          • -------- Invalid code --------
          • Game - Display to (Player group((Triggering player))) the text: wrong code..
          • Skip remaining actions
        • Else - Actions
      • -------- It worked, let's do something with it --------
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Set VariableSet SaveCount = 1
      • -------- Restore Gold --------
      • Player - Set (Triggering player).Current gold to Save[SaveCount]
      • -------- For "number of Heroes", do --------
      • Set VariableSet SaveCount = (SaveCount + 1)
      • For each (Integer B) from 1 to Save[SaveCount], do (Actions)
        • Loop - Actions
          • -------- Restore Hero --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Custom script: set udg_TempUnitType = SaveLoad_Integer2Unit(udg_Save[udg_SaveCount])
          • Unit - Create 1 TempUnitType for (Triggering player) at (Random point in RegioPlayer[(Player number of (Triggering player))]) facing Default building facing degrees
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Unit-type of (Last created unit)) Not equal to Trainer) or ((Unit-type of (Last created unit)) Not equal to Trainer Female)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering player) Equal to Player 1 (Red)
                • Then - Actions
                  • Set VariableSet MonsterListPlayer1[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                  • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Triggering player) Equal to Player 2 (Blue)
                    • Then - Actions
                      • Set VariableSet MonsterListPlayer2[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                      • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Triggering player) Equal to Player 3 (Teal)
                        • Then - Actions
                          • Set VariableSet MonsterListPlayer3[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                          • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Triggering player) Equal to Player 4 (Purple)
                            • Then - Actions
                              • Set VariableSet MonsterListPlayer4[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                              • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Triggering player) Equal to Player 5 (Yellow)
                                • Then - Actions
                                  • Set VariableSet MonsterListPlayer5[CounterMonsterList[(Player number of (Triggering player))]] = (Last created unit)
                                  • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • (Triggering player) Equal to Player 6 (Orange)
                                    • Then - Actions
                                      • Set VariableSet MonsterListPlayer6[(Player number of (Triggering player))] = (Last created unit)
                                      • Set VariableSet CounterMonsterList[(Player number of (Triggering player))] = (CounterMonsterList[(Player number of (Triggering player))] + 1)
                                    • Else - Actions
              • Set VariableSet MonstersCountforPlayer[(Team number of (Triggering player))] = (MonstersCountforPlayer[(Team number of (Triggering player))] + 1)
            • Else - Actions
          • -------- Set Experience --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • Hero - Set (Last created unit) experience to Save[SaveCount], Hide level-up graphics
          • -------- Move to saved position --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnitType Equal to Trainer) or (TempUnitType Equal to Trainer Female)
            • Then - Actions
              • Unit - Move (Last created unit) instantly to (Point((Real(Save[SaveCount])), (Real(Save[(SaveCount + 1)]))))
              • Camera - Pan camera for (Owner of (Last created unit)) to (Point((Real(Save[SaveCount])), (Real(Save[(SaveCount + 1)])))) over 1.00 seconds
            • Else - Actions
          • Set VariableSet SaveCount = (SaveCount + 1)
          • -------- Recreate all items --------
          • Set VariableSet SaveCount = (SaveCount + 1)
          • For each (Integer A) from 1 to Save[SaveCount], do (Actions)
            • Loop - Actions
              • -------- The actual item --------
              • Set VariableSet SaveCount = (SaveCount + 1)
              • Custom script: set udg_TempItemType = SaveLoad_Integer2Item(udg_Save[udg_SaveCount])
              • Hero - Create TempItemType and give it to (Last created unit)
              • -------- Number of charges --------
              • Set VariableSet SaveCount = (SaveCount + 1)
              • Item - Set charges remaining in (Last created item) to Save[SaveCount]
 
Level 28
Joined
Feb 18, 2014
Messages
3,576
I suppose you're using AceHart's Save/Load system, right? This is why it creates colored strings for numbers.
JASS:
function SaveLoad_Color takes string s returns string
    local integer i = StringLength(s)
    local string c
    local string r = ""

    loop
        set i = i - 1
        set c = SubString(s,i,i + 1)
        if c == "0" or c == "1" or c == "2" or c == "3" or c == "4" or c == "5" or c == "6" or c == "7" or c == "8" or c == "9" then
            set r = "|cffffcc00" + c + "|r" + r
        elseif c == "-" then
            set r = "|cffdddddd-|r" + r
        else
            set r = c + r
        endif
        exitwhen i <= 0
    endloop
    return r
endfunction
You can fix that by going to the Map Header, scroll down to the buttom, and change this :
JASS:
function SaveLoad_Encode takes nothing returns string
    if udg_SaveLoad_CaseSensitive == false then
        set udg_SaveLoad_Alphabet = StringCase(udg_SaveLoad_Alphabet,true)
    endif
    return SaveLoad_Color(SaveLoad_EncodeValues())
endfunction
to this :
JASS:
function SaveLoad_Encode takes nothing returns string
    if udg_SaveLoad_CaseSensitive == false then
        set udg_SaveLoad_Alphabet = StringCase(udg_SaveLoad_Alphabet,true)
    endif
    return SaveLoad_EncodeValues()
endfunction
 
Level 6
Joined
Mar 7, 2011
Messages
124
im not familiar with that system, but have you tried the udg_SaveLoad_CaseSensitive configuration setting? it looks like the save code will use an all upper-case alphabet when udg_SaveLoad_CaseSensitive = false

or do you mean you want it to colorize / highlight lower case vs upper case letters?

going further out on a limb, it sortof sounds like you're trying to do two things - output a plain-text save code to file and a colorized save code to the UI. that'd be a good feature, but you might want two functions to do it. essentially the original + Warseeker's edit

JASS:
function SaveLoad_EncodePlain takes nothing returns string
    if udg_SaveLoad_CaseSensitive == false then
        set udg_SaveLoad_Alphabet = StringCase(udg_SaveLoad_Alphabet,true)
    endif
    return SaveLoad_EncodeValues()
endfunction

function SaveLoad_EncodeColor takes nothing returns string
    return SaveLoad_Color(SaveLoad_EncodePlain())
endfunction

youd call SaveLoad_EncodePlain to save to file and SaveLoad_EncodeColor to output to UI
 
Last edited:
Status
Not open for further replies.
Top