• 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.

Using Custom Script As A Condition

Status
Not open for further replies.
Level 14
Joined
Nov 30, 2013
Messages
926
Something like this maybe?
  • Custom Script /w Conditions
    • Events
    • Conditions
    • Actions
      • Custom script: if (GetTriggerUnit() == "What Unit") then
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Custom script: else
      • Unit - Create 1 Rifleman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Custom script: endif
 
You know, "leave JASS out of this" kind of refuses any kind of help, when you say you want to use custom script.
Custom script requires to write your own statements, might it be an If/Then/Else, or anything else. You need to use JASS directly.

bear_369 wrote a unit comparison example.

If then else structure/lines:

Code:
(required)
if + boolean(-expression) + then 

    code


(optional)
else

    code


(optional)
elseif + boolean(-expression)

    code


(required)
endif

The boolean thing must be something is true or false.
If it is true, it will run the next code block, if false, not.

One can directly write true or false,
but you may want to use comparisons that will result in true or.
So maybe something like ( x == 3) or (GetTriggerUnit == Hero[³])

To know what kind of code to write in you might write your condition in GUI,
then to convert the trigger to CustomText and then you might extraxt the info of the JASS code and use it in your own.

You can optionaly use else and elseif lines if you need them. As shown about you need expliccitly to write it,
and it doesnt come by alone like in GUI.

The "code" itself can be GUI or also custom scrip, or a mix. It wont matter in this case.
 
Last edited:
It's the same as previously shown, but you add and between each condition. If you have a lot it can get pretty long, though, and WE will crash. For example:

  • Custom script: if (GetTriggerUnit() == 'hfoo') and UnitAlive(GetTriggerUnit()) then
  • -------- Your Actions Here --------
  • Custom script: endif
 
tumblr_m6uj6jh6NH1rxm1ywo1_400.gif


It would seems you misunderstood me (again).I need a Multiple Or custom script condition.Not an And Condition.Plus,the one you gave me is not a multiple condition.
 
Level 14
Joined
Nov 30, 2013
Messages
926
  • Custom script: if (Condition1) or (Condition2) then
  • -------- Your Actions here --------
  • Custom script: elseif (Condition3) or (Condition4) then
  • -------- Your Actions here --------
  • Custom script: endif
  • -------- Or this?? --------
  • Custom script: if (Condition1) or (Condition2) or (Condition3) then //I'm not sure if this actually worked since I haven't tested on this one.
  • -------- Your Actions here --------
  • Custom script: endif
Is this it?
 
But I need to know if its possible to create multiple or custom script conditions.
Well that was very ambiguously worded. Could be taken in 2 ways, not to mention you tend to phrases your questions in rather ambiguous ways to begin with :p

Juts replace and with or

EDIT: looks like bear_369 gotchu :p
 
  • Custom script: if (Condition1) or (Condition2) then
  • -------- Your Actions here --------
  • Custom script: elseif (Condition3) or (Condition4) then
  • -------- Your Actions here --------
  • Custom script: endif
  • -------- Or this?? --------
  • Custom script: if (Condition1) or (Condition2) or (Condition3) then //I'm not sure if this actually worked since I haven't tested on this one.
  • -------- Your Actions here --------
  • Custom script: endif
Is this it?

Yes,like that.But,I need all the conditions to do the same actions.I don't wanna use way too long triggers.

Well that was very ambiguously worded. Could be taken in 2 ways, not to mention you tend to phrases your questions in rather ambiguous ways to begin with :p

Juts replace and with or

EDIT: looks like bear_369 gotchu :p

Uuhuuh
 
Level 14
Joined
Nov 30, 2013
Messages
926
Yes,like that.But,I need all the conditions to do the same actions.I don't wanna use way too long triggers.

What do you mean you need all the conditions to do the same actions?
You confused me there. :l

Since I got confused by your question, I kinda try this out if this what you mean.
  • Custom script: local boolean b = false
  • Custom script: if (b == false) and (Condition1) then
  • Custom script: set b = true
  • Custom script: endif
  • Custom script: if (b == false) and (Condition2) then
  • Custom script: set b = true
  • Custom script: endif
  • Custom script: if (b == false) and (Condition3) or (Condition4) then
  • Custom script: set b = true
  • Custom script: endif
  • Custom script: if (b == false) and (Condition5) or (Condition6) or (Condition7) then
  • Custom script: set b = true
  • Custom script: endif
  • Custom script: if (b == true) then
    • -------- Your Actions here --------
  • Custom script: endif
 
No,that's not what I need,but thanks for trying. :\
I'll make it more clearly:
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • (Unit-type of (Constructed structure)) Equal to Building1
        • (Unit-type of (Constructed structure)) Equal to Building2
        • (Unit-type of (Constructed structure)) Equal to Building3
        • (Unit-type of (Constructed structure)) Equal to Building4
        • (Unit-type of (Constructed structure)) Equal to Building5
        • (Unit-type of (Constructed structure)) Equal to Building6
        • (Unit-type of (Constructed structure)) Equal to Building7
        • (Unit-type of (Constructed structure)) Equal to Building8
  • Actions
    • Unit - Add a 0.01 second Generic expiration timer to unit
So simply,it's all a different condition,but will still end up with the same actions and it saves room.This is all that I ever needed except with a custom script OrderID condition.
 
Level 14
Joined
Nov 30, 2013
Messages
926
Can you do Jass stuff? If so, you can create a function at the "Custom Script Code" and do this.

Example, if you want to do something about the constructed unit.
JASS:
function IsVarTrue takes unit u returns boolean
    if ((Condition1(u)) or (Condition2(u)) ) then
        return true
    elseif ((Condition3(u)) or (Condition4(u)) or (Condition5(u)) ) then
        return true
    //And so on
    endif
    return false
endfunction
  • Custom script: local boolean b = IsVarTrue(GetConstructedUnit())
  • Custom script: if (b == true) then
  • -------- Your actions here --------
  • Custom script: endif
If you're only do GUI triggers, you can sometimes do this.
  • -------- Some pratically bad If/Or statements.. --------
  • Custom script: if (Condition1) or (Condition2) or (Condition3) *and so on* then
  • -------- Your actions here --------
  • Custom script: endif
Although that's pretty much expands the *width scrolling* of the Trigger Editor, it might come in handy. Well probably...

So far I know, shortening a huge amount of conditions of a single trigger would be only useful for Jass.
 
  • Derp
    • Events
    • Conditions
      • -------- You cannot put Custom Scripts here in GUI, forget this block ---------
    • Actions
      • Custom script: if OrderID == (integer1) or OrderID == (integer2) or OrderID == (integer3) or then
      • -------- Actions --------
      • Custom script: endif
if you have JNGP, then you can line break with this /* */
  • Derp
    • Events
    • Conditions
    • Actions
      • Custom script: if OrderID == (integer1) or /*
      • Custom script: */ OrderID == (integer1) or /*
      • Custom script: */ OrderID == (integer1) /*
      • Custom script: */ then
      • -------- Actions --------
      • Custom script: endif
Does look kinda silly in GUI, but at least each condition can be separated with a line break.
 
Status
Not open for further replies.
Top