• 🏆 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] Few Questions

Status
Not open for further replies.
Level 5
Joined
Nov 22, 2009
Messages
181
Hi. I'm learning to use Jass and have read all the tutorials i could find and still have many questions especially about triggers.
Lets say you have a trigger assisted spell called portal. the ability is based off of Archimond's Dark Portal spell and summons nothing. The unit is based off of the human campaign 'portal' and has the Waygate ability. The trigger's actions would be:
  • set tempPoint[1] to position of (casting unit)
  • set temppoint[2] to target point of ability being cast
  • create 1 Portal at tempPoint[1] for (owner of (casting unit))
  • set Waygate destination for (last created unit) to tempPoint[2]
  • create 1 portal at tempPoint[2] for (owner of (casting unit))
  • set Waygate destination for (last created unit) to tempPoint[1]
  • custom script: call RemoveLocation(udg_tempPoint[1])
  • custom script: call RemoveLocation(udg_tempPoint[2])
When converted to custom text and simplified the trigger would look something like:

JASS:
function PortalConditions takes nothing returns boolean
    return GetAbilityID()=='A000'
endfunction

function PortalActions takes nothing returns nothing
    local location loc1=GetUnitLocation(caster)
    local location loc2=GetSpellTargetLocation()
    local unit portal1= CreateNUnits(1, loc1, GetUnitOwner(caster))
    local unit portal2= CreateNUnits(1, loc2, GetUnitOwner(caster))
        SetWaygateDestinationBJ (portal1, loc2)
        SetWaygateDestinationBJ (portal2, loc1)
        call RemoveLocation(loc1)
        call RemoveLocation(loc2)
        set portal1 = null
        set portal2 = null
endfunction

//======================================

function InitTrig_Portal takes nothing returns nothing
    set gg_trg_Portal = CreateTrigger()
    TriggerRegisterAnyUnitEventBJ(gg_trg_Portal, EVENT_UNIT_ABILITY_CAST)
    TriggerAddCondition(gg_trg_Portal, condition(PortalConditions),
    TriggerAddAction(gg_trg_Portal, PortalActions)
*not exact functions

Do the actions and conditions need in a special place like when you click on the map name in the trigger editor, above the area where the actions/conditions/events are displayed, and to the left, where it says 'code entered here will be loaded after global variables and before any other functions? (i hope you got that) and does there need to be a function that starts at melee initialization in order to call the InitTrig_Portal function to actually make the trigger?
ill finish this post when im able
 
Level 22
Joined
Feb 3, 2009
Messages
3,292
JASS:
function InitTrig_Portal takes nothing returns nothing
    set gg_trg_Portal = CreateTrigger()
    TriggerRegisterAnyUnitEventBJ(gg_trg_Portal, EVENT_UNIT_ABILITY_CAST)
    TriggerAddCondition(gg_trg_Portal, condition(PortalConditions),
    TriggerAddAction(gg_trg_Portal, PortalActions)
Well.. this above is the initilization function of a trigger... In here is set on what event the trigger runs and sets a function for the conditions and actions (if any)

JASS:
  set gg_trg_Portal = CreateTrigger()
This line creates your trigger for use.

JASS:
 TriggerRegisterAnyUnitEventBJ(gg_trg_Portal, EVENT_UNIT_ABILITY_CAST)
This is the function that sets on what event to run.

JASS:
 TriggerAddCondition(gg_trg_Portal, condition(PortalConditions)
This code is to set the function of the conditions, in your case PortalConditions.


JASS:
 TriggerAddAction(gg_trg_Portal, PortalActions)
This code is to set the function of the actions, in your case PortalActions.
 
JASS:
function PortalConditions takes nothing returns boolean
    return GetAbilityID()=='A000'
endfunction

function PortalActions takes nothing returns nothing
    local location loc1=GetUnitLocation(caster)
    local location loc2=GetSpellTargetLocation()
    local unit portal1= CreateNUnits(1, loc1, GetUnitOwner(caster))
    local unit portal2= CreateNUnits(1, loc2, GetUnitOwner(caster))
    call SetWaygateDestinationBJ (portal1, loc2)
    call SetWaygateDestinationBJ (portal2, loc1)
    call RemoveLocation(loc1)
    call RemoveLocation(loc2)
    set portal1 = null
    set portal2 = null
endfunction

//======================================

function InitTrig_Portal takes nothing returns nothing
    set gg_trg_Portal = CreateTrigger()
    TriggerRegisterAnyUnitEventBJ(gg_trg_Portal, EVENT_UNIT_ABILITY_CAST)
    TriggerAddCondition(gg_trg_Portal, condition(PortalConditions),
    TriggerAddAction(gg_trg_Portal, PortalActions)
*not exact functions

Do the actions and conditions need in a special place like when you click on the map name in the trigger editor, above the area where the actions/conditions/events are displayed, and to the left, where it says 'code entered here will be loaded after global variables and before any other functions? (i hope you got that) and does there need to be a function that starts at melee initialization in order to call the InitTrig_Portal function to actually make the trigger?
ill finish this post when im able

The world editor basically reads this code from up to down. The triggers that come first are the ones placed first. When you refer to functions, you must refer to a function above the action.

Example:
JASS:
//This would compile without any errors
function Whee takes nothing returns nothing
endfunction

function Argh takes nothing returns nothing
    call Whee()
endfunction
JASS:
//This would cause an error.
//Undefined function Argh()
function Whee takes nothing returns nothing
    call Argh()
endfunction

function Argh takes nothing returns nothing
endfunction

(Unless you use: ExecuteFunc("Argh"))

Functions in the header are sent immediately to the top of the script, so they are parsed first. This allows them to be used globally. You can use functions globally if they are in a trigger, but the trigger must be before all the others. (Unless you use vJASS)

When you add the InitTrig_ prefix, it will automatically be ran. There is no need to run the function, it will do that at the start of the map automatically. All the functions with an InitTrig_ prefix are sent to the top of the map to be called from a function called "InitCustomTriggers". This function is ran immediately upon map initialization so no need to worry about calling it separately.
 
Level 5
Joined
Nov 22, 2009
Messages
181
When you add the InitTrig_ prefix, it will automatically be ran. There is no need to run the function, it will do that at the start of the map automatically. All the functions with an InitTrig_ prefix are sent to the top of the map to be called from a function called "InitCustomTriggers". This function is ran immediately upon map initialization so no need to worry about calling it separately.

THANK YOU SOOO MUCH!! I was having so much trouble trying to figure out what actually causes the function that creates the trigger to run. That explains so much. I mean this kind of stuff really should be mentioned in the tutorials.

The world editor basically reads this code from up to down. The triggers that come first are the ones placed first. When you refer to functions, you must refer to a function above the action.

Example:
JASS:
//This would compile without any errors
function Whee takes nothing returns nothing
endfunction

function Argh takes nothing returns nothing
    call Whee()
endfunction
JASS:
//This would cause an error.
//Undefined function Argh()
function Whee takes nothing returns nothing
    call Argh()
endfunction

function Argh takes nothing returns nothing
endfunction

Thank you but i already understood that part. What I dont understand is whether or not it matters if the -Actions function comes first or the
-Conditions function does.
I also want to know if it matters whether you need to have TriggerAddCondition come before TriggerAddAction or if they can be switched.

has anyone made a post that lists all of the premade functions and the paramaters in proper order and what it does or correlates to in gui and if it is a native or bj and (if it is a bj) whether it is effective or inefficient and if inefficient recommends a good replacement?
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
kennyman94 said:
What I dont understand is whether or not it matters if the -Actions function comes first or the
-Conditions function does.

It makes no difference, as long as they are above the InitTrig function (so that they can be "seen" when referenced). You could also just use JNGP and declare scopes, in which case you can declare your own initialization functions.

kennyman94 said:
has anyone made a post that lists all of the premade functions and the paramaters in proper order and what it does or correlates to in gui and if it is a native or bj and (if it is a bj) whether it is effective or inefficient and if inefficient recommends a good replacement?

Just never use BJ functions. Again, if you use JNGP then there is a really easy-to-use Function List which shows what exactly the functions do (and you can use these to formulate your own methods). If you don't have JNGP, then you could always open up war3.mpq, look for "scripts", and inside that folder is a file called blizzard.j and common.j, both of which have a list of the function APIs.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Scopes define where a certain object can be "seen". Read the JassHelper Manual (in the jassnewgenpack folder).

The functions list appears in TESH (the syntax highlighter) --do you have that?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
There is a library or "lookup" button when you're editing the code in NewGen. Use that library to look up a *ton* of functions.

A scope gives you greater control over your JASS code. Normally, if you want a function in each trigger called Actions, that's impossible, because you can only have one of a function name. Just, when you have a function in a scope, 99% of the time you want to write private function instead of function

A scope allows you do create functions called Actions in a bountiful number.

JASS:
scope Name_Of_Scope initializer Actions
    private function Actions takes nothing returns nothing
    endfunction
endscope
 
scope Another_Name_Of_Scope initializer Actions
    private function Actions takes nothing returns nothing
    endfunction
endscope
 
Level 5
Joined
Nov 22, 2009
Messages
181
I was told that tesh is horribly broken.

What are structs and how do they work?

So, scopes can contain multiple functions? and can you explain the syntax for the scope? like what is INITIALIZER and is actions the equivalent of InitTrig_ since it is after Initializer?

so could you have something like this?

JASS:
scope Portal initializer portal
    private function conditions takes nothing returns boolean
        //conditional statement
    endfunction

    private function actions takes nothing returns nothing
        //actions
    endfunction

    private function portal takes nothing returns nothing
        set gg_trg_Portal = CreateTrigger()
        call TriggerAddActions //blah blah blah
        call TriggerAddConditions // blah blah blah
    endfunction
endscope

scope IncomeIncrease initializer income
    private function conditions takes nothing returns boolean
        //conditional statement
    endfunction

    private function actions takes nothing returns nothing
        //actions
    endfunction

    private function income takes nothing returns nothing
        set gg_trg_Portal = CreateTrigger()
        call TriggerAddActions //blah blah blah
        call TriggerAddConditions // blah blah blah
    endfunction
endscope
 
I was told that tesh is horribly broken.

TESH works fine, it just doesn't highlight the Hashtable API and its syntax checker isn't functional. (it doesn't parse vJASS, but you don't really need the syntax checker if you have JNGP. TESH runs using the old pJASS syntax highlighter I think, or at least some version of it)

What are structs and how do they work?

http://www.hiveworkshop.com/forums/1508879-post11.html
I'm too lazy to rewrite it. =P


So, scopes can contain multiple functions? and can you explain the syntax for the scope? like what is INITIALIZER and is actions the equivalent of InitTrig_ since it is after Initializer?

Yes, scopes can contain multiple functions. Scopes are pretty much nothing but a kind of container. They "contain" your functions, in reality scopes are nothing but commented lines. =P However, they allow you to use the prefixes private and public for your functions to prevent function naming collisions and for general encapsulation. initializer are the equivalent of InitTrig_. Basically, you'll declare an initializer like this:
JASS:
scope Whee initializer Argh
private function Argh takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    //add condition func, add action func etc.
    set t = null
endfunction
endscope
It is essentially the same as:
JASS:
function InitTrig_Whee takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    //add condition func, add action func etc.
    set t = null
endfunction

If the trigger's name is Whee.

so could you have something like this?

Yep =)
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Look at the JassHelper manual (link in my signature) for all of the available features of JassHelper.

Not only can you declare functions within scopes, but you can declare other things as well. Anything declared within a scope can be privatized, or publicized, depending on where you want each "object" to be able to be referenced from.

Libraries work exactly like scopes, except libraries can require other libraries (allowing them to be ordered, unlike scopes). This is the fundamental difference between the two. The manual is actually pretty well written, and it provides lots of good examples to help you understand vJass/JassHelper syntax.
 
Level 5
Joined
Nov 22, 2009
Messages
181
Look at the JassHelper manual (link in my signature) for all of the available features of JassHelper.

Not only can you declare functions within scopes, but you can declare other things as well. Anything declared within a scope can be privatized, or publicized, depending on where you want each "object" to be able to be referenced from.

Libraries work exactly like scopes, except libraries can require other libraries (allowing them to be ordered, unlike scopes). This is the fundamental difference between the two. The manual is actually pretty well written, and it provides lots of good examples to help you understand vJass/JassHelper syntax.

Wait, so you can also declare variables like locals within a scope even if it is not in a function? Also aren't locals actually used bfunctions other than the one they are declared in when you use them as a paramater when calling a function? Because people keep saying a local can't be used by any other function than the one they are declared in.

What is the difference between a function and a public function?

What do you mean by a library can require another library?

What is MUI?
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
You can never declare local variables outside of a function. If you want a variable that can be referenced inside the scope, then make a global. It doesn't make any sense to have a "local" variable outside of a function, there is nothing to be local to. If you pass a local variable as a parameter then those passed variables become local to the function that is taking them.

kennyman94 said:
What is the difference between a function and a public function?

Public functions within different scopes can share the same name, but basically it just adds an "invisible" ScopeName_ prefix to the function. Normal functions are referenced exactly as they are declared, and cannot share names.

kennyman94 said:
What do you mean by a library can require another library?

Well if you want one library to be able to use another you would need to make it require that library, essentially ordering the code so that the libraries can see the necessary components. In JASS you cannot reference a function that is declared below the function you are referencing it from.

kennyman94 said:
What is MUI?

It basically refers to how many instances can be in-play at any given time. Multiple-unit-instance-able basically means that no matter how many units there are, there can be one instance of "something" for each unit.

kennyman94 said:
i have this idea where there is an ability that allows you to "capture" a unit and then you can bring another type of unit to the "captured" unit. Then when you move the "cage" to a certain area, that unit is put into a structure and your income is increased for every unit you have captured depending on the type and the units can be rescued by the original owner. does anyone have any ideas?

Any ideas on what? I still don't understand what you mean by "allows you to capture a unit and then you can bring another type of unit to the captured unit".
 
Level 5
Joined
Nov 22, 2009
Messages
181
when you use scopes and libraries, can the initializer be outside of the library (or scope) or can it only be used if it is inside?

What character is used for multiplication? is it "*"?

What is OOP?

Why do some conditional statements say:
JASS:
if (b) then //actions

Without anything to compare it with? Like:
JASS:
if b == true then //actions
 
Last edited:
Level 5
Joined
Nov 22, 2009
Messages
181
Can you have a function return a value without using the return command inside the function like this:
JASS:
function Sum takes integer A, integer B returns C
    local integer C = A + B
endfunction
function CallSum takes nothing returns nothing
    local integer A = 3
    local integer B = 2
        call Sum(a, b)
        call BJDebugMsg (i2s(C))
endfunction
// would it still return 5 and display it? (I can’t test it because my laptop was taken away because of grades so)
or do you have to put a type of value when specifying what it returns?

what is the function used to get all units of a type? is it GetUnitsOfType('/*rawcode*/)?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
JASS:
function Sum takes integer A, integer B returns integer
    return A + B
endfunction
 
function CallSum takes nothing returns nothing
    call BJDebugMsg (I2S(Sum(3,2)))
endfunction
 
// or //
 
function Sum takes integer A, integer B returns integer
    return A + B
endfunction
 
function CallSum takes nothing returns integer
    local integer C = Sum(3,2)
    call BJDebugMsg (I2S(C))
    return C
endfunction

when you use scopes and libraries, can the initializer be outside of the library (or scope) or can it only be used if it is inside?
Inside only. And it's best to use private function Init so that you can have another initializer in another scope/library with the same name.
What character is used for multiplication? is it "*"?
http://jass.sourceforge.net/doc/expressions.shtml

What is OOP?
Object-oriented Programming. (Wiki it). In Jass, those are structs.

Why do some conditional statements say:
JASS:
if (b) then
Do it like that. If (b) then is the same as if b == true then, and if not b then is the same as if b == false then.

Keep it without the == false/== true imo, because it's easy to accidentally disclude the second = operator.
 
Level 5
Joined
Nov 22, 2009
Messages
181
JASS:
Do it like that. [B]If (b) then[/B] is the same as [B]if b == true then[/B], and [B]if not b then[/B] is the same as [B]if b == false then[/B].
 
Keep it without the == false/== true imo, because it's easy to accidentally disclude the second = operator.[/QUOTE]

what if b was an integer or object or some type of value other than a boolean?

thank you you are a great help. :)
 
Level 5
Joined
Nov 22, 2009
Messages
181
what is the difference between: call EvaluateFunction(functionname) and functionname.evaluate and call ExecuteFunction(functionname) and functionname.execute?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
There is no EvaluateFunction(functionname) and ExecuteFunction(functionname).

There is ExecuteFunc("functionname") but that's it for what you can do with Jass. That command allows you to ignore the laws of precedence and it also doesn't interrupt the thread.

JASS:
functionname.execute()
//and
functionname.evaluate()

Those are vJass components and I am not exactly sure how they operate. You can't use vJass in the normal World Editor, you can only use it in NewGen, but you can't use it in the NewGen campaign editor.
 
Level 5
Joined
Nov 22, 2009
Messages
181
ok. how does it let you ignore the law of precedence? and how is it slower? i mean it can't really take THAT long. can it?

this might not be jass exactly but what are trigger ques, what do they do, how do they work, and how do you use them? (also can they be used in jass and if wo what are the functions and their syntax?)

what is mpi?

what does newtimer() and releasetimer() do?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Normally a function is called like call FunctionName() and that tells the game to scroll up the code and run that function, while using ExecuteFunc("FunctionName") is treating the function like an object and so it takes a nanosecond longer to run that function. The time difference is meaningless.

Trigger Queues are useless in Jass, so don't waste your time. Search the tutorials for something called "Exact Timing Cinematic" and that's the only use I've ever seen for Queues, but it's for GUI and, like I said, useless in Jass.

MPI = Multi-Player-Instanciable. Do you know what MUI is? MPI is the poor man's MUI as it allows 12 instances of the spell and one instance per player instead of unlimited instances.

Those functions are part of a vJass system called TimerUtils, a system used to recycle timers instead of destroying them. However, I don't have a need for TimerUtils as I always incorporate some kind of a timer-recycling system into the projects I work on. To understand TimerUtils, you have to understand a lot more about vJass and, again, you have to install NewGen for your game to compile vJass properly.
 
Level 5
Joined
Nov 22, 2009
Messages
181
ok. and again i already have jngp installed. also i already get most of the concepts (of the ones that ive seen so far ) but i still need to learn most of the preset functions.

What is the point of an interface if you still have to declare the methods and add all of the actions and calls to the methods?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Level 18
Joined
Jan 21, 2006
Messages
2,552
An interface is used to define rules of a struct, primarily so that when that struct is extended the defined rules can still be applied without having directly declared them in the struct. An interface cannot have a constructor method.
 
Level 5
Joined
Nov 22, 2009
Messages
181
@Berbanog: would you mind explaining that a little more? i don't quite understand. also, symantec antivirus says it found and quarantined a trojan horse called pipe.dll from jngp. is it real? will it being quarantined effect the we in any way? should i release it from quarantine?

thank you guys.
 
@Berbanog: would you mind explaining that a little more? i don't quite understand. also, symantec antivirus says it found and quarantined a trojan horse called pipe.dll from jngp. is it real? will it being quarantined effect the we in any way? should i release it from quarantine?

thank you guys.

No, it will count it as a virus because it is injecting stuff. But don't worry about it, it isn't a real virus (as long as you got it from the proper source). But yeah, it will show up as a virus, there might be some option though for your antivirus to ignore the "threat" from the JNGP. Else just disable it when you use WE.
 
Level 5
Joined
Nov 22, 2009
Messages
181
ok. i can just release it from quarantine. just wanted to make sure it is not a trojan horse, especially since i can't seem to remember which versions of the world editor were reported to have that issue occasionally. wait. will it still effect the we if the program remains quarantined? i got it from a link posted in one of the comments in one of the threads here. i think it went to some other forum website with it on there somewhere.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
There are lots of good examples on how interfaces can be used in the JassHelper manual. I'll show you a simple one:

JASS:
interface shape
    method area takes nothing returns real defaults 0.00
endinterface

struct square extends shape
    real    length

    method area takes nothing returns real
        return length*length
    endmethod
    
    static method create takes real length returns thistype
        local thistype s=allocate()
        set s.length=length
        return s
    endmethod
endstruct

struct rectangle extends square
    real    width
    
    method area takes nothing returns real
        return length*width
    endmethod
    
    static method create takes real length, real width returns thistype
        local thistype r=allocate(length)
        set r.width=width
        return r
    endmethod
endstruct

In this case, if you remove the interface then you cannot declare an alternative to method area within struct rectangle but using an interface will allow each method to be seen independently.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
It's one of those things that separates good code from really good code. The more you code the more you'll understand the purpose of it.

What I've explained above also means that you can allow users to extend a struct, redefine certain interface methods and then use the actions that are declared in these methods to almost "magically" reference events without writing any of the code.

A good example of this is my projectiles library.

JASS:
interface projectileinterface
    //inside this interface i would have declared many methods, for example:
    method onUnitCollision takes unit u returns nothing defaults nothing
endinterface

struct projectile
...
    //now in my projectile i am able to call the method ".onUnitCollision", even if
    //it does not directly exist inside this struct. 
        call projRef.onUnitCollision(GetFilterUnit()) //called from an enumeration callback
...
endstruct


struct missile extends projectile
...
    //now when i declare onUnitCollision the code for the collision has
    //already been made in the projectile, but i can extend that into this
    //struct-type and it will be executed as if the other code were there.
    method onUnitCollision takes unit u returns nothing

    endmethod
...
endstruct

Just try to use them where they are appropriate and they'll grow on you.
 
Level 5
Joined
Nov 22, 2009
Messages
181
I can't seem to get it. Doesn't projectile need to extend the interface? and can you make the example a lot more specific? I can't understand exactly what is going on (for the projectile example).
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
I can't seem to get it. Doesn't projectile need to extend the interface?
Yes, it definitely does in his actual map. Clearly, he didn't do a straight copy+paste. I've studied that bulky JASS code he made so many times and I've tried to model some of my code based on it, so I know at least that projectile extends projectileinterface.
 
Level 5
Joined
Nov 22, 2009
Messages
181
what is Enum as in GetEnumUnit()?

what is GetLocalPlayer and what does it do/ how does it work?

what is the difference between GetEnumUnit() and GetFilterUnit()?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
To enumerate is to count.

call GroupEnumUnitsInRange, however, should be called GroupFilterUnitsInRange because it filters units instead of counting them.

JASS:
function b takes nothing returns boolean
    if GetWidgetLife(GetFilterUnit()) > 0. then //filterunit = the unit being evaluated.
        return true    // returning true means the unit has been added to the group.
    endif
    return false    // returning false means that the unit has been filtered out.
endfunction
 
function a takes nothing returns nothing
    call GroupEnumUnitsInRange(group,x,y,radius,Filter(function b))
endfunction

GetEnumUnit() is an actual counted unit from a unit group, used in ForGroup.

ForGroup means Pick every unit in group
GetEnumUnit means "Picked Unit"
GetFilterUnit means "Matching Unit"
 
Level 5
Joined
Nov 22, 2009
Messages
181
cool thank you. now which color code corresponds to which color?
JASS:
    set udg_c[0]="|cffff0303"
    set udg_c[1]="|cff0042ff"
    set udg_c[2]="|cff1ce6b9"
    set udg_c[3]="|cff540081"
    set udg_c[4]="|cfffffc01"
    set udg_c[5]="|cfffe8a0e"
    set udg_c[6]="|cff20c000"
    set udg_c[7]="|cffe55bb0"
    set udg_c[8]="|cff959697"
    set udg_c[9]="|cff7ebff1"
    set udg_c[10]="|cff106246"
    set udg_c[11]="|cff4e2a04"
    set udg_c[12]="|cff272727"
    set udg_c[13]="|cff272727"
    set udg_c[14]="|cff272727"
i can't seem to get it to test in the we right now. How do you get it to open the map when you hit test map? it just opens straight to the main menu.
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Oh, dude, that's easy, and I'll tell you how to make your own, too. Use this link or just type a google search for "Hex converter". You can use this to translate a 255-based color code to hex, or you can experiment and make your own. You can open an image editor, type in the code, and view the color.

All you have to do, once you find the Hex code, you add |cff as a prefix (or strip the |cff if you want to test the color). In the properly-quoted format of "|cff000000" of course.
 
It is built by the combination of two hex to form a portion of an RGB code.

|cAARRGGBB

|c - This begins the color code for text.
AA - This is the alpha of the text. However, it doesn't work so you can choose to exclude it or just put "ff" or "00" or whatever.
RR - This is the red value.
GG - This is the green value.
BB - This is the blue value.

Hexes go from 0-9 and then A-F as Bribe said. A pair of hex values (eg: 0A or F5) have a range of values from 0-255.
Code:
Full Colour Code List
---------------------------
0 = 00
1 = 01
2 = 02
3 = 03
4 = 04
5 = 05
6 = 06
7 = 07
8 = 08
9 = 09
10 = 0A
11 = 0B
12 = 0C
13 = 0D
14 = 0E
15 = 0F
16 = 10
17 = 11
18 = 12
19 = 13
20 = 14
21 = 15
22 = 16
23 = 17
24 = 18
25 = 19
26 = 1A
27 = 1B
28 = 1C
29 = 1D
30 = 1E
31 = 1F
32 = 20
33 = 21
34 = 22
35 = 23
36 = 24
37 = 25
38 = 26
39 = 27
40 = 28
41 = 29
42 = 2A
43 = 2B
44 = 2C
45 = 2D
46 = 2E
47 = 2F
48 = 30
49 = 31
50 = 32
51 = 33
52 = 34
53 = 35
54 = 36
55 = 37
56 = 38
57 = 39
58 = 3A
59 = 3B
60 = 3C
61 = 3D
62 = 3E
63 = 3F
64 = 40
65 = 41
66 = 42
67 = 43
68 = 44
69 = 45
70 = 46
71 = 47
72 = 48
73 = 49
74 = 4A
75 = 4B
76 = 4C
77 = 4D
78 = 4E
79 = 4F
80 = 50
81 = 51
82 = 52
83 = 53
84 = 54
85 = 55
86 = 56
87 = 57
88 = 58
89 = 59
90 = 5A
91 = 5B
92 = 5C
93 = 5D
94 = 5E
95 = 5F
96 = 60
97 = 61
98 = 62
99 = 63
100 = 64
101 = 65
102 = 66
103 = 67
104 = 68
105 = 69
106 = 6A
107 = 6B
108 = 6C
109 = 6D
110 = 6E
111 = 6F
112 = 70
113 = 71
114 = 72
115 = 73
116 = 74
117 = 75
118 = 76
119 = 77
120 = 78
121 = 79
122 = 7A
123 = 7B
124 = 7C
125 = 7D
126 = 7E
127 = 7F
128 = 80
129 = 81
130 = 82
131 = 83
132 = 84
133 = 85
134 = 86
135 = 87
136 = 88
137 = 89
138 = 8A
139 = 8B
140 = 8C
141 = 8D
142 = 8E
143 = 8F
144 = 90
145 = 91
146 = 92
147 = 93
148 = 94
149 = 95
150 = 96
151 = 97
152 = 98
153 = 99
154 = 9A
155 = 9B
156 = 9C
157 = 9D
158 = 9E
159 = 9F
160 = A0
161 = A1
162 = A2
163 = A3
164 = A4
165 = A5
166 = A6
167 = A7
168 = A8
169 = A9
170 = AA
171 = AB
172 = AC
173 = AD
174 = AE
175 = AF
176 = B0
177 = B1
178 = B2
179 = B3
180 = B4
181 = B5
182 = B6
183 = B7
184 = B8
185 = B9
186 = BA
187 = BB
188 = BC
189 = BD
190 = BE
191 = BF
192 = C0
193 = C1
194 = C2
195 = C3
196 = C4
197 = C5
198 = C6
199 = C7
200 = C8
201 = C9
202 = CA
203 = CB
204 = CC
205 = CD
206 = CE
207 = CF
208 = D0
209 = D1
210 = D2
211 = D3
212 = D4
213 = D5
214 = D6
215 = D7
216 = D8
217 = D9
218 = DA
219 = DB
220 = DC
221 = DD
222 = DE
223 = DF
224 = E0
225 = E1
226 = E2
227 = E3
228 = E4
229 = E5
230 = E6
231 = E7
232 = E8
233 = E9
234 = EA
235 = EB
236 = EC
237 = ED
238 = EE
239 = EF
240 = F0
241 = F1
242 = F2
243 = F3
244 = F4
245 = F5
246 = F6
247 = F7
248 = F8
249 = F9
250 = FA
251 = FB
252 = FC
253 = FD
254 = FE
255 = FF
---------------------------

Leaning toward 0 means less of that color, and leaning toward 255 means a lot of that color. You don't need to go through this though unless you really want to, there are a lot of converters for color -> hex, just search in google.

EDIT: Like this: http://www.allprofitallfree.com/color-wheel2.html
 
Level 5
Joined
Nov 22, 2009
Messages
181
what is alpha? for the declaration for the color code is that an L or some other symbol?
So if i wanted to get just a plain red i would put lc00ff0000?
 

Cokemonkey11

Spell Reviewer
Level 29
Joined
May 9, 2006
Messages
3,534
Q1: Transparency (don't remember if FF is invisible or if 00 is invisible)
Q2: No, you just ignore that part and put 00 or FF or something in its place.
Q3: Exactly.

FF is fully opaque, 00 is fully transparent, however these values don't actually do anything in many cases (ie game messages)
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
GetLocalPlayer() is very sensitive and should be used with extreme caution. It physically gets each actual person's computer so that you can do things like play a sound for a specific person, or set a variable for a specific person, and my grandpa just sat down and farted.

You can view a great tutorial regarding local players here: http://www.hiveworkshop.com/forums/jass-ai-scripts-tutorials-280/using-getlocalplayer-59368/

Red/Green/Blue, in that order. Red/Yellow/Blue are primary colours, however every colour mixer, including party-lights, use red/green/blue, and the reasoning behind it has something to do with how the human eye perceives colours.
 
Status
Not open for further replies.
Top