HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Loops, Locals, and Trigger Executes

11-09-2007, 04:43 PM#1
MrApples
Alright, i've been working on something I call the 'Risk Engine'. It's GUI based for now, and i've been running into some crazy bugs, so I have a couple questions on gui loops and stuff. It would be greatly appreciated if someone would help me out here, I would really like to fix this bug.

I've created 3 global integer variables, and I used those in place of (For Each Integer A).
  • So would any problems be caused by this below?
    Code:
    NOTE: This is the For Each Integer Variable action. Not For A.
    For Each Integer a from 1 to variable
       For Each Integer b from 1 to variable
          Do stuff with vars[b] and vars[a]
       For Each Integer b from 1 to variable
          Do stuff with vars[b] and vars[a]
  • If That is ok, what if I added this before it (to make it faster)? When I did this it caused a crash, so I'm asking in theory.
    Code:
    local integer udg_a = 0
    local integer udg_b = 0
    local integer udg_c = 0
  • If I did something with the global a afterwards, would it be set to the last loop?

  • And, if I were to conditionally execute a bunch of triggers in a row which all contain loops like this, but with no waits, would they conflict?

  • If a trigger is conditionally executed, and it has waits, does the host trigger(the one that executed it) wait for it to continue?

  • What can cause a defective variable? (A variable that is still registered/in code, but if looked up in the variable editor it has no type, yes this does happen)

If anyone has read this far, thanks for paying this much attention to it. I can't post the actual code because it is far too long/complex.
11-09-2007, 07:06 PM#2
Av3n
you forgot

Code:
local integer array udg_a
local integer array udg_b
local integer array udg_c
you are making non array values when your trigger requries array values.

Also making loops within loops are ok.
The global if changed would effect the current loop (depending if you have waits)

-Av3n
11-09-2007, 07:23 PM#3
MrApples
They are not arrays... [a], not a[].
11-10-2007, 06:01 PM#4
legend_tisman
perhaps it is because you are doing this...

local integer udg_a = 0

local means local variable
udg means user defined global

set udg_a = 0 ?
11-10-2007, 06:33 PM#5
cohadar
offtopic:

Trigger tags are your friends:
Trigger:
ClearVision
Collapse Events
Map initialization
Conditions
Collapse Actions
Visibility - Disable fog of war
Visibility - Disable black mask
11-10-2007, 07:07 PM#6
Salbrismind
Quote:
Originally Posted by legend_tisman
perhaps it is because you are doing this...

local integer udg_a = 0

local means local variable
udg means user defined global

set udg_a = 0 ?

Legend gots the idea. Just use "set udg_a = 0".

To answer your questions:
I know nothing of trigger excution, I actually wanna find out something similar.
But for loops, as long as you don't put wait in or something, and as long as you don't have the same loop running at the same or within the same loop then your okay with them.

loop b - 1
loop b - 1
code...

this would cause problems
11-10-2007, 11:52 PM#7
MrApples
Quote:
udg means user defined global
Means that, but by no means makes it so. Heard of ghost variables?

Quote:
Trigger tags are your friends
That's a writeup, not a trigger.

This seems to be causing confusion, sorry about that, i've solved the problem since though. One extra line of code... 3 hours of searching for one extra line of code.
11-11-2007, 12:13 AM#8
legend_tisman
@mrapples "Heard of ghost variables?"
nope, care to give a simple explaination?

@cohadar "Trigger tags are your friends:"
How about you make some pseudo code tags?
[pseudo] ftw [/pseudo]
11-11-2007, 12:56 AM#9
Pyrogasm
Quote:
Originally Posted by legend_tisman
How about you make some pseudo code tags?
[pseudo] ftw [/pseudo]
What would be the point? You could do this instead:
[code=Pseudo Code]Code Here[/code]
11-11-2007, 03:32 AM#10
MrApples
>nope, care to give a simple explaination?

Woops, ghost variables are using locals in GUI.

Code:
Custom Script: local integer udg_integervariable

If you put that at the top of a GUI trigger, the 'integervariable' variable would now be local. I know i've seen people use it, but it caused my system to crash.