• 🏆 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!

Calling a Jass Function

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
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.

JASS:
function Test_Sort_Actions takes nothing returns nothing

local boolean swap
local integer temp
local integer count = 0

loop
  exitwhen swap == false
  set swap = false
  loop
    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
      endif
  endloop
endloop


endfunction

//===========================================================================
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 )
endfunction

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:
http://www.hiveworkshop.com/forums/...ials-280/use-functions-other-triggers-232537/

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.
 
Status
Not open for further replies.
Top