Debug this simple JASS code so it works OR Suggest a solution to my problem

Nogusta

New Member
Reaction score
1
My third and final question in the set:
How Do I Attach Item Tables to Newly Created Units?
and
When This Unit Dies Game Crashes. Why?

Well here goes:

Hey guys, let me tell you this one is pretty complicated and annoying, I suspect no one but Darg himself could figure it out:

I'm attempting to make a code that destroys the entrance and exit you could say, of any pair of waygates in which one of the waygates dies. (The gates are NOT pre-placed and are vulnerable to regular attacks.)

Here is a slightly bugged code I am trying to use:

Code

function your_trigger_actions takes nothing returns nothing
local unit u = GetDyingUnit()
local integer i = 0
loop
exitwhen ( GetBooleanOr( udg_WaygateA = u, udg_WaygateB = u )) %<--Problem%
set i = ( i + 1 )
endloop
set u = null
call ExplodeUnitBJ( udg_WaygateA )
call ExplodeUnitBJ( udg_WaygateB )
endfunction

For some reason WE says that it has an error and says it's expecting a "==" in the line indicated above.

But skipping over that let me tell you something about this code. It uses two global arrays of size 100. Another trigger not stated here stores a number of waygates within both arrays.

%%%%%The Problem I'm Trying to Solve%%%%%

You see the players can build an undetermined amount of waygates in this map. When a waygate finishes construction then a sister waygate will be created via triggers and automatically link up with the built one.

When this occurs the built waygate will also be stored within the index of the array 'WaygateA' and the sister waygate will be stored within the index of the array 'WaygateB'.

Making this even more complicated is the fact that a counter is attached to the indexes of the arrays. Every time a pair of waygates are stored within the pair of arrays the counter will go up by 1 so the next pair of waygates will be stored in the next entry of their corresponding arrays all the way up to 100.

This system makes sure that built and sister waygates all have the same index number in the two arrays so they can be used in the code above.

(Takes a breath) Finally, the code above simply makes it so when a unit dies the trigger will check for whether the dying unit was a waygate stored within either array and if it was attempt to destroy any waygate with the corresponding index number of the dying waygate therefore destroying both the built and sister waygates.

However of course... it doesn't do so for a reason that is beyond me. In fact I believe the loop in the code above may never even exit. But I am unfortunately fairly new at JASS and pretty nasty with its syntax.

Well the bottom line is: A little help guys?
 
I'd say it's a little more complicated then that. I previously used double equal signs and WE said it was alright. However it did say I needed something like "init(Trigger Name) function" or something. I think this is because I cleared all the custom script when I first converted the trigger in the first place.

So I remade the trigger and didn't clear all the JASS script already there. I just simply substituted my revised code:

Code

function your_trigger_actions takes nothing returns nothing
local unit u = GetDyingUnit()
local integer i = 0
loop
exitwhen ( GetBooleanOr( udg_WaygateA == u, udg_WaygateB == u ))
set i = ( i + 1 )
endloop
set u = null
call ExplodeUnitBJ( udg_WaygateA )
call ExplodeUnitBJ( udg_WaygateB )
endfunction

If my programming knowledge is correct this should accomplish what's described in my first post but it just doesn't, unless I still did something wrong with that initialize function I mentioned earlier even though WE didn't disable the trigger. I'm sure every trigger in accordance with this script is correct. The only thing that isn't correct is this script itself. Maybe I just need a whole new script, but I can't think of one.

If you read my problem it says I want it so when a waygate gets killed the waygate its connected to gets killed. I tried all the stuff I said above even before submitting this thread.

Basically the result of this script that I get is: When I try killing a waygate in game, it just dies and its sister waygate doesn't.

I'm really missing something here.
 
Yeah, in every trigger theres a function that actually creates it and adds the events, conditions and actions to it.

You can do it yourself too, like this:
Code:
function initTrig_mytrigname takes nothing returns nothing
    set gg_trg_mytrig = CreateTrigger( )
    call TriggerRegisterAnyUnitEven (UNIT_SPELL_EFFECT) //This registers a "unit starts the effect of an ability" event to the trigger.    
    call TriggerAddCondition(gg_trg_mytrig, your_trigger_condition)
    call TriggerAddAction(gg_trg_mytrig, your_trigger_actions )

Just put this at the end of your trigger.

P.S your_trigger_condition is the function used for the conditions.
 
Ugh, sorry for double post, Can't edit.

Anyways, forgot to put endfunction in it :p
 
Sorry for being a little thick here but could you re-post that end code so it actually applies to the code I posted?

My script was never made from an existing trigger, I did it from a completely blank state.
 
Oh. no problem :p

Code:
function your_trigger_actions takes nothing returns nothing
   local unit u = GetDyingUnit()
   local integer i = 0
   loop
   exitwhen ( GetBooleanOr(    udg_WaygateA[i] == u, udg_WaygateB[i] == u )) %<--Problem%
   set i = ( i + 1 )
   endloop
   set u = null
   call ExplodeUnitBJ( udg_WaygateA[i] )
   call ExplodeUnitBJ( udg_WaygateB[i] )
endfunction

//======================================
function initTrig takes nothing returns nothing
   set gg_trg_Name_Of_Trigger =        CreateTrigger()
   call TriggerRegisterEvent(   ) //Event  you desire
   call TriggerAddCondition(gg_trg_Name_Of_Trigger, your_trigger_condition)
   call TriggerAddAction(gg_trg_Name_Of_Trigger, your_trigger_actions)
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    It's an unnecessarily long and just not that good of a cord. Falls out of the little clip I put it in.
  • Varine Varine:
    And yeah I was working. It was a suprisingly good weekend, I didn't run out of anything until today and had most of resolved. I think the only thing I didn't have some solution for was halibut, but in my defense I got 45 pounds or something last Thursday. It took me like an hour and a half at the end of the night.
  • Varine Varine:
    Today I had to scramble, I didn't work most of dinner service and no one told me shit. They had a rough few hours lol
  • Varine Varine:
    I have two salmon, Sockeye and Atlantic. Atlantic is used for the kids salmon and the salmon and beet salad, and can also be added onto any dish or just as a side. Atlantic salmon will almost exclusively ever be FARMED, as it is endangered in the wild, and we ALWAYS cut them to 4 ounces.
  • Varine Varine:
    SOCKEYE salmon, very different and this IS wild caught. We have an ENTREE version, and an add on version. The entree is 7 ounces, the add on is 4. Why? Because that is how someone that wasn't me set up the computer.
  • Varine Varine:
    I had to have this conversation like ten fucking times tonight
  • Varine Varine:
    The issue being, I came into work and had none of this whatsoever
  • Varine Varine:
    No one told me shit
  • Varine Varine:
    So, taking into consideration that what I typed out up there is kind of some fucking nonsense that under normal circumstances no one really needs to fucking be able to explain in any rational way
  • Varine Varine:
    Let alone trying to figure it out from a wildly stressed out me that is also on a phone call trying to get something to show up from Seattle tomorrow while trying to explain this salmon situation, that also is barely solved in maybe a few hours and and but I am bulking it with a few steelhead filets I have and that is a WHOLE fucking different thing to the 19 year old server that got put on day shift C crew that doesn't know who I am.
  • Varine Varine:
    I did however really want days. I like getting off at 4 half the time, and that makes it worth it!
  • Varine Varine:
    Also I hate my job right now but I think that was the hard part. Now it's just work
  • Varine Varine:
    @jonas I'm sorry? I don't know what you're referring to.
  • Varine Varine:
    Once we hit winter I feel like I get to back to having a pretty cool job. Like I bitch about it all the time, but it's work. I'm still gonna bitch
  • Varine Varine:
    All in all though I think this summer is going really well. Some complicated things, but at the end of the day it isn't THAT big of a deal. Not all of our servers have quite realized they are technically sales
  • Varine Varine:
    Like yeah it is a substitute, but FOMO. Chef isn't getting this again this year, he has to figure it out, so it's slightly off on the menu, but that is more or less the LOWEST quality and price. Right now, steelhead is a real stealhear, right?
  • Varine Varine:
    Like fuck off even I can do it
  • Varine Varine:
    I am going to get one of my servers to do that in her server voice and you'll see my point
  • Varine Varine:
    Maybe the bartender. Idk, it's one of my favorite things to hear them go from calm to customer service voice. They will translate it to like "The chef is trying to change that a bit right now so he does have a Alaskan river steelhead. Yeah like the one you might fish probably!" And then the girls can bat their eyes and do pretty girl server shit
  • Varine Varine:
    At least that's how imagine some of them. Did you know mayonnaise is dairy free? A suprisingly amount of people don't\
  • The Helper The Helper:
    mayo is eggs right?
  • The Helper The Helper:
    Seems I never watched the Witcher - looks like i have a lot of content
  • The Helper The Helper:
    Season 1 Episode 8 the marathon continues...
  • jonas jonas:
    mayo is eggs & oil
    +1
  • The Helper The Helper:
    I got halfway season 2 on The Witcher and it lost me. I am going to have to pick this one up again later.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top