1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Essentials Tutorial

Discussion in 'Trigger (GUI) Editor Tutorials' started by Deuterium, Aug 22, 2009.

  1. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,101
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Why is DT_Index and array. You only ever use it statically so for efficency it should be 3 different variables.

    DT_Index[1] = one
    DT_Index[2] = two
    DT_Index[3] = three
     
  2. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Oh, well if it is more efficient, then yeah sure :) I'll keep that in mind for next update...
     
  3. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Hotfix:
    - Edited: I - 3. Multi Unit Instanceability (MUI)
    - Edited: I - 4 - e. Avoiding the usage of Do nothing
    - Edited: i - 4 - g. Avoiding the usage of Index A (or Index B)

    Hopefully by now I have the major issues fixed.
    Advice on how-to-improve is always welcome :)
     
  4. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    If you're not using wait actions inside the loop you can recycle the variables, this including Integer A and Integer B. Thus, like I said, if you don't use wait actions inside loops, the only reason you would need to use an integer C is when you need a triple nested loop. For everything else, Integer A and Integer B should be sufficient.

    In fact, if you're using wait actions inside loops, using different variables for different triggers will still not be sufficient.
     
  5. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    I must say you're wrong. Go a few posts up, baassee quotes what the issue is...
     
  6. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    There are actions that cause a thread to stop executing while it waits for something else to finish executing. In these cases another thread can interrupt a loop and cause global variable value corruption if you're not careful. For example, UnitDamageTarget() will cause the current thread to block until the damage is dealt, and any threads run by a trigger responding to EVENT_UNIT_DAMAGED will execute while the first thread waits. So you don't necessarily need to explicitly use waits for threads to interrupt one another.
     
  7. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Uh, sure, but he doesn't say how to detect bugs like that. He just says to use different variables for each loop you have, and honestly that's just idiot. Especially when bugs like this happen in maybe 2% of the triggers you have.
     
  8. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    What's wrong with using different variables for each loop?

    It's the GUI equivalent of doing:

    Code (vJASS):

    local integer i = 0
    loop
        exitwhen (i > 100)
        set i = i + 1
    endloop
     


    I'm pretty sure no JASS user would go through the trouble of using only one or two globals in every loop they had just because it PROBABLY wouldn't screw up. So why should GUI users do the same?
     
  9. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Those are local variables. Creating a separate global variable for each iterator is just going to explode your variablelist when you don't have to. And the GUI variable list is already ugly.
     
  10. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    @ Eleandor:
    First of all I said generally what the problem is:
    And as you see, since I thought what I said wasn't clear enough, I quoted PP. I didn't go deep into details, 'cause I know that doing so would simply confuse the users.

    And why would they need to detect it when I already told them to avoid those integers?

    Oh really?

    It's a bug nevertheless.

    Well, once a global is indexed, it functions in a common manner to a local variable, except much less efficient. And also a trigger would intercept it's own actions, so even if the global isn't indexed and the spell is instant, as long as it's unique for that trigger, it's safe.

    One of the burden's of using GUI.


    @ aznricepuff:
    Thanks for the support :)
     
  11. Dj0z

    Dj0z

    Joined:
    Oct 16, 2008
    Messages:
    509
    Resources:
    5
    Skins:
    1
    Maps:
    4
    Resources:
    5
    About: "Avoiding the usage of Index A (or Index B)"

    'Kay i've read all the posts dealing with that in this thread, and i was extremely surprised to learn that a trigger can pause the execution of another one and overwrite "Integer A" inside itself, before re-enabling the first trigger to go on o_O

    At first i thought it was b*llshit to be honest. Fact is, i have a whole map with billions of executions of loops including integer A's and B's. They include absolutely no "waits" of any sort, so until now, i assumed they were completely safe.
    I very rarely experience weird bugs with that map, such as the complete unability to build anything for a player, or things not happening for some weird obscure reason.

    If that issue with those preset integers happens to be the reason, Man you deserve a medal. Actually, just for the sake of this fact being true, you already do. Wait, not only you, the people who found this out also do.
    But that's one helluva stealth problem we got there, further decreasing my trust in GUI, and you were the one to get this tutorial in here, in such a neat and reader-friendly manner. +rep.
     
  12. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Oh, sure but rather than getting into more specific details on how you know if your loop will cause trouble, you just tell people to use different variables anyway? I don't see much tutoring in this part of the tutorial.

    Here's why:
    • Test
    • Events
      • A player skips a cinematic
      • Unit - a unit enters playable map area
    • Conditions
      • SomeInt less than 100
    • Actions
      • for Integer C from 1 to 10 do
        • Unit - create a unit of type UnitArray[Integer C] at center of playable map area
        • set SomeInt = SomeInt + 1

    They're avoiding Integer A and Integer B, yet I doubt that they expect this trigger to behave like it does.
    What they probably wanted to do is something like waves of units with an equal spreading of the unit types, and a maximum unitcount of 100

    But not a bug with Integer A or Integer B. It's a bug in their own code, and you're not telling them how they can write good code.

    No, see the example trigger I gave. If the looping variable would have been local there would be no problem at all.

    Hell, if you have lots of loops I really think using Integer A and Integer B is a lot better than creating a different variable.
     
  13. reason 3

    reason 3

    Joined:
    Aug 11, 2009
    Messages:
    1,549
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    Why most of you guys dislike GUI?In every chance you are given you mention it isn't good/usefull and etc...Using jass i guess you can make everything but...the 95% of them can also be made in GUI +custom texts.
    For me and many other users that don't want or don't have time to go through the process to learn jass,GUI has never let me down until now.(except 1 time when i was making a spell and i wanted to toss enemy untis in the air )
     
    Last edited: Sep 1, 2009
  14. TheBlooddancer

    TheBlooddancer

    Joined:
    Jun 24, 2008
    Messages:
    2,908
    Resources:
    0
    Resources:
    0
    Now you just have to time travel back to when i started, posted this, and aquire profit and delicious cake.

    Oh, and in 'How not to use wait, a-example' aren't you making it wait 1 second, instead of 0.1?
     
  15. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    @ Eleandor:
    No offense - and I thank you for your opinions - but apparently it's only you who find a problem with that section, although I believe it's fine since it contains the explanation of what the problem is and how to fix it. And the explanation is just at the right dose for a beginner GUI user. I might have to add an example or two, but I'll do so once I'm in a "coding" mood :)P). Anyways, I'll ask some people to check it out, and if anyone finds it's lacking, I'll see how I could improve it.

    Again, thanks!

    @ TBD:
    Well the wait is in a loop which runs ten times. It waits 0.1 sec. every instance, summing up to 1 seconds. I think it's right unless I missed your point. Did I?

    @ Dj0z:
    Glad you learnt that!

    @ reason 3:
    GUI does suck, but it's not forbidden :p
     
  16. reason 3

    reason 3

    Joined:
    Aug 11, 2009
    Messages:
    1,549
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    Can you tell me why GUI sucks?Give me an example of jass that cannot be done in GUI...
     
  17. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Don't turn this tutorial into a jass vs gui thread please, you'll lose anyway. Check out the warcraft 3 forum for such a topic.
     
  18. reason 3

    reason 3

    Joined:
    Aug 11, 2009
    Messages:
    1,549
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    Sry about it Eleandor i wasn't going to turn this into a GUI vs Jass thread,and yes i know with jass there are more possibilities and the code is also faster...i know all these.My point was just to prove you that GUI isn't "sucking"!
     
  19. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Thank you :)
     
  20. Vulcano

    Vulcano

    Joined:
    Mar 8, 2009
    Messages:
    335
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Nice tutorial, although i'll stay to vJASS :p.

    I have another reason why to save GetBlaUnit in variable. They bug when they are used in a function that is not called by the "event trigger", even when there are no waits and it happens with GetTriggerUnit too. Because of that you can't use GetBlaUnit in loops because GUI loops are run in another function.

    Here is the thread in which i found out this problem.