wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-23-2009, 05:13 AM   #16
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,154

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

Quote:
Originally Posted by Strilanc
You should return an enum (an integer, with some public constants). Nobody disagrees about what RET_REMOVE and RET_KEEP mean.
You could just keep what you have so far, and add two globals as strilanc suggested ...but IMO they dont have to be be booleans, just 2 extra constant booleans for those who arent sure about that thing ...
__________________
akolyt0r is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-26-2009, 08:51 PM   #17
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Quote:
they dont have to be be booleans,just 2 extra constant booleans

huh.

I think the question is "keep running the loop?" and not "should I destroy it?" at least in my case it makes more sense to use true = positive = continue and false = bad = stop , true = destroy sounds a little counter-intuitive, and well... it is not like changing it would make it easier to move from another system to this one. So, I'll keep it with true = continue.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 04-27-2009, 03:21 AM   #18
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

I personally like the true -> destroy method better, but I think in the end it's all just a matter of opinion. I do not believe that either way is particularly better/more standardized.

However, I do agree with Strilanc that it would be smart to have some constant globals inside the library to use:
Collapse JASS:
globals
    constant boolean RET_KEEP = true
    constant boolean RET_REMOVE = false
endglobals
That way, what should be done is never ambiguous and JASSHelper will inline the variable anyway.


Aside from that, I don't see any flaws in this module, really. You did write "u" where you should have written ".u" in your example, however.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 04-27-2009, 05:00 AM   #19
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,154

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

damn my last post seems obfuscated even to me xD
well basically i wanted the same pyro has just posted, with a minor twist.
Collapse JASS:
globals
    public constant boolean CONTINUE = true
    public constant boolean REMOVE = false
endglobals
__________________

Last edited by akolyt0r : 04-27-2009 at 05:01 AM.
akolyt0r is offline   Reply With Quote
Old 04-27-2009, 05:25 PM   #20
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by Vexorian
I think the question is "keep running the loop?" and not "should I destroy it?"

You think. You can't expect people using the system to think like you, and you have to design with that in mind. Enums solve the problem, using true/false means avoidable one-time bugs.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 04-27-2009, 05:57 PM   #21
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,375

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

Given that code outside the library has to use the correct boolean, that's a terrible idea to have two constants.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 04-27-2009, 06:24 PM   #22
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

It is sad to see this thread filled with pages of quibbling over this minor detail. Anyway, I like it the way it is, as it's the same way I do things with my periodic events. No globals.
grim001 is offline   Reply With Quote
Old 04-27-2009, 07:41 PM   #23
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

Quote:
Originally Posted by Captain_Griffen
Given that code outside the library has to use the correct boolean, that's a terrible idea to have two constants.
Only if the booleans were private...

I see no reason not to have constants.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 04-28-2009, 01:11 AM   #24
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Quote:
You think. You can't expect people using the system to think like you,
Yes, I can. If they don't then they will find out by the time they read the documentation.

enums would be an absurdly retarded thing to do .

I am still not updating this because I can't find good names already, with the lame, completely unnecessary idea of using enums, it would get even worse, for correct scopeness of the constants I would have to add a prefix

Collapse JASS:
return PeriodicModule_Continue
it sounds terrible. Are you returning the function, or continuing the loop or returning a random constant?

I find it very irritating that every single piece of code using a boolean return value for continue or not has been able to do it, and now just because of a lame cohadar rant you are saying that I am supposed to uglysize it by adding two constants.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 04-28-2009, 02:13 AM   #25
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

No, you're not supposed to. Like you said, documentation exists for a reason. To me, the current setup makes more intuitive sense than the opposite.
__________________
Anitarf is offline   Reply With Quote
Old 04-28-2009, 10:39 AM   #26
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,375

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

Discussion over, you don't need to change it. It's already taken up far too much talking, so I'm making a call on it. (Plus Vex and Ani agree.) Sorry Pyro, but, really, constants would be fuck ugly.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 04-28-2009, 12:37 PM   #27
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by Vexorian
Names and implementation are likely to change before approval.
So, will there be any changes or are you happy with the current setup? It seems alright to me.

Perhaps you could add some @@ highlights to the usage example, making the implement line, the startLoop call and the onLoop method name stand out more? Not that the example isn't simple enough to understand as it is, but a bit of highlights can only make it better.

Is there a reason why the indentation is one tab further in the startLoop method?
__________________
Anitarf is offline   Reply With Quote
Old 04-29-2009, 03:12 PM   #28
Deaod
User
 
Join Date: Jan 2007
Posts: 542

Submissions (11)

Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)Deaod is a jewel in the rough (192)

Default

Collapse JASS:
library PeriodicStruct
//********************************************************
//*
//*   A library + module that are meant to make those
//* array + timer loops easy, yet still faster than
//* other alternatives meant to be easy (In other words
//* no TriggerEvaluate is involved).
//*
//* The OOPness is interesting.
//*
//*  Before implementing PeriodicLoopModule,
//* your struct needs an onLoop method that takes
//* nothing and returns boolean, if the method
//* returns false, the instance will get removed
//* from the loop and destroyed.
//*
//* After implementing PeriodicLoopModule, you can call the
//* startLoop method to add the periodic event to that
//* instance, only call it once per instance.
//*
//* I recommend to call implement just bellow the declaration
//* of the onLoop method, else it will actually use
//* TriggerEvaluate, which is lame.
//*
//*  If you feel the need to destroy the struct outside
//* the loop, well, you'll have to add a flag to it so
//* you send a message to onLoop to make it return false.
//* A more complicated module to allow that easily would
//* come later.
//*
//********************************************************


//========================================================
    globals
        public real PERIOD = 0.025
    endglobals
   
   
    //===========================  
    module PeriodicStruct
        private static thistype array V
        private static integer        N = 0
        private static timer          T = CreateTimer()
        
        private static method onExpire takes nothing returns nothing
        local integer  n    = 0
        local thistype this
        local integer i=0
        
            loop
                exitwhen (i>=.N)
                set this = .V[i]
                if not this.onLoop() then
                    call this.destroy()
                    set .N=.N-1
                    set .V[i]=.V[.N]
                    set i=i-1
                endif
                set i=i+1
            endloop
            if (n== 0) then
                call PauseTimer(.T)
            endif
        endmethod
        
        method startLoop takes nothing returns nothing
            set .V[.N] = this
            set .N=.N + 1
            if (.N == 1) then
                call TimerStart(.T, PERIOD, true, function thistype.onExpire)
            endif
        endmethod
    
    endmodule


endlibrary
This is what I'd do.

Edit: why's the "not" keyword not highlighted?
__________________

Last edited by Deaod : 04-29-2009 at 03:13 PM.
Deaod is offline   Reply With Quote
Old 04-30-2009, 11:05 PM   #29
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Quote:
So, will there be any changes or are you happy with the current setup?
I am all but happy with the current names.

Will think about it tomorrow.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 05-07-2009, 03:52 PM   #30
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Ok, updated, finally decided on good news, and well I did the constant non-sense, I don't plan to change the values of true/false so people are free to use them directly, I know I will...

As for the names, I decided against the Module sufix, everyone is free to follow a naming convention that makes more sense, as for me, I never really added a "Struct" sufix to my structs so I don't think it is necessary to do that with Module.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 05:48 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services