• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

[General] Custom script trigger?

Status
Not open for further replies.
Level 17
Joined
Dec 11, 2014
Messages
2,004
Not always leaks. We sometimes use it when we want to use a variable as a key for a hashtable as well. There is no limit. As I've already said in your wrong-forum thread:

Custom script is a way to use JASS (vJASS and other scripting languages as well) in GUI. Example:
  • Custom script - call DestroyTrigger(GetTriggeringTrigger())
That destroys the current trigger. We use custom script when we have a feature in JASS and we don't in GUI, and we want to use that feature in GUI.
 
So, what does this "leak" mean?

Take a look at the link Flux provided.

Memory leak is if you can't refer to a used part in the memory.
The memory part is occupied, but during runtime the user has no
possibility anymore to read or manipulate the said part in memory.
You can say that leaked memory is unuseable and will hold up space for just nothing.
 
So, custom scripts are only to remove leaks?

As Arad stated above, no it is not. Custom scripts are so people can use JASS script normally not available in GUI. A great example is the native to clear leaks, but it is not the sole reason. If you were to scroll through all of the functions you have available to you in the trigger editor, you would find out that there's nothing correlated to call RemoveLocation() or set bj_wantDestroyGroup = true. That is because the two examples I gave you is a native and constant only accessible via JASS script.
 
So, the custom script is good for making what?

It just you access to JASS functions.

GUI is just the interface of JASS. When you compile your map, all those cute icons and non-broken english text you see will get converted into JASS.

For example, take a look at this GUI snippet:
  • Test Trigger
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Order (Last created unit) to Move To (Random point in (Playable map area))
This is familiar to you, yes? Well, this is what it gets converted into:
JASS:
function Trig_Test_Trigger_Actions takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
    call IssuePointOrderLocBJ( GetLastCreatedUnit(), "move", GetRandomLocInRect(GetPlayableMapRect()) )
endfunction

//===========================================================================
function InitTrig_Test_Trigger takes nothing returns nothing
    set gg_trg_Test_Trigger = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Test_Trigger, function Trig_Test_Trigger_Actions )
endfunction

The text you see in red go even further (obviously not in the right order, just copy pasting all the functions here):
JASS:
function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group
    call GroupClear(bj_lastCreatedGroup)
    loop
        set count = count - 1
        exitwhen count < 0
        call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
        call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
    endloop
    return bj_lastCreatedGroup
endfunction

//===========================================================================
function GetRectCenter takes rect whichRect returns location
    return Location(GetRectCenterX(whichRect), GetRectCenterY(whichRect))
endfunction

function GetPlayableMapRect takes nothing returns rect
    return bj_mapInitialPlayableArea
endfunction

//===========================================================================
function IssuePointOrderLocBJ takes unit whichUnit, string order, location whichLocation returns boolean
    return IssuePointOrderLoc( whichUnit, order, whichLocation )
endfunction

function GetLastCreatedUnit takes nothing returns unit
    return bj_lastCreatedUnit
endfunction

function GetRandomLocInRect takes rect whichRect returns location
    return Location(GetRandomReal(GetRectMinX(whichRect), GetRectMaxX(whichRect)), GetRandomReal(GetRectMinY(whichRect), GetRectMaxY(whichRect)))
endfunction

In the end, it's all just preference. Obviously JASS is the better solution here because of speed (readability if you're a programmer, and maybe freedom?), but if you don't feel like learning a programming language, GUI is perfectly fine.
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
So, the custom script is good for making what?

As I and KILLCIDE have said, there is no limit. Custom script is good for making everything. You can do the EXACT way the GUI functions do with it or do what is usually used, pure JASS. GUI has a lot of limits that in which we don't have in JASS, we remove the limit by using custom script.

Custom script is usually used for leaks, but as I've said before you can use it for Hashtables, Custom functions, removing BJ's, using natives to have more control over the map rather than BJ's, etc. there is no limit.


there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
there is no limit.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
As KILLCIDE mentioned "GUI is just the interface of JASS.".

In Warcraft 3, you can change the behavior and appearance of a map using a scripting language made by Blizzard. This scripting language is known as JASS (Just Another Scripting Syntax).

Because coding is not so easy for most people, especially for those who have never used it, Blizzard made an "easy to use" graphical interface so you can use most of the JASS features in an easier understandable language.

Everything that you make in your trigger up from "Unit - Set Life of (Unit)" to "Variable - Set (variable) = (value)" is converted to pure JASS code when you save the map.

Because it is really hard to cover all the required features of JASS in the GUI triggers, they also made a special case known as Custom Script.
This one does not convert to JASS because you as map maker are allowed to write pure JASS in that action all by yourself.

This opens a lot of efficiency options but also functions that are not included in GUI trigger actions.
For example the functions "RemoveLocation()", "DestroyGroup()" and "DestroyForce()".
You could also create your own functions in it so you dont have to make so much redundant code.

"there is no limit"
Wanna bet?
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
In most coding languages, functions or methods often require parameters or arguments.
These are data you pass in on the function or method that you call.

For example, you call the function KillUnit.
KillUnit's purpose is to simply kill a unit, however, you havent told it which unit it should kill.
To tell that function which unit to kill, you pass the unit in as a parameter:
KillUnit myUnit

To tell the function which parameters it has, you create parenthesis and place the parameters inside it: KillUnit(myUnit)

Sometimes functions do not require any parameters, but to still tell the comiler that it is a function call, you add empty parenthesis to the functions name: GetTriggerUnit() (aka Triggering unit)

Parenthesis are also used to control the order in which certain stuff is executed.
For example in maths you do "4 + 5 * 6" which becomes "4 + 30" because multiplication comes before addition.
To be able to do the addition first, you place those between parenthesis: "(4 + 5) * 6" which will be "9 * 6".

"()()" is really weird and completely useless.
Even if the first is because of the function call without parameters, you still end up with the second being useless.

(5 / (5 / (5 / (5 / 5)))) is an example of something where the parenthesis are necessary. (The outcome is 5 for those who want to know :D)
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
"Wietlol mentioned some important things."
Thats new... not me mentioning important things, but people actually knowing they are important.

If somebody doesn't know how to use parentheses correctly, he'll be unable to use math and code correctly. Almost all coding languages have a start and an ending tag.

HTML: <meh>something</meh>
JASS: call meh(parameter, Func(parameter))
Java: System.out.printIn("still we have start and ending tags.");
C#: System.console.WriteLine("Still parentheses, not mentioning all {}[]/**/ things.");

They are indeed important.
 
Last edited:
Level 14
Joined
Nov 30, 2013
Messages
924
If somebody doesn't know how to use parentheses correctly, he'll be unable to use math and code correctly. Almost all coding languages have a start and an ending tag.

HTML: [meh]something[/meh]
JASS: call meh(parameter, Func(parameter))
Java: System.out.printIn("still we have start and ending tags.")
C#: System.console.WriteLine("Still parentheses, not mentioning all {}[]/**/ things.")

They are indeed important.

In Java, it's actually look like this

Code:
System.out.println("I'm just a hero for fun");

Your example for Java errors without " ; " in the end and misspelled println.

I'm only familiar with Java and Jass (vJass a little). I'm also familiar with C++ and HTML a little.
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,296
One should really not use GUI in Warcraft III anyway as the implementation is just so terrible. It is so much easier to get stuff done with custom script writing. After using GUI in StarCraft II you will literally grind your teeth away with frustration using WC3 GUI.

Seems complicated. Because I still don't understand the "()()))(" like that.
It a programming language. Unlike natural languages, programming languages follow very strict syntaxes. If the syntax is not correct it throws a syntax error rather than even trying to run.

I would recommend reading an introductory guide to programming languages if you plan to use JASS. If you can grasp the basics of a language like C or Java then you will have no problem grasping JASS. You can do the opposite as well (that is what I did originally) however it is likely a lot harder as JASS is actually quite a bad language and has many unexpected behaviours.
 
Read what's GUI and what's JASS: http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/elemental-coder-guide-274346/

Interface -> GUI

Plain text -> JASS (or an extension of JASS, but which is not important now)

GUI can use "Custom script" to allow the user directly writing in JASS. One line at least.

Read the examples made in the linked tutorial for GUI and JASS.

If you are totaly new to any kind of coding with writing texts, then you might want to use GUI at first, because it's beginner friendlier.
 
Status
Not open for further replies.
Top