Integer Problems

Vulcansurge

Ultra Cool Member
Reaction score
27
I just learnt JASS :)D part of the 'in' crowd now) and I've spent a few minutes working out how to write some script. Here is what I have:

Code:
// Change the variables in the starry box only.
function PlayerMsg takes player p, string s returns nothing
  call DisplayTextToPlayer(p,0,0,s)
endfunction

function Trig_UpgradeBasicCannonJASS_Actions takes nothing returns nothing
  local integer l = 0
  local unit u = GetManipulatingUnit()
  local item i = GetManipulatedItem()
  local player p = GetOwningPlayer(u)
  local item iu
//***************************************************************************
  local integer ut = 5   //Total upgrades
  local string array ul 
    set ul[1]="I00H"     //Item Rawcodes (use ctrl+D in unit editor)
    set ul[2]="I00D"
    set ul[3]="I00E"
    set ul[4]="I00F"
    set ul[5]="I00G"
//***************************************************************************  
  loop
  set l=l+1
  exitwhen l==5
  if (GetItemTypeId(i)==ul[I2S(l)]) then
    if (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)>=600) then
      call AdjustPlayerStateBJ(-600,GetOwningPlayer(GetManipulatingUnit()), PLAYER_STATE_RESOURCE_GOLD)
      call PlayerMsg(p,"|cFF0000FFNote:|r Your item is being upgraded")
      call UnitRemoveItemSwapped(i,u)
      call RemoveItem(i)
      call UnitAddItemByIdSwapped('I00C',u)
      set iu = GetLastCreatedItem()
      call TriggerSleepAction(10.00)
      call UnitRemoveItemSwapped(iu,u)
      call RemoveItem(iu)
      call UnitAddItemByIdSwapped(ul[I2S(l)],u) 
    else
      call PlayerMsg(p,"|cFF0000FFNote:|r You need more gold to upgrade this item")
    endif
  endif
  endloop 
endfunction

//===========================================================================
function InitTrig_UpgradeBasicCannonJASS takes nothing returns nothing
    set gg_trg_UpgradeBasicCannonJASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_UpgradeBasicCannonJASS, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddAction( gg_trg_UpgradeBasicCannonJASS, function Trig_UpgradeBasicCannonJASS_Actions )
endfunction
 
I

IKilledKEnny

Guest
What is the problem? I asssume the trigger is disabled? Also please on future posts delete those //**********... comments they make it harder to read.

Code:
local string array ul

just make it integer, and instead of "s use 's.

Code:
call AdjustPlayerStateBJ(-600,GetOwningPlayer(GetManipulatingUnit()), PLAYER_STATE_RESOURCE_GOLD)

Just use p instead of owning player.

Probably few more problems but I'm in a hurry.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
You cannot compare two variables with different primitive types. Try this instead. Ant there are a lot of fluff functions, which should be avoided.

Code:
// Change the variables in the starry box only.
function PlayerMsg takes player p, string s returns nothing
    call DisplayTextToPlayer(p,0,0,s)
endfunction

function Trig_UpgradeBasicCannonJASS_Actions takes nothing returns nothing
    local integer l = 0
    local unit u = GetManipulatingUnit()
    local item i = GetManipulatedItem()
    local player p = GetOwningPlayer(u)
    local item iu
    local integer ut = 5   //Total upgrades
[B]    local integer array ul
    set ul[1]='I00H'
    set ul[2]='I00D'
    set ul[3]='I00E'
    set ul[4]='I00F'
    set ul[5]='I00G'[/B]
    loop
        set l=l+1
        exitwhen l==5
[B]        if (GetItemTypeId(i)== ul[l]) then[/B]
            if (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)>=600) then
                call AdjustPlayerStateBJ(-600,GetOwningPlayer(GetManipulatingUnit()), PLAYER_STATE_RESOURCE_GOLD)
                call PlayerMsg(p,"|cFF0000FFNote:|r Your item is being upgraded")
                call UnitRemoveItemSwapped(i,u)
                call RemoveItem(i)
                call UnitAddItemByIdSwapped('I00C',u)
                set iu = GetLastCreatedItem()
                call TriggerSleepAction(10.00)
                call UnitRemoveItemSwapped(iu,u)
                call RemoveItem(iu)
[B]                call UnitAddItemByIdSwapped( ul[l],u )[/B]
            else
                call PlayerMsg(p,"|cFF0000FFNote:|r You need more gold to upgrade this item")
            endif
        endif
    endloop
endfunction

//===========================================================================
function InitTrig_UpgradeBasicCannonJASS takes nothing returns nothing
    set gg_trg_UpgradeBasicCannonJASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_UpgradeBasicCannonJASS, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddAction( gg_trg_UpgradeBasicCannonJASS, function Trig_UpgradeBasicCannonJASS_Actions )
endfunction
 

Vulcansurge

Ultra Cool Member
Reaction score
27
andrewgosu has it , thats the problem. Should have mentioned it before sorry...

Anyway to fix it?
 
I

IKilledKEnny

Guest
Yup Andrewgosu said what I said ( > just make it integer) but he gave fixed example. :) Do what he said, remember integers using letters need to be between 2 's.
 

Vulcansurge

Ultra Cool Member
Reaction score
27
How does that work? how can I00C be and integer is alpha numeric... Anyway, thanks Andrewgosu.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top