System Detect Resource Exchange

Troll-Brain

You can change this now in User CP.
Reaction score
85
Here is a simple and short system :

JASS:
//==============================================================================
//      DRES -> DETECT RESOURCE EXCHANGE SYSTEM -- v 2.1 // by Troll-Brain
//==============================================================================
//
//      REQUIREMENTS :
//              * The last JassHelper
//              * The library Table by Vexorian, more infos about that :
//                <a href="http://www.wc3campaigns.net/showthread.php?t=101246" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://www.wc3campaigns.net/showthread.php?t=101246</a>
//                 
//      THE GOAL :
//              * Detect when a player gives gold or wood to an allie, and ofc to know wich one is the donor, the receiver
//                and the amount of the deal.
//
//      HOW IT WORKS :
//              * It add a new TriggerRegisterPlayerStateEvent event to your trigger, for each player in the force you define
//                and also a condition because this function don&#039;t have a boolexpr parameter.
//
//      HOW TO IMPORT:
//              * Just create a trigger named DRES or whatever.
//              * Convert it to text and replace the trigger text with this one.
//              * Do the same with the library Table.
//
//      HOW TO USE IT :
//              * Read the documentation and check the example in the demo map.
//                CAREFULL, you can use all the GetLast... everywhere, but the other Get... ONLY in a trigger ACTION, NOT in a trigger CONDITION

library DRES initializer init uses Table

globals
    public constant integer GOLD = 1
    public constant integer LUMBER = 2
    private constant real MAX = 1000000.0 // you should not edit this value, because it&#039;s simply the max possible of a resource
    private constant real TIME_OUT = 1.0 // i think that&#039;s a good value, you shouldn&#039;t edit it, unless you perfectly know what you are doing
endglobals
    
globals // don&#039;t edit them
    public playerstate Ple = null
    private timer Tim = null
    private integer Count = 1
    private HandleTable GoldTable
    private HandleTable LumberTable
    private trigger Trig = null
endglobals
        
//! textmacro DRES_Resource takes TYPE , NAME
    globals
        private player $TYPE$Donor = null
        private player $TYPE$PossibleDonor = null
        private player $TYPE$Receiver = null
        private integer array $TYPE$Given
        private real $TYPE$Time = 0.0
        private conditionfunc $TYPE$C = null
        private integer $TYPE$Deal = 0
        private integer $TYPE$PossibleDeal = 0
    endglobals
    
    private struct s_$TYPE$
        trigger trig
        
        static method create takes trigger t returns s_$TYPE$
            local s_$TYPE$ s = s_$TYPE$.allocate()
            set s.trig = t
            set $TYPE$Table[t] = s
            return s
        endmethod
        method onDestroy takes nothing returns nothing
            call $TYPE$Table.flush(.trig)
            set .trig = null
        endmethod
    endstruct
    
    private function $TYPE$Check takes nothing returns boolean
        local player p = GetTriggerPlayer()
        local integer ref
    
        if GetEventPlayerState () == PLAYER_STATE_RESOURCE_$NAME$ then
            if TimerGetElapsed(Tim)*Count != $TYPE$Time then
                set $TYPE$PossibleDonor = GetTriggerPlayer()
                set $TYPE$Time = TimerGetElapsed(Tim)*Count
                return false
            else
                set ref = GetPlayerId($TYPE$PossibleDonor)
                set $TYPE$PossibleDeal = GetPlayerScore($TYPE$PossibleDonor, PLAYER_SCORE_$NAME$_GIVEN) - $TYPE$Given[ref] 
                if $TYPE$PossibleDeal == 0 then
                    set $TYPE$PossibleDonor = GetTriggerPlayer()
                    return false
                endif
                set $TYPE$Deal = $TYPE$PossibleDeal
                set $TYPE$Donor = $TYPE$PossibleDonor
                set $TYPE$Receiver = GetTriggerPlayer()
                set $TYPE$Given[ref] = GetPlayerScore($TYPE$Donor, PLAYER_SCORE_$NAME$_GIVEN)
            endif
            set $TYPE$Time = TimerGetElapsed(Tim)*Count
        endif
        
        return true
    endfunction
        
    private function $TYPE$ForForce takes nothing returns nothing
        call TriggerRegisterPlayerStateEvent( Trig, GetEnumPlayer(), PLAYER_STATE_RESOURCE_$NAME$, NOT_EQUAL, MAX )
    endfunction
        
    function Get$TYPE$Donor takes nothing returns player
        local s_$TYPE$ s
        if GetEventPlayerState()!= PLAYER_STATE_RESOURCE_$NAME$ then
            debug call BJDebugMsg(&quot;you tried to use the function Get$TYPE$Donor with a bad event&quot;)
            return null
        endif
        set s = $TYPE$Table[GetTriggeringTrigger()]
        if s.trig != GetTriggeringTrigger() then
            debug call BJDebugMsg(&quot;you didn&#039;t use the function TriggerRegisterTrade to register the $TYPE$ trade&quot;)
            return null
        endif
        return $TYPE$Donor
    endfunction
        
    function Get$TYPE$Receiver takes nothing returns player
        local s_$TYPE$ s
        if GetEventPlayerState() != PLAYER_STATE_RESOURCE_$NAME$ then
            debug call BJDebugMsg(&quot;you tried to use the function Get$TYPE$Receiver with a bad event&quot;)
            return null
        endif
        set s = $TYPE$Table[GetTriggeringTrigger()]
        if s.trig != GetTriggeringTrigger() then
            debug call BJDebugMsg(&quot;you didn&#039;t use the function TriggerRegisterTrade to register the $TYPE$ trade&quot;)
            return null
        endif
        return $TYPE$Receiver
    endfunction
        
    function Get$TYPE$Deal takes nothing returns integer
        local s_$TYPE$ s
        if GetEventPlayerState() != PLAYER_STATE_RESOURCE_$NAME$ then
            debug call BJDebugMsg(&quot;you tried to use the function Get$TYPE$Deal with a bad event&quot;)
            return 0
        endif
        set s = $TYPE$Table[GetTriggeringTrigger()]
        if s.trig != GetTriggeringTrigger() then
            debug call BJDebugMsg(&quot;you didn&#039;t use the function TriggerRegisterTrade to register the $TYPE$ trade&quot;)
            return 0
        endif
        return $TYPE$Deal
    endfunction
    
    function GetLast$TYPE$Donor takes nothing returns player
        return $TYPE$Donor
    endfunction
    
    function GetLast$TYPE$Receiver takes nothing returns player
        return $TYPE$Receiver
    endfunction
    
    function GetLast$TYPE$Deal takes nothing returns integer
        return $TYPE$Deal
    endfunction
    
//! endtextmacro
//! runtextmacro DRES_Resource(&quot;Gold&quot;,&quot;GOLD&quot;)
//! runtextmacro DRES_Resource(&quot;Lumber&quot;,&quot;LUMBER&quot;)
    
function TriggerRegisterTrade takes trigger t , force f , integer resourceType returns boolean
    local s_Gold g
    local s_Lumber l

    if f == null then
        debug call BJDebugMsg(&quot;the force taken in the function TriggerRegisterTrade is null&quot;)
        return false
    elseif t == null then
        debug call BJDebugMsg(&quot;the trigger taken in the function TriggerRegisterTrade is null&quot;)
        return false
    endif
            
    if resourceType == GOLD then
        set g = GoldTable[t]

        if g.trig == t then
            debug call BJDebugMsg(&quot;You had already register a gold exchange for this trigger&quot;)
            return false
        endif
        if g != 0 and g.trig != t then
            call g.destroy()
        endif
        set g = g.create(t)
        set Trig = t
        call ForForce(f,function GoldForForce)
        call TriggerAddCondition(t,Condition(function GoldCheck))
        
        return true
    elseif resourceType == LUMBER then
        set l = LumberTable[t]

        if l.trig == t then
            debug call BJDebugMsg(&quot;You had already register a lumber exchange for this trigger&quot;)
            return false
        endif
        if l != 0 and l.trig != t then
            call l.destroy()
        endif
        set l = l.create(t)
        set Trig = t
        call ForForce(f,function LumberForForce)
        call TriggerAddCondition(t,Condition(function LumberCheck))
        return true
    endif
            
    debug call BJDebugMsg(&quot;the resourceType taken in the function TriggerRegisterTrade is invalid&quot;) 
    return false
endfunction

public function DestroyTriggerEx takes trigger t returns nothing
    local s_Gold g = GoldTable[t]
    local s_Lumber l = LumberTable[t]
    
    if g != 0 then
        call g.destroy()
    endif
    if l != 0 then
        call l.destroy()
    endif
    call DestroyTrigger(t)
endfunction
    
// This textmacro should be used if you want other events in your trigger, because in the case of a trade, the conditions will be evaluated two times.
// Using this macro won&#039;t avoid the double evaluation but if you use it just after the local declaration in your condition, it will return false
// if the players events GOLD or LUMBER start the trigger. Check the demo trigger to see an example of usage.

//! textmacro DRES_C
    set DRES_Ple = GetEventPlayerState()
    if DRES_Ple == PLAYER_STATE_RESOURCE_GOLD or DRES_Ple == PLAYER_STATE_RESOURCE_GOLD then
        return true
    endif
//! endtextmacro
    
private function TimeOut takes nothing returns nothing
    set Count = Count+1
endfunction
    
private function init takes nothing returns nothing
    set Tim = CreateTimer()
    call TimerStart(Tim,TIME_OUT,true,function TimeOut)
    set GoldC = Condition(function GoldCheck)
    set LumberC = Condition(function LumberCheck)
    set GoldTable = HandleTable.create()
    set LumberTable = HandleTable.create()
endfunction
    
endlibrary


Requires :

- JassHelper
- The JassNewGenPack with UMWSE enabled if you want to open the demo map
- the library Table

And this is the documentation you can copy/paste it in a deactivated jass trigger.

JASS:
//      ~~ CHANGELOG
        
    * v 2.1 
        - Changed the name of the custom function DestroyTrigger, now you must use DRES_DestroyTriggerEx, because you can&#039;t use
          a native function name, even if you use the keyword public, my bad ...
        
    * v 2.0
        - Use the library Table instead of DataSystem, because we don&#039;t need the fastest way here.
          And i had a bad idea of how the handles are recycled, so in the previous versions, they were leaks, 
          if you destroyed the DRES triggers. I&#039;ve added a custom function (DRES_DestroyTrigger) if you want destroy triggers which have trade events.
        - Removed an unneeded creation trigger at the map init, and now the integer Count is increased when the timer expire ...
        
    * v 1.3
        - updated with the new library DataSystem
        
    * v 1.2
        - Fixed a bug, i used GetTriggerEventId() instead of GetEventPlayerState() without any compilation error ...
        
    * v 1.1
        - Renamed the function TriggerRegisterResourceExchange by this shorter name : TriggerRegisterTrade.
        - Added a demo map.
        
    * v 1.0
        - Edited the code to follow the jass convention.
        - Added the functions GetLast...
        - Fixed a possible bug if the time beetween two trades was very closed.
        - Now i&#039;ts completly friendly user, because :
            ~ you won&#039;t be able to add many time the same ResourceExchange event in a same trigger, even if you call it.
            ~ the gets returns null if it&#039;s not the right event.
            ~ added a texmacro for your trigger conditions.
            ~ added more debug messages.

    * v 0.2
        - Added a miss setting of the variables $TYPE$Time in the Alt$TYPE$Check functions.
        - Added more comments about how to use the AltRegister$TYPE$Exchange function.
        
    * v 0.1
        - Initial Release.
        
//      ~~ HOW TO USE IT

    I will comment the functions.
    
&gt;&gt;&gt;      Register function      &lt;&lt;&lt;

    You should use only allies for the force parameter but if the alliance can change in the game,
    or if you can give resource to ennemies then simply add all players.
    The function below is friendly user, it will add for you the events and the condition to your trigger.

    ** function TriggerRegisterResourceExchange takes trigger t , force f , integer resourceType returns boolean
            - Use this function to register a trade. For the ressourceType simply use the constants DRES_GOLD and DRES_LUMBER.
               or GOLD and LUMBER if you can delete the public attribute of them in the library.
            - It returns true if the event is register and false if not.
    
    You are not allowed to add the same event in the same trigger with this function.
    If you try it it won&#039;t add it anyway, so just don&#039;t.

    Now it&#039;s hardier.
    The function TriggerRegisterResourceExchange add players event PLAYER_STATE_RESOURCE_(GOLD or LUMBER) to your trigger.
    You can add more other events to your trigger but you must consider these facts:
    
    - You are not allowed to add these players event PLAYER_STATE_RESOURCE_GOLD or PLAYER_STATE_RESOURCE_LUMBER.
    - Your conditions will be evaluated when a resource player change (gold or lumber ofc).
    - In case of a trade, the conditions will be evaluated two times.
    - I have created a textmacro to fix this problem, check the example.

    The condition added by the function TriggerRegisterResourceExchange returns true when the system detect an exchange of ressources between players, but also true,
    when the event which fire the trigger, is different to PLAYER_STATE_RESOURCE_(GOLD or LUMBER). To allow the other conditions evaluate.

           
&gt;&gt;&gt;      Get functions      &lt;&lt;&lt;
           
    The different Get return null if you try to use it with a bad event.
    But ofc you can use the GetLast... anywhere.
    CAREFULL, you CAN&#039;T use them in a trigger condition, just in a trigger action, because how the &quot;system&quot; was made.
    But ofc all the GetLast... can be used in a trigger condition as well.

    ** function GetGoldDonor takes nothing returns player
            - Use this function to return which player gives gold.

    ** function GetGoldReceiver takes nothing returns player
            - Use this function to return which player get gold.

    ** function GetLumberDonor takes nothing returns player
            - Use this function to return which player gives lumber.

    ** function GetLumberReceiver takes nothing returns player
            - Use this function to return which player get lumber.

    ** function GetGoldDeal takes nothing returns integer
            - Use this function to return the amount of the gold exchange.

    ** function GetLumberDeal takes nothing returns integer
            - Use this function to return the amount of the lumber exchange.

    ** function GetLastGoldDonor takes nothing returns player
            - Use this function to return the last gold donor.
            
    ** function GetLastLumberDonor takes nothing returns player
            - Use this function to return the last lumber donor.
            
    ** function GetLastGoldReceiver takes nothing returns player
            - Use this function to return the last gold receiver.

    ** function GetLastLumberReceiver takes nothing returns player
            - Use this function to return the last lumber receiver.

    ** function GetLastGoldDeal takes nothing returns integer
            - Use this function to return the last gold deal.
            
    ** function GetLastLumberDeal takes nothing returns integer
            - Use this function to return the last lumber deal.  

//      ~~ SPECIAL THANKS TO

            //! popp
                - Asked me the system and tested it a lot with me.
            //! Blubb-Tec
                - Found a code error and reminder me the double evaluation of the trigger.
            //! Earth-Fury
                - Helped me for respect the jass convention and gave me some tips.
            //! Vexorian
                - For his library Table.


Read the changelog for more infos.

EDIT : You must be at least 2 players to test it, it seems it's hardcoded in war3.
 

Attachments

  • DRES v 2.1.w3x
    31.7 KB · Views: 414

BlackRose

Forum User
Reaction score
239
> EDIT : You must be at least 2 players to test it, it seems it's hardcoded in war3.
Can't you go to LAN game and play against AI and test using that? It seems useful for something....
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
> EDIT : You must be at least 2 players to test it, it seems it's hardcoded in war3.
Can't you go to LAN game and play against AI and test using that? It seems useful for something....
No if you don't have 2 real players (a bot should be considered as a real player), i mean not a computer, you can't trade anything, try it yourself if you don't believe me.

An ai is just useful for use an ... ai .
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
It would be great if you explained in depth how this works... and why on earth you'd use Table. o.o :thup:
The best explanation i can give is "read the code and ask if you don't understand".
Table is just to prevent people being dumb, basically i attach datas to triggers.
 

Romek

Super Moderator
Reaction score
963

Troll-Brain

You can change this now in User CP.
Reaction score
85
You need to at least say what functions are available to use, what they do, etc.
Actually i did it.

JASS:
    public constant integer GOLD = 1
    public constant integer LUMBER = 2

...You could use a boolean. :p
And if someday Blizzard decide to add more resources ? :p
Seriously that doesn't make sense for me, and anyway i should use "key" now instead.
Or not, i'm waiting for Vexorian's answer about how key values are defined (only > 0 or can be equal to 0 or less)

JASS:
set .trig = null

No need.
If the user want destroy the trigger later, it is.
Anyway it's a good behaviour to null handle variables when they are not needed anymore.

JASS:
public function DestroyTriggerEx takes trigger t returns nothing

Use a hook instead. =)
It wasn't available when i made it, i could change it but then lost the backward compatibility, hmm wait that's not like it is already used by someone xD.
I will probably make it.

It's just for the textmacro, it's explained how and when use it.

EDIT : Oh you want say "why use a global instead of directly GetEventPlayerState()" ?
Bwah it's just in case the user want to add more player states events to his trigger, he can use DRES_Ple instead of GetEventPlayerState, for ... speed freak, but i just realize now it's silly, thx to point it out.
You're right i think i should remove it.
 

Romek

Super Moderator
Reaction score
963
> And if someday Blizzard decide to add more resources ? :p
They won't.

> Seriously that doesn't make sense for me, and anyway i should use "key" now instead.
No you shouldn't.. o_O

> Anyway it's a good behaviour to null handle variables when they are not needed anymore.
Nulling variables does nothing if they're not declared locals. So it's useless and does nothing.

> It wasn't available when i made it, i could change it but then lost the backward compatibility, hmm wait that's not like it is already used by someone xD.
Well, 'Latest Jasshelper' is already a requirement, so that's not a problem.
You could keep DestroyTriggerEx and make it simply call DestroyTrigger.

As for the last thing, I don't think you noticed.
JASS:
DRES_Ple == PLAYER_STATE_RESOURCE_GOLD or DRES_Ple == PLAYER_STATE_RESOURCE_GOLD
// Is similar to doing:
i == 5 or i == 5
// Two identical comparisons.


Oh, and preferably, the changelog should be at the bottom of the documentation. :p
...In which DestroyTriggerEx isn't mentioned.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
> And if someday Blizzard decide to add more resources ? :p
They won't.
sure it was a joke in answer to your silly request or joke ?.

> Seriously that doesn't make sense for me, and anyway i should use "key" now instead.
No you shouldn't.. o_O
And why not ?

> Anyway it's a good behaviour to null handle variables when they are not needed anymore.
Nulling variables does nothing if they're not declared locals. So it's useless and does nothing.
I think you don't get that struct are not just globals they are arrays, yes i know that you know it ...
But during the game you could need 100 instances of the struct (just a silly example) and later no more than 10 , great you have 90 no null leaks ...
It's a good standard to null handles members of a struct on onDestroy method.
I hope now you get the point of it.

> It wasn't available when i made it, i could change it but then lost the backward compatibility, hmm wait that's not like it is already used by someone xD.
Well, 'Latest Jasshelper' is already a requirement, so that's not a problem.
You could keep DestroyTriggerEx and make it simply call DestroyTrigger.
And how can i avoid to the hook being called in the DestroyTriggerEx function ?

As for the last thing, I don't think you noticed.
JASS:
DRES_Ple == PLAYER_STATE_RESOURCE_GOLD or DRES_Ple == PLAYER_STATE_RESOURCE_GOLD
// Is similar to doing:
i == 5 or i == 5
// Two identical comparisons.
:banghead:

Oh, and preferably, the changelog should be at the bottom of the documentation. :p
Will do it.
 

Romek

Super Moderator
Reaction score
963
> And why not ?
There are two possible values. Boolean is ideal.
Integer... Fine.
Key is an integer. Why 'should' you use a key over the other two?

> ...I hope now you get the point of it.
Yeah, I know why you're doing it. I'm not stupid. :p
I just tested something - I was under the impression that only locals leaked in a retarded way like that.

> And how can i avoid to the hook being called in the DestroyTriggerEx function
Something like this:
JASS:
private function DestroyTheTriggerThing takes trigger t returns nothing
 // do your stuff
endfunction

hook DestroyTrigger DestroyTheTriggerThing

function DestroyTriggerEx takes trigger t returns nothing
 call DestroyTrigger(t)
endfunction
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
> And why not ?
There are two possible values. Boolean is ideal.
Integer... Fine.
Key is an integer. Why 'should' you use a key over the other two?
Even if i would have only one constant i will never use a boolean for a not boolean thing, integer is just fine with all vJass stuff.
Hard to explain for me but it's my standard.
Anyway i will add "ALL" and then you won't complain anymore about it :D
Also key is great because you don't have to define a value and all keys are unique.
Pretty good for systems together in a same map.

EDIT : And i mean using 2 keys instead of using 2 constants integers ofc, but now 3 with "ALL"

> ...I hope now you get the point of it.
Yeah, I know why you're doing it. I'm not stupid. :p
I just tested something - I was under the impression that only locals leaked in a retarded way like that.
Need some tests o_O, actually i can't believe it, proof me that handles are correctly recycled if you don't null the array variable associated.

> And how can i avoid to the hook being called in the DestroyTriggerEx function
Something like this:
JASS:
private function DestroyTheTriggerThing takes trigger t returns nothing
 // do your stuff
endfunction

hook DestroyTrigger DestroyTheTriggerThing

function DestroyTriggerEx takes trigger t returns nothing
 call DestroyTrigger(t)
endfunction

Oh that was so simple ...
I will add it so.
 

Romek

Super Moderator
Reaction score
963
I'm fine with integers being there.
Your explanation for using keys is rubbish in my opinion.

> Also key is great because you don't have to define a value and all keys are unique.
Yes, I know. That doesn't really help this system though. '1' and '2' are unique enough.

> Pretty good for systems together in a same map.
...Yeah.

> Need some tests o_O, actually i can't believe it, proof me that handles are correctly recycled if you don't null the array variable associated.
Read over what I wrote again.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I'm fine with integers being there.
Your explanation for using keys is rubbish in my opinion.
Maybe, i should explain in my native language but you won't understand anything then ...

> Also key is great because you don't have to define a value and all keys are unique.
Yes, I know. That doesn't really help this system though. '1' and '2' are unique enough.
Using key make the system a (very) little more user friendly if a library plan to use theses constants.
At least you don't have to define values, what's bad with it ?

> Pretty good for systems together in a same map.
...Yeah.
Where is Bryan ?
Bryan is in the kitchen.

> Need some tests o_O, actually i can't believe it, proof me that handles are correctly recycled if you don't null the array variable associated.
Read over what I wrote again.

Romek said:
I just tested something - I was under the impression that only locals leaked in a retarded way like that.
Was under the impression is not enough :)
 

Romek

Super Moderator
Reaction score
963
> Was under the impression is not enough
'Was' being a key word there.

> At least you don't have to define values, what's bad with it ?
There's nothing bad with it. There's just no reason why you 'should' use it.
Not defining values, eh? Is "= 1" too much to type?

Anyway, I'll look through the code in more detail in the future (once I get to reviewing resources).
I like the idea of this though.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Please remove your use of Table. You're not using it for anything in the system's actual functionality.

As in, really, why are you bothering to do that. I hate the idea that a system would actually require Table because you the author considered a couple of extra debug messages that necessary.

And I don't believe any system needs DestroyTriggerEx. I can't imagine myself using a system that hooks my DestroyTrigger function. Why? Because you used Table? Because you wanted a user-stupidity error message? It's irrelevant to the functionality of this system... :(

But if you must, copy Event's structure to achieve all this without gamecache attaching and DestroyTrigger hooking. At the start you can flag that the trigger is good, and at the end flag that it isn't. You can detect that it has been destroyed. It's basically just a trigger wrapper. But at least it won't make your system break for patch 1.24.

Actually, at a closer look, this should be using Event - before launching the event, flag that the event is running, then fire it, then flag that it isn't running, your messages can work fine...
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Please remove your use of Table. You're not using it for anything in the system's actual functionality.

As in, really, why are you bothering to do that. I hate the idea that a system would actually require Table because you the author considered a couple of extra debug messages that necessary.
For example GetOrderedUnit return null when you use with a bad event, right ?
I really don't like that all my Get would return something when they shouldn't, used with a bad event.

Also if you try to add several times theses events to the same trigger the system will fail.

And I don't believe any system needs DestroyTriggerEx. I can't imagine myself using a system that hooks my DestroyTrigger function. Why? Because you used Table? Because you wanted a user-stupidity error message? It's irrelevant to the functionality of this system... :(
I won't leave the debug part as i said above.
About the hook part i don't like it neither i don't know if i will add it or not, but if i keep Table i will keep it also.

But if you must, copy Event's structure to achieve all this without gamecache attaching and DestroyTrigger hooking. At the start you can flag that the trigger is good, and at the end flag that it isn't. You can detect that it has been destroyed. It's basically just a trigger wrapper. But at least it won't make your system break for patch 1.24.
Will take a closer look about it.
Actually, at a closer look, this should be using Event - before launching the event, flag that the event is running, then fire it, then flag that it isn't running, your messages can work fine...
As i said above i will look your code.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Ok i've looked your code Jesus4Lyf, nothing is bad with it as usual, expect one big point :
It can confuse as hell jass beginners.

I won't switch to it and keep the "horrible" use of Table, sorry.
It's not like it is something you will use several times in a same map anyway ...
 

Jesus4Lyf

Good Idea™
Reaction score
397
>It's not like it is something you will use several times in a same map anyway ...
It is not something I will use at all if it uses Table. (I refuse to use any H2I in my maps, currently main reason is because it will break on patch 1.24.) It could've been useful, but now I'd have to recode it.

Breaking a map for debug messages...

Anyway, you didn't need to understand how Event works, just what it does. You could've used Event as is instead of Table. Just have two triggers, one for gold one for lumber, add all 16 player state change events to just those two triggers (instead of adding to all triggers, much nicer like this) and then make those triggers say... set IsValid boolean = true, call GoldEvent.fire(), set IsValid boolean = false. Your event responses can just check if IsValid is true before returning. Register triggers onto the Event to register the event... Really simple, just a different way of thinking about it.

Maybe I missed something, but I hope you will consider it...

Thanks for your time and work, either way. :thup:
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
>It's not like it is something you will use several times in a same map anyway ...
It is not something I will use at all if it uses Table. (I refuse to use any H2I in my maps, currently main reason is because it will break on patch 1.24.) It could've been useful, but now I'd have to recode it.
Totally irrelevant since all you have to do it's just update your Table when the new patch will come.
And if you refuse to use the native GetHandleId, it's your choice.

Breaking a map for debug messages...
Have you read what i said above ?!
Anyway, you didn't need to understand how Event works, just what it does. You could've used Event as is instead of Table. Just have two triggers, one for gold one for lumber, add all 16 player state change events to just those two triggers (instead of adding to all triggers, much nicer like this) and then make those triggers say... set IsValid boolean = true, call GoldEvent.fire(), set IsValid boolean = false. Your event responses can just check if IsValid is true before returning. Register triggers onto the Event to register the event... Really simple, just a different way of thinking about it.
It's not a problem actually.

Maybe I missed something, but I hope you will consider it...
I was more talking about "how to use" for beginners.
I'm just realist, really few or none will use it and if i make the usability harder for beginners then it will have less users ...

Thanks for your time and work, either way. :thup:
I love making shits like this, so nop.
Also thx for your feedback and critics.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Totally irrelevant since all you have to do it's just update your Table when the new patch will come.
Please don't tell me what's "totally irrelevant" to me as a mapper (I'm talking as an end user about this, not a system writer). I insist my 1.23 map releases work on 1.24, and that's my decision and since that means something to me, I will not include Table just because you felt like using it. So yes, to me as an end user, this breaks my map, and no it is not totally irrelevant, it's just your decision.

>if i make the usability harder for beginners
You could do what I said without changing anything about the interface or error messages to the end users - that's the idea.

>it will have less users
Hi, I'm a user (not that I was hoping to use this yet, but I'm a mapper). You don't seem too concerned about me not using it. ;)

>Also thx for your feedback and critics.
No problem. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top