Integer Question

EoW.chips

New Member
Reaction score
2
Hey,

how can i set a Variable like this:

MUI_3 = Integer -nothing-

How to set an Integer Variable to -nothing- ?

Thanks for help
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Hey,

how can i set a Variable like this:

MUI_3 = Integer -nothing-

How to set an Integer Variable to -nothing- ?

Thanks for help

You cannot. 0 is the value you would want to use. You essentially need to reserve a specific value and treat that one as a "NULL". With vJASS, struct(0) is used as the NULL value.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
darthfett already explained it, it simply is not possible, the reason why some variables can be set to null and others (numbers) can not, is because other variables contain a handle (a number generated by wc3) which is never 1, so setting that variable to null actually just sets it to 0 which wc3 treats as a null handle, integers/reals cant be set to null because well... 0 is null, the only way to get an integer/real variable that equals nothing is with locals:
[ljass]local integer i[/ljass] local variables like this that do not have an initialized value have no value, but they cause errors if you try to reference them like an integer until they are set, ie:
[ljass]local integer i = 0[/ljass] is an initialized variable
JASS:
function Example takes nothing returns nothing
    local integer i = 0
    set i = i + 1 //works
endfunction

function Example takes nothing returns nothing
    local integer i
    set i = i + 1 //doesnt work, cuz i = ??? so set i = ??? + 1 = ???... it cant do it
endfunction
 
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