Integer/Real problem in function

prismpirate

New Member
Reaction score
2
I'm having problems with variables at the moment. If I use an integer for random numbers, my map hangs the moment the map loads. However, if I use a real, the map loads fine. However, GetRandomReal(0,6) can return numbers such as 3.5, something that I would not like to happen.
The function where the problem occurs is found below. It is perfectly fine if I do not have this function in my code. Could someone take a look and see what is wrong?

JASS:
function weatherselection takes nothing returns nothing
    
    local integer tempint = GetRandomInt(0, 6)
    
    if tempint == 0 then
        call Reverse()
    elseif tempint == 1 then
        call Reverse()
        call Winter()
    elseif tempint == 2 then
        call Reverse()
        call Thunder()
    elseif tempint == 3 then
        call Reverse()
        call Darkness()
    elseif tempint == 4 then
        call Reverse()
        call Wind()
    elseif tempint == 5 then
        call Reverse()
        call Rain()    
    endif
endfunction
 

Exide

I am amazingly focused right now!
Reaction score
448
I bet the problem lies within the functions you are calling.
Try disabling all those functions, save the map and see what happens.
 

prismpirate

New Member
Reaction score
2
If i call all the functions using:

JASS:
call somefunction()


It works. Should I use
JASS:
==
to check for equality? Or is that only for real numbers. In addition, are you allowed to create variables within if then statements?
 

prismpirate

New Member
Reaction score
2
JASS:
function Reverse takes nothing returns nothing
    call RemoveWeatherEffect( bj_lastCreatedWeatherEffect )
    //Winter
    call ReplaceGlobalTerrainReversed(LORDAERONSUMMER_DARK_GRASS, LORDAERONWINTER_SNOW) 
    //Thunder
    call ReplaceGlobalTerrainReversed(LORDAERONSUMMER_DARK_GRASS, LORDAERONFALL_DARK_GRASS)
    //Darkness
    call ReplaceGlobalTerrainReversed(LORDAERONSUMMER_DARK_GRASS, DALARAN_TRIM_GRASS)
    //Wind
    call ReplaceGlobalTerrainReversed(LORDAERONSUMMER_DARK_GRASS, VILLAGEFALL_THICK_GRASS)
    //Rain
    call ReplaceGlobalTerrainReversed(LORDAERONSUMMER_DARK_GRASS, ASHENVALE_LUMPY_GRASS)
    set treetype = 'LTlt'
    set Weather = "Normal"
endfunction


I've got it semi working, trying to fix it. I think I used tempint as a global somewhere. I'm using Romek's change terrain system btw.

Edit: Fixed. It was a variable naming problem. Thanks for the help though
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top