jass function

dansam92

New Member
Reaction score
1
i coded my own out of combat sys.
37936446.jpg

this is outline of my triggers.

this is a function includeded in out of combat trigger.
26264989.jpg

the function works well and there is no prob.

but
when i use the function in another trigger(brush check) like below,
91692478.jpg

map crashed.

wht can i do?
can't i use a function in one trigger in another trigger?
 

Komaqtion

You can change this now in User CP.
Reaction score
469
can't i use a function in one trigger in another trigger?

No...
You need to move that function into the "Map Header" (The thing at the top of the triggers-list, with the map's name on it ;)) then just call it in both the other triggers ;)
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
No...
You need to move that function into the "Map Header" (The thing at the top of the triggers-list, with the map's name on it ;)) then just call it in both the other triggers ;)

Well, not necessarily. =P As long as one trigger is above the other, its functions can be called by the trigger below. (As long as they aren't private) =)

Anyway, is it only when you add that function? If you are testing it online, this might cause a desync:
JASS:
function brush_check_f takes nothing returns boolean
    local unit cast = udg_brush_unit
    local unit tar = GetFilterUnit()
    local string p = ""
    local effect eff
    if GetUnitDistance(cast,tar) <= 300. and IsUnitType(tar,UNIT_TYPE_STRUCTURE) != true then
        if GetUnitAbilityLevel(cast,'Agho') > 0 then
            if GetLocalPlayer() != GetOwningPlayer(cast) then
                set p = "Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl"
            endif
        endif


It causes the string table to be unsynced if that was used for the first time:
JASS:
    local string p = "Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl" 
//Change it to this


Change the local player block to this:
JASS:
            if GetLocalPlayer() != GetOwningPlayer(cast) then
    set p = ""
endif
//change it to this as well


Also, does the function work fine normally? (Without crashing) Does it crash if you set some other unit in combat other than "cast"?

Btw, you can post your codes in [noparse]
JASS:
[/noparse] tags, since it makes it easier for us to edit your code.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
> can't i use a function in one trigger in another trigger?

Use a library. :p
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Use scope and libraries for your codes.

Here's a template:
Trigger 1 (convert to custom text, then paste this)
JASS:

library MyFunctions initializer Init

    globals
        // globals go here, if only used inside library, make 'em private
    endglobals

    private function PrivateFunctionality takes nothing returns nothing
        // Only used by this library
    endfunction

    function PubliclyUsableFunction takes nothing returns nothing
        // Publicly available
        // Example: IsUnitInCombat takes unit u returns boolean
    endfunction


    // ==================================================
    // Initalizer
    private function Init takes nothing returns nothing
        // Initialize some globals/triggers/units/etc... here
    endfunction
endlibrary


Trigger 2 (convert to custom text, then paste this)
JASS:

library SomeSpell initializer Init requires MyFunctions
    // Spell stuff here

    // ==================================================
    // Initalizer
    private function Init takes nothing returns nothing
        // Initialize some globals/triggers/units/etc... here
    endfunction
endlibrary
 

dansam92

New Member
Reaction score
1
whereas now im using JNGP, my jass helper is not working...
so i cnt use library or scope...

PurgeandFire//
i tested before, it was fine. (no desync)
but i should change into what u said for a safety. :)
thx for ur advice.
next time, i will post my code with
JASS:
.

i change the trigger into local trigger, then i can call one trigger's functions in another.
here is my code to check combat status. there is any leaks or something else i should edit?
<div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code"><div class="bbCodeBlock-title">JASS:</div><div class="bbCodeBlock-content"><pre class="bbCodeCode"><code class="jass"><span class="keyword">function</span> <span>GetUnitCombatState</span> <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/unit" class="type">unit</a> <span>u</span> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/boolean" class="type">boolean</a>
    <span class="keyword">return</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/LoadTimerHandle" class="native">LoadTimerHandle</a><span class="symbol">(</span><span>udg_hash</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>u</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span>&<span>quot</span>;<span>ooc_t</span>&<span>quot</span>;<span class="symbol">)</span><span class="symbol">)</span><span class="symbol">=</span><span class="symbol">=</span><span class="value">null</span>
<span class="keyword">endfunction</span>

<span class="keyword">function</span> <span>EndCombat</span> <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a>
    <span class="keyword">local</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/timer" class="type">timer</a> <span>t</span><span class="symbol">=</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetExpiredTimer" class="native">GetExpiredTimer</a><span class="symbol">(</span><span class="symbol">)</span>
    <span class="keyword">local</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/unit" class="type">unit</a> <span>u</span><span class="symbol">=</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/LoadUnitHandle" class="native">LoadUnitHandle</a><span class="symbol">(</span><span>udg_hash</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>t</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span>&<span>quot</span>;<span>ooc_u</span>&<span>quot</span>;<span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/FlushChildHashtable" class="native">FlushChildHashtable</a><span class="symbol">(</span><span>udg_hash</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>u</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/FlushChildHashtable" class="native">FlushChildHashtable</a><span class="symbol">(</span><span>udg_hash</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>t</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/PauseTimer" class="native">PauseTimer</a><span class="symbol">(</span><span>t</span><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/DestroyTimer" class="native">DestroyTimer</a><span class="symbol">(</span><span>t</span><span class="symbol">)</span>
    <span class="keyword">set</span> <span>t</span><span class="symbol">=</span><span class="value">null</span>
<span class="keyword">endfunction</span>

<span class="keyword">function</span> <span>SetUnitInCombat</span> <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/unit" class="type">unit</a> <span>u</span> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a>
    <span class="keyword">local</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/timer" class="type">timer</a> <span>t</span><span class="symbol">=</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/LoadTimerHandle" class="native">LoadTimerHandle</a><span class="symbol">(</span><span>udg_hash</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>u</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span>&<span>quot</span>;<span>ooc_t</span>&<span>quot</span>;<span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">if</span> <span>t</span><span class="symbol">=</span><span class="symbol">=</span><span class="value">null</span> <span class="keyword">then</span>
        <span class="keyword">set</span> <span>t</span><span class="symbol">=</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/CreateTimer" class="native">CreateTimer</a><span class="symbol">(</span><span class="symbol">)</span>
        <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/SaveTimerHandle" class="native">SaveTimerHandle</a><span class="symbol">(</span><span>udg_hash</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>u</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span>&<span>quot</span>;<span>ooc_t</span>&<span>quot</span>;<span class="symbol">)</span><span class="symbol">,</span><span>t</span><span class="symbol">)</span>
    <span class="keyword">endif</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/SaveUnitHandle" class="native">SaveUnitHandle</a><span class="symbol">(</span><span>udg_hash</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>t</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span>&<span>quot</span>;<span>ooc_u</span>&<span>quot</span>;<span class="symbol">)</span><span class="symbol">,</span><span>u</span><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/TimerStart" class="native">TimerStart</a><span class="symbol">(</span><span>t</span><span class="symbol">,</span><span>udg_ooc_dur</span><span class="symbol">,</span><span class="value">false</span><span class="symbol">,</span><span class="keyword">function</span> <span>EndCombat</span><span class="symbol">)</span>
    <span class="keyword">set</span> <span>t</span><span class="symbol">=</span><span class="value">null</span>
<span class="keyword">endfunction</span>

<span class="keyword">function</span> <span>OOC_Conditions</span> <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/boolean" class="type">boolean</a>
    <span class="keyword">return</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/IsUnitType" class="native">IsUnitType</a><span class="symbol">(</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetTriggerUnit" class="native">GetTriggerUnit</a><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/UNIT_TYPE_HERO" class="variable">UNIT_TYPE_HERO</a><span class="symbol">)</span> <span class="symbol">=</span><span class="symbol">=</span> <span class="value">true</span> <span class="keyword">or</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/IsUnitType" class="native">IsUnitType</a><span class="symbol">(</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetAttacker" class="native">GetAttacker</a><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/UNIT_TYPE_HERO" class="variable">UNIT_TYPE_HERO</a><span class="symbol">)</span> <span class="symbol">=</span><span class="symbol">=</span> <span class="value">true</span> <span class="keyword">or</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/IsUnitType" class="native">IsUnitType</a><span class="symbol">(</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetSpellTargetUnit" class="native">GetSpellTargetUnit</a><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/UNIT_TYPE_HERO" class="variable">UNIT_TYPE_HERO</a><span class="symbol">)</span> <span class="symbol">=</span><span class="symbol">=</span> <span class="value">true</span>
<span class="keyword">endfunction</span>

<span class="keyword">function</span> <span>OOC_Actions</span> <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a>
    <span class="keyword">local</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/unit" class="type">unit</a> <span>tar</span> <span class="symbol">=</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/GetAttacker" class="native">GetAttacker</a><span class="symbol">(</span><span class="symbol">)</span>
    <span class="keyword">local</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/unit" class="type">unit</a> <span>temp</span> <span class="symbol">=</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/GetSpellTargetUnit" class="native">GetSpellTargetUnit</a><span class="symbol">(</span><span class="symbol">)</span>
    <span class="keyword">call</span> <span>SetUnitInCombat</span><span class="symbol">(</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetTriggerUnit" class="native">GetTriggerUnit</a><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">if</span> <span>tar</span> <span class="symbol">!=</span> <span class="value">null</span> <span class="keyword">then</span>
        <span class="keyword">call</span> <span>SetUnitInCombat</span><span class="symbol">(</span><span>tar</span><span class="symbol">)</span>
    <span class="keyword">elseif</span> <span>temp</span> <span class="symbol">!=</span> <span class="value">null</span> <span class="keyword">then</span>
        <span class="keyword">call</span> <span>SetUnitInCombat</span><span class="symbol">(</span><span>temp</span><span class="symbol">)</span>
    <span class="keyword">endif</span>
    <span class="keyword">set</span> <span>tar</span> <span class="symbol">=</span> <span class="value">null</span>
    <span class="keyword">set</span> <span>temp</span> <span class="symbol">=</span> <span class="value">null</span>
<span class="keyword">endfunction</span>

<span class="comment">//======================================================</span>
<span class="keyword">function</span> <span>InitTrig_out_of_combat</span> <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a>
    <span class="keyword">local</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/trigger" class="type">trigger</a> <span>t</span> <span class="symbol">=</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/CreateTrigger" class="native">CreateTrigger</a><span class="symbol">(</span><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/Blizzard.j/TriggerRegisterAnyUnitEventBJ" class="function">TriggerRegisterAnyUnitEventBJ</a><span class="symbol">(</span><span>t</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/EVENT_PLAYER_UNIT_ATTACKED" class="variable">EVENT_PLAYER_UNIT_ATTACKED</a><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/Blizzard.j/TriggerRegisterAnyUnitEventBJ" class="function">TriggerRegisterAnyUnitEventBJ</a><span class="symbol">(</span><span>t</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/EVENT_PLAYER_UNIT_SPELL_EFFECT" class="variable">EVENT_PLAYER_UNIT_SPELL_EFFECT</a><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/TriggerAddCondition" class="native">TriggerAddCondition</a><span class="symbol">(</span><span>t</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/Condition" class="native">Condition</a><span class="symbol">(</span><span class="keyword">function</span> <span>OOC_Conditions</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/TriggerAddAction" class="native">TriggerAddAction</a><span class="symbol">(</span><span>t</span><span class="symbol">,</span><span class="keyword">function</span> <span>OOC_Actions</span><span class="symbol">)</span>
<span class="keyword">endfunction</span></code></pre></div></div>
and in this case, local trigger can leaks?

ps: based on Darthfett&#039;s vjass code. <a href="http://www.thehelper.net/forums/showthread.php?t=91529" class="link link--internal">http://www.thehelper.net/forums/showthread.php?t=91529</a>
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
whereas now im using JNGP, my jass helper is not working...
... Why?
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top