• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Cannot convert boolean to code

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
        private static method saveWithLocal takes nothing returns boolean
        local player tplay = GetTriggerPlayer()
        local integer pnumb = GetPlayerId(tplay)
        local NumberStack stack = BigInt.create(encryptionKey)
        local string encrypted
        local integer i = 1
        local string s
        set SaveTriggers[pnumb] = CreateTrigger()
        set SaveDialog[pnumb] = DialogCreate()
        call TriggerAddAction(SaveTriggers[pnumb], function thistype.onSaveDialogClick)
        call SaveHeroLevel(udg_PlayerUnit[pnumb], stack)
        call SaveGold(stack, tplay)
        call SaveCustomInventory(stack, tplay)
        call SaveHero(stack, tplay)
        call DisplayTimedTextToPlayer(tplay,0,0,60,"Saving. . .")
        set encrypted=EncryptNumber(stack,      1000000,                                3,  pnumb,    "salt value",   .85)
        set encrypted=AddRepeatedString(encrypted,"-",4,0)
        set encrypted=ColorCodeString(encrypted, "40e0d0",  "ff69b4",    "00AA00",  "ffff00",                   0)
        call AddBoolean(101, true, tplay)
        call SaveData(BankId, tplay)
        call LoadData(BankId, tplay)
        if ReadBoolean(101, tplay) != true then
            call print("Your computer does not have localized storing enabled. Type '-write' and you will get further instructions to enable. Untill then, this code will overwrite your first slot")
            call AddString(i + 20, "Level " + I2S(GetHeroLevel(udg_PlayerUnit[pnumb])) + " " + GetUnitName(udg_PlayerUnit[pnumb]), tplay)
            call AddString(i, encrypted, tplay)
            call SaveData(BankId, tplay)
        else
            loop
                set s = ReadString(i + 20, tplay)
                if StringLength(s) < 5 then                                     
                    set SaveButtonArray[(i) + (pnumb * 22)] = DialogAddButton(SaveDialog[pnumb], "Empty Slot", i)                                  
                    call TriggerRegisterDialogButtonEvent(SaveTriggers[pnumb], SaveButtonArray[(i - 22) + (pnumb * 22)])
                    call print(s)
                else                                     
                    set SaveButtonArray[(i) + (pnumb * 22)] = DialogAddButton(SaveDialog[pnumb], s, i)               
                    call TriggerRegisterDialogButtonEvent(SaveTriggers[pnumb], SaveButtonArray[(i) + (pnumb * 22)])
                    call print(s)
                endif
                set i = i + 1
                exitwhen i == 11
            endloop
            set SaveButtonArray[(21) + (pnumb * 22)] = DialogAddButton(SaveDialog[pnumb], "Other Page", 21)               
            call TriggerRegisterDialogButtonEvent(SaveTriggers[pnumb], SaveButtonArray[(21) + (pnumb * 22)])
            set SaveButtonArray[(22) + (pnumb * 22)] = DialogAddButton(SaveDialog[pnumb], "Exit Dialog", 22)               
            call TriggerRegisterDialogButtonEvent(SaveTriggers[pnumb], SaveButtonArray[(22) + (pnumb * 22)])
            call DialogDisplay(tplay, SaveDialog[pnumb], true)
            set EncryptionString[pnumb] = encrypted
        endif
        call stack.destroy()
        set tplay = null
        
        return false
    endmethod

call GroupEnumUnitsInRangeOfLoc( returns it

Ive been toying with it for a wihle and i just cant get it to work >.<

e/ forgot the "function" -.- i replaced the code with something else. The action thistype.onSaveDialogClick doesnt play when the button is clicked? but t
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
JASS:
call GroupEnumUnitsInRangeOfLoc(g, l, radius,Filter( function thistype.Conditions))
Also, i don't remember how such methods are handled, but it would be better to place the method Conditions above, to avoid any unwanted TriggerEvaluate.
That's how jass work anyway, i mean you can't use a function if it's not already declared above.

Finally, there is no need of a location here, there are functions with coordinates X/Y instead.

EDIT : Well, in your edit you've completely changed the code, for your newest question we don't have all the related code.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
i forgot "Function" lol.

anyway, i changed the code because the problem was solved but the dialog button wasnt running so i decided to recycle threads

e/ what other code do you want? ill post the onSaveDialogClick

it doesnt print "Dialog Button Was Clicked!"

2e/ strange. It seems "other page" and "exit dialog" run the function, but they run "It was another button!" + "Data Saved!" over and over and over again.

JASS:
    private static method onSaveDialogClick takes nothing returns nothing
    local player tplay = GetTriggerPlayer()
    local integer pnumb = GetPlayerId(tplay)
    local integer i2 = 0
    local integer i = 10
    local string s
    call print("Dialog Button Was Clickded!")
    if GetClickedButton() == SaveButtonArray[21 + (22 * pnumb)] then
        call print("It was Switch Page!")
        call DialogClear(SaveDialog[pnumb])
            loop
                set s = ReadString(i + 20, tplay)
                if StringLength(s) < 5 then                                     
                    set SaveButtonArray[(i) + (pnumb * 22)] = DialogAddButton(SaveDialog[pnumb], "Empty Slot", i)                                  
                    call TriggerRegisterDialogButtonEvent(SaveTriggers[pnumb], SaveButtonArray[(i) + (pnumb * 22)])
                else                                     
                    set SaveButtonArray[(i) + (pnumb * 22)] = DialogAddButton(SaveDialog[pnumb], s, i)               
                    call TriggerRegisterDialogButtonEvent(SaveTriggers[pnumb], SaveButtonArray[(i) + (pnumb * 22)])
                endif
                set i = i + 1
                exitwhen i == 21
            endloop
    elseif GetClickedButton() == LoadButtonArray[22 + (22 * pnumb)] then
        call print("It was Exit!")
        call DialogDestroy(LoadDialog[pnumb])
    endif
        
        loop
            if GetClickedButton() == SaveButtonArray[i2 + (22 * pnumb)] then
                call print("It was another button!")
                call AddString(i2, EncryptionString[pnumb], tplay)
                call AddString(i2 + 20, "Level " + I2S(GetHeroLevel(udg_PlayerUnit[pnumb])) + " " + GetUnitName(udg_PlayerUnit[pnumb]), tplay)
                set i2 = 20
                call print("Data Saved!")
            endif
            set i2 = i + 1
            exitwhen i2 == 21
        endloop
        set tplay = null
    endmethod
 
Status
Not open for further replies.
Top