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

The commads here only work every second time.

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
Basically every other command is ignored. I have to write it twice for it to work.


JASS:
library StringLib

    struct Words
        string array word[120]
        
        static method create takes string s returns Words
            local thistype this = .allocate()
            local integer i = 0
            local integer j = 0
            local integer sLength = StringLength(s)
            local string char = ""
            set sLength = StringLength(s) 
            loop
                exitwhen i > sLength
                set char = SubString(s, i, i + 1)
                if char != " "  then 
                    set word[j] = word[j] + char
                else
                    set j = j + 1
                endif
                set i = i + 1
            endloop
            return this
        endmethod
    endstruct
endlibrary

    private function Main takes nothing returns nothing 
        local trigger t
        local integer i
        set chat = GetEventPlayerChatString()
        set w = Words.create(chat)                                // This is probably the reason                      
        if not (SubString(chat, 0, 1) == "-") then
            return 
        endif 
        set i = StringHash(w.word[0])
        if HaveSavedHandle(hash, i, 0) then
            set t = LoadTriggerHandle(hash,  i, 0)
        else
            return
        endif
        if TriggerEvaluate(t) then
            call TriggerExecute(t)          // Combined with this
        endif
        call w.destroy()                    // and this.
        set t = null
    endfunction

Here is an example of a executed trigger loaded from the hash.

JASS:
    private function SetBoard takes nothing returns nothing
        local string s = SubString(chat, 7, 8)
        local integer i = S2I(w.word[1])
        local integer pid = GetPlayerId(GetTriggerPlayer())
        if s == "0" then
            call msgBoard[pid].addDisplacement(-msgBoard[pid].getDisplacement())
            call msgBoard[pid].update()
        else
            call msgBoard[pid].addDisplacement(i)
            call msgBoard[pid].update()
        endif   
    endfunction
 
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
Where is the main function called from?I personally don't see any problem with it maybe you want to make sure main is running by putting some messages in it.
 
Status
Not open for further replies.
Top