• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Calling a Jass Function

Not open for further replies.
Level 16
Mar 27, 2011
Wanted to make a bubble sort and I've made it in Jass. I'm not sure if I've made it properly, but that beside the point for now.

This is my first attempt at using Jass so I have no idea how to call the Jass trigger from GUI! I get the error message "Expected a Function Name". How do I get the name of my function? I've tried:

call Test_Sort()
call TestSort()
call Test_Sort_Actions()
call InitTrig_Test_Sort()

No idea what I've named my function...? Lol.

function Test_Sort_Actions takes nothing returns nothing

local boolean swap
local integer temp
local integer count = 0

  exitwhen swap == false
  set swap = false
    exitwhen count == 4
      if udg_sort[count] < udg_sort[count + 1] then
        set temp = udg_sort[count]
        set udg_sort[count] = udg_sort[count + 1]
        set udg_sort[count + 1] = temp
        set swap = true


function InitTrig_Test_Sort takes nothing returns nothing
    local trigger Test_Sort = CreateTrigger()
    set Test_Sort = CreateTrigger()
    call TriggerAddAction( Test_Sort, function Test_Sort_Actions )

The tutorial I'm following, http://www.hiveworkshop.com/forums/jass-ai-scripts-tutorials-280/jass-what-func-238298/, doesnt have all that init code after the comment.

  • Display Kills
    • Events
      • Player - Player 1 (Red) types a chat message containing -sort as An exact match
    • Conditions
    • Actions
      • Set sort[1] = 5
      • Set sort[2] = 6
      • Set sort[3] = 9
      • Set sort[4] = 4
      • Set sort[5] = 12
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) for 3.00 seconds the text: (String(sort[(Integer A)]))
      • -------- --------- --------
      • -------- sort --------
      • -------- --------- --------
      • Custom script: call Test_Sort()
      • Wait 3.00 seconds
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) for 3.00 seconds the text: (String(sort[(Integer A)]))
Follow this tutorial:

And use call Test_Sort_Actions().

You can also move the function over to the map header (it'll allow you to call it from anywhere). To access the map header, go to the trigger editor, look to the left side where all the triggers are listed, and click on the map's name. The right area should turn into a window that accepts text. Paste the function over there, and you should be able to call it from your GUI triggers.
Not open for further replies.