• 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.

[Solved] Syntax error for no reason

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

I just wanted to create a little map for no reason and already having a little problem, without doing anything. I just created a new map, want to save it and a syntax error shows up:

JASS:
function GetFadeFromSeconds takes real seconds returns integer
    if (seconds != 0) then
        return 128 / seconds
    else
        return 10000
    endif
endfunction

In the error window the "else" is marked and the error message is "line 7118:Cannot convert returned value from real to integer". I checked the trigger editor; nothing. Also also enabled UMSWE and things like that to test if this would fix the problem, but nothing, it's just a new empty map without adding, editing or deleting something.

I think I stood to long out of this scene, since its nothing I know from the past, so please can someone help me a bit here? =D

Thanks - Greetings - Peace
Dr. Boom
 
Last edited by a moderator:
You are trying to divide an integer by a real. By default, that converts it to a real.

Thus you must change the line to:
JASS:
return R2I(128 / seconds)

EDIT: I just realized that is a BJ function. You should get the latest patch. This is what it should look like in the latest Blizzard.j:
JASS:
function GetFadeFromSeconds takes real seconds returns integer
    if (seconds != 0) then
        return 128 / R2I(seconds)
    endif
    return 10000
endfunction

Source:
http://wiki.thehelper.net/wc3/jass/Blizzard.j

Long ago blizzard wasn't very careful with returns. The return bug allowed such statements, and it would typecast the real 128/seconds to an integer since the "returns" portion expected an integer. Ever since 1.24, they fixed that and fixed the faulty functions that relied on the return bug.
 
Level 16
Joined
May 1, 2008
Messages
1,605
O
M
G

I reinstalled my computer also Warcraft 3 but forgot to patch it, since I don't connect to Battle.net anymore.
How stupid can someone be seriously .. well thanks anyway :D

Edit: Bah need to spread some rep first before I can give you some rep :s

Greetings and Peace
Dr. Boom
 
Status
Not open for further replies.
Top