WE does not accept this code but JassCraft does:confused: +rep

Samael88

Evil always finds a way
Reaction score
181
This is solved!

JASS:
globals
    integer MeteorCount = 0
    real array StartingX
    real array StartingY
    integer array MainBuild          
    integer array BuildSlots
    integer loopint = 0   
    race array PlayerRaces
    integer HumanMain = 'h006'
    integer OrcMain = 'o009'
    integer UndeadMain = 'u007'
    integer NightElfMain = 'h006'
endglobals

function variableset takes nothing returns nothing
    loop 
        exitwhen loopint == 12
        set StartingX[loopint] = GetStartLocationX(loopint)
        set StartingY[loopint] = GetStartLocationY(loopint)
        set PlayerRaces[loopint] = GetPlayerRace(Player(loopint))        
        set loopint = loopint + 1
    endloop
endfunction   

            
function Start takes nothing returns nothing
    set loopint = 0
    loop
        exitwhen loopint==12             
        if PlayerRaces[loopint] == RACE_HUMAN then
        call CreateUnit(Player(loopint), HumanMain, StartingX[loopint], StartingY[loopint], 270)
        endif 
        if PlayerRaces[loopint] == RACE_ORC then
        call CreateUnit(Player(loopint), OrcMain, StartingX[loopint], StartingY[loopint], 270)
        endif
        if PlayerRaces[loopint] == RACE_UNDEAD then
        call CreateUnit(Player(loopint), UndeadMain, StartingX[loopint], StartingY[loopint], 270)
        endif
        if PlayerRaces[loopint] == RACE_NIGHTELF then
        call CreateUnit(Player(loopint), NightElfMain, StartingX[loopint], StartingY[loopint], 270)
        endif
        set loopint= loopint + 1 
    endloop
endfunction


JassCraft accepts this code and tells me that it is ok. But the game won't accept it:nuts: I can't find anything wrong with it.
+rep to helper

This is how I call it for now:
Custom Script: call Start(loopint)
Custom Script: call variableset(loopint)

I have tried calling it in the map init and in 0.1 sec of gametime.
It just gives me about 34 errors, almost everyone of them is on loopint
 

saw792

Is known to say things. That is all.
Reaction score
280
JASS:
function variableset takes nothing returns nothing


It doesn't take anything, yet you are trying to pass it an argument.

Also, I don't see a MapSetup function there either.
 

Samael88

Evil always finds a way
Reaction score
181
JASS:
function variableset takes nothing returns nothing


It doesn't take anything, yet you are trying to pass it an argument.

Also, I don't see a MapSetup function there either.

I have tried passing loopint over to it, that is the one I usually need to pass over when doing this type of functions.

The start/mapsetup was a typo. I renamed it beacuse of the possibility of another function with that name.

Wich arguments should be passed over?
Why?
And how?
Is is like this:
call Start(loopint):confused:

Edit: Oh, passing loopint does not work either: function variableset takes integer loopint returns nothing

I am currently putting it in the map header to test it out, I don't want to write several pages of code without testing it on the way just to find out that it does not work in the end.

Edit2: Allmost all the errors are on loopint, not matter if I pass it with the function or not.
 

saw792

Is known to say things. That is all.
Reaction score
280
Hmm sorry I don't know what is going wrong then. What is the exact error, and exact line of the first error?
 

Samael88

Evil always finds a way
Reaction score
181
It says, "expected end of line" for every global.
It says, that it expected a variable name for every time Loopint is used.
And a few expected name and expected endloop at the end of it.
It is now down to 25 errors. And here is the current code:
JASS:
globals
    integer MeteorCount = 0
    real array StartingX
    real array StartingY
    integer array MainBuild          
    integer array BuildSlots
    integer Loopint = 0   
    race array PlayerRaces
    integer HumanMain = 'h006'
    integer OrcMain = 'o009'
    integer UndeadMain = 'u007'
    integer NightElfMain = 'h006'
endglobals

function variableset takes integer Loopint returns nothing
    loop 
        exitwhen Loopint == 12
        set StartingX[Loopint] = GetStartLocationX(Loopint)
        set StartingY[Loopint] = GetStartLocationY(Loopint)
        set PlayerRaces[Loopint] = GetPlayerRace(Player(Loopint))        
        set Loopint = Loopint + 1
    endloop
endfunction   

            
function Start takes integer Loopint returns nothing                   
    set Loopint = 0
    loop
        exitwhen Loopint == 12             
        if PlayerRaces[Loopint] == RACE_HUMAN then
            call CreateUnit(Player(Loopint), HumanMain, StartingX[Loopint], StartingY[Loopint], 270)
         
        elseif PlayerRaces[Loopint] == RACE_ORC then
            call CreateUnit(Player(Loopint), OrcMain, StartingX[Loopint], StartingY[Loopint], 270)
        
        elseif PlayerRaces[Loopint] == RACE_UNDEAD then
            call CreateUnit(Player(Loopint), UndeadMain, StartingX[Loopint], StartingY[Loopint], 270)
        
        elseif PlayerRaces[Loopint] == RACE_NIGHTELF then
            call CreateUnit(Player(Loopint), NightElfMain, StartingX[Loopint], StartingY[Loopint], 270)
        endif
        set Loopint= Loopint + 1 
    endloop
endfunction


Edit: Can it be that these are buildings?:
JASS:
    integer HumanMain = 'h006'
    integer OrcMain = 'o009'
    integer UndeadMain = 'u007'
    integer NightElfMain = 'h006'
 

saw792

Is known to say things. That is all.
Reaction score
280
If (as I suspect) you don't have Newgen, you can only declare globals at the very top of the map script. Move all those globals to the map header at the very top, and see what happens.
 

SFilip

Gone but not forgotten
Reaction score
634
> Move all those globals to the map header at the very top, and see what happens.
That won't work.

As already said, the code you're trying to use requires Jass NewGen. While you could modify it not to, you really should get NewGen as it's a really good thing to have.
 

Samael88

Evil always finds a way
Reaction score
181
> Move all those globals to the map header at the very top, and see what happens.
That won't work.

As already said, the code you're trying to use requires Jass NewGen. While you could modify it not to, you really should get NewGen as it's a really good thing to have.

The code you are reffering to is the global block right?
Beacuse all the other stuff works if I use udgs instead.

I actually have newgen, I just don't like to use. I guess I am just affraid.
It is like in gone in 60 seconds whit nicolas cage and eleanor:eek:
 

saw792

Is known to say things. That is all.
Reaction score
280
Well the thing is, normal world editor only allows globals to be declared at the very top of the map script, sortof like how local variables work within a function. Unfortunately (as I now realise) we cannot access the top of the map script. There is already a globals block in the map script that contains all the variables declared in the GUI variable editor. That means that you cannot declare another globals block. Newgen, however, allows you to use globals blocks wherever you want, and merges them with the globals block at the top of the map script upon saving.
 

Samael88

Evil always finds a way
Reaction score
181
Well the thing is, normal world editor only allows globals to be declared at the very top of the map script, sortof like how local variables work within a function. Unfortunately (as I now realise) we cannot access the top of the map script. There is already a globals block in the map script that contains all the variables declared in the GUI variable editor. That means that you cannot declare another globals block. Newgen, however, allows you to use globals blocks wherever you want, and merges them with the globals block at the top of the map script upon saving.

Aha, to bad I kind of already figured that out. But if I use no udgs, can I use the other way to declare globals instead?
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
Yes, you can declare globals without the udg_ prefix.
JASS:
function DMG takes nothing returns real
return 125.
endfunction


Used like this:
JASS:
local real damage = DMG()


Can also be used with other types.
Jass globals can also be constants.
JASS:
constant function DMG takes nothing returns real
return 89.
endfunction


Or even changing numbers according to levels:
JASS:
function YourSpell_DMG takes integer lvl returns real
if lvl == 1 then
     return 80.
elseif lvl == 2 then
     return 135.
elseif lvl == 3 then
     return 240.
endif
return 0
endfunction

Used like this:
JASS:
local real dmg = YourSpell_DMG(GetUnitAbilityLevel(caster, YourSpell_SPELLID))


Spell rawcodes should be constants:
JASS:
constant function Enflame_SPELLID takes nothing returns integer
    return 'A000'
endfunction


Hope I helped.
 

Samael88

Evil always finds a way
Reaction score
181
What if he is not on about constant globals?

I descided to start learning vJASS. I thought that the global block was possible to use in normal JASS:(
I will code in JassCraft and then just implement it into my map thru the newgen editor. That is much easier beacuse I really hate the newgen trigger editor:(
I can never seem to get the colors right for my eyes:eek:

wich means. Constants, no. Libraries, no. and so on.
 

LocalDude

New Member
Reaction score
4
well good luck with vJASS if it dosent work you can try this
JASS:
globals
    integer udg_MeteorCount = 0
    real array udg_StartingX
    real array udg_StartingY
    integer array udg_MainBuild          
    integer array udg_BuildSlots
    integer udg_loopint = 0   
    race array udg_PlayerRaces
    unittype udg_HumanMain = h006
    unittype udg_OrcMain = o009
    unittype udg_UndeadMain = u007
    unittype udg_NightElfMain = n006
endglobals

function variableset takes integer udg_loopint returns nothing
loop
  exitwhen udg_loopint == 12                               
        set udg_StartingX[udg_loopint] = GetStartLocationX(udg_loopint)
        set udg_StartingY[udg_loopint] = GetStartLocationY(udg_loopint)
        set udg_PlayerRaces[udg_loopint] = GetPlayerRace(Player(udg_loopint))        
        set udg_loopint = udg_loopint + 1
    endloop
endfunction   

            
function Start takes integer loopint returns nothing
    set udg_loopint = 0
    loop
        exitwhen udg_loopint==12             
        if udg_PlayerRaces[udg_loopint] == RACE_HUMAN then
        call CreateUnit(Player(udg_loopint), udg_HumanMain, udg_StartingX[udg_loopint], udg_StartingY[udg_loopint], 270)
        endif 
        if udg_PlayerRaces[udg_loopint] == RACE_ORC then
        call CreateUnit(Player(udg_loopint), udg_OrcMain, udg_StartingX[udg_loopint], udg_StartingY[udg_loopint], 270)
        endif
        if udg_PlayerRaces[udg_loopint] == RACE_UNDEAD then
        call CreateUnit(Player(udg_loopint), udg_UndeadMain, udg_StartingX[udg_loopint], udg_StartingY[udg_loopint], 270)
        endif
        if udg_PlayerRaces[udg_loopint] == RACE_NIGHTELF then
        call CreateUnit(Player(udg_loopint), udg_NightElfMain, udg_StartingX[udg_loopint], udg_StartingY[udg_loopint], 270)
        endif
        set udg_loopint= udg_loopint + 1 
    endloop
endfunction

I dont now if it was what you were loking for but it placed the starting bouldings in my map, BTW
Code:
Untitled Trigger 001
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Custom script:   call variableset(udg_loopint)
        Custom script:   call Start(udg_loopint)
 

Samael88

Evil always finds a way
Reaction score
181
well good luck with vJASS if it dosent work you can try this
JASS:
globals
    integer MeteorCount = 0
    real array StartingX
    real array StartingY
    integer array MainBuild          
    integer array BuildSlots
    integer loopint = 0   
    race array PlayerRaces
    string HumanMain = h006
    string OrcMain = o009
    string UndeadMain = u007
    string NightElfMain = h006
endglobals

  exitwhen udg_loopint == 12
        set udg_StartingX[udg_loopint] = GetStartLocationX(udg_loopint)
        set udg_StartingY[udg_loopint] = GetStartLocationY(udg_loopint)
        set udg_PlayerRaces[udg_loopint] = GetPlayerRace(Player(udg_loopint))        
        set udg_loopint = udg_loopint + 1
    endloop
endfunction   

            
function Start takes integer loopint returns nothing
    set udg_loopint = 0
    loop
        exitwhen udg_loopint==12             
        if udg_PlayerRaces[udg_loopint] == RACE_HUMAN then
        call CreateUnit(Player(udg_loopint), udg_HumanMain, udg_StartingX[udg_loopint], udg_StartingY[udg_loopint], 270)
        endif 
        if udg_PlayerRaces[udg_loopint] == RACE_ORC then
        call CreateUnit(Player(udg_loopint), udg_OrcMain, udg_StartingX[udg_loopint], udg_StartingY[udg_loopint], 270)
        endif
        if udg_PlayerRaces[udg_loopint] == RACE_UNDEAD then
        call CreateUnit(Player(udg_loopint), udg_UndeadMain, udg_StartingX[udg_loopint], udg_StartingY[udg_loopint], 270)
        endif
        if udg_PlayerRaces[udg_loopint] == RACE_NIGHTELF then
        call CreateUnit(Player(udg_loopint), udg_NightElfMain, udg_StartingX[udg_loopint], udg_StartingY[udg_loopint], 270)
        endif
        set udg_loopint= udg_loopint + 1 
    endloop
endfunction

I dont now if it was what you were loking for but it placed the starting bouldings in my map, BTW
Code:
Untitled Trigger 001
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Custom script:   call variableset(udg_loopint)
        Custom script:   call Start(udg_loopint)

Oh, thanks. That is really the most simple somution to this problem:thup: I did not expect that from you:p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top