• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Expected function name

Status
Not open for further replies.

sentrywiz

S

sentrywiz

I just started learning jass. Taking on this tutorial:

http://www.hiveworkshop.com/forums/jass-ai-scripts-tutorials-280/beginning-jass-tutorial-series-30765/

But I can't even pass the first lessons without a boatload of errors.

I want to try this code:

JASS:
function Trig_bla_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_bla takes nothing returns nothing
    set gg_trg_bla = CreateTrigger(  )
    call TriggerAddAction( gg_trg_bla, function Trig_bla_Actions )
endfunction

function DisplayAMessage takes string message returns nothing
    call BJDebugMsg(message)
endfunction

And call the function from another trigger

  • Trigger
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
    • Conditions
    • Actions
      • Custom script: call DisplayAMessage("Hello")
And its not letting me, tells me the "Expected function name" error and the function is clearly named DisplayAMessage.

Can anyone tell me why?
I don't understand. I am copying the code from the tutorial.
 
Is this placed within the Custom Script Code section of your trigger editor (if you click on the map's name above your triggers)?
160036-albums4747-picture85155.jpg
 

sentrywiz

S

sentrywiz

No they are inside separate triggers that are converted into custom text.

I am just following the tutorial at the link
 
Yeah, this won't work for plain Jass. You can't call the function externally, unless it's within the Custom Script section. In vJass, for instance, this would work, provided that you have a library or something similarly functioning.

Plus, it's listed on the tutorial:
-Click on the map icon at the top of the list of triggers
-Paste the code in the custom script section.
 

sentrywiz

S

sentrywiz

I knew it was entirely my fault somehow xD

Thanks for telling me and pointing it out.
So I can just put all the functions that I am trying to test in the custom script section and make triggers to test them? That would work?

+rep

EDIT: Tested it. It works flawlessly now.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Yeah, this won't work for plain Jass. You can't call the function externally, unless it's within the Custom Script section. In vJass, for instance, this would work, provided that you have a library or something similarly functioning.

Plus, it's listed on the tutorial:

This is not entirly true. You could call funcfions inside other triggers, but you must guarantee that the function is defined above your trigger, where you call it, which is nigh impossible.
 

sentrywiz

S

sentrywiz

This is not entirly true. You could call funcfions inside other triggers, but you must guarantee that the function is defined above your trigger, where you call it, which is nigh impossible.

EDIT: I didn't yet have my morning coffee so I read gibberish.
 
Last edited by a moderator:

sentrywiz

S

sentrywiz

You cant do that too, because function with name X can only be once in map script. Pharaoh provides good solution to this

So the solution is to use the custom script section at the top of the map right? That way functions will always be 'above' and can be used anywhere?
 
Status
Not open for further replies.
Top