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

[JASS] Error saving, Line 648: Expected: "returns"

Status
Not open for further replies.
Level 8
Joined
May 21, 2008
Messages
218
JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Builders_Func001Func001C takes nothing returns boolean
    if ( not ( GetPlayerController(udg_players[GetForLoopIndexA()]) == MAP_CONTROL_USER ) ) then
        return false
    endif
    if ( not ( GetPlayerSlotState(udg_players[GetForLoopIndexA()]) == PLAYER_SLOT_STATE_PLAYING ) ) then
        return false
    endif
    return true
endfunction

---------------------------------------------------------------
function Trig_Builders_Get_Player takes integer returns player| This line causes error
---------------------------------------------------------------
   return local player p = Player(a)
endfunction

function Trig_Builders_Get_PlayerID takes integer returns integer
    return local player pi = GetPlayerId(Player(a))
endfunction

function Trig_Builders_Actions takes nothing returns nothing
    
    local integer a = 0
    local integer b = 7 
    
    loop
        exitwhen a > b
        
        call function Trig_Builders_Get_Player (a)
        call function Trig_Builders_Get_PlayerID (a)
               
        if ( Trig_Builders_Func001Func001C() ) then
            call CreateUnit( pi, 'e001', GetPlayerStartLocationX(p), GetPlayerStartLocationY(p), 270.00 ) 
        else
            call CreateUnit( pi, 'e001', GetPlayerStartLocationX(p), GetPlayerStartLocationY(p), 270.00 ) 
        endif
        set a = a + 1
    endloop
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

//===========================================================================
function InitTrig_Builders takes nothing returns nothing
    set gg_trg_Builders = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Builders, function Trig_Builders_Actions )
endfunction

Im incredibly noob at JASS so help please.
Used NewGen

Error:
function Trig_Builders_Get_Player takes integer returns player
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
You can't declared a variable on the return value. What exactly do you return?
You also don't name your parameters.

JASS:
function Trig_Builders_Get_Player takes integer a returns player
   return Player(a)
endfunction

function Trig_Builders_Get_PlayerID takes integer a returns integer
    return GetPlayerId(Player(a))
endfunction

It is also not suggested to destroy triggers unless you really have to. It can cause serious trouble if you are unlucky.

And what's up with all you guys naming your functions with WE-automatic-idiotic-too-long-names?
 
Status
Not open for further replies.
Top