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 05-07-2009, 03:15 PM   #31
Alevice
It feels good
 
Alevice's Avatar
 
Join Date: Mar 2006
Posts: 1,305

Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)

Default

I kind like that module based scripts have the 'Module' suffix. If only becasue you get to know how is implemented, and depening on your prefered coding style, you may want or not to use modules.

I mean it is not necesary, just handy, much like the System suffix as well :P
__________________
_-|-_

Alevice.jones is SC2 Beta, losers.

Check out my never updated deviantart gallery!!

Kalimdor Raiders (Race Contest #1) Pastebin Page
Cavern Crawlers (Race Contest #2) Pastebin Page
Airship Race Motherfuckers!
Quote:
Originally Posted by http://ajaxian.com/archives/would-you-like-a-_-with-that-new-library-gives-js-what-it-should-have#comment-276203
- Dont solve problems that dont exist.
- Improve the wheel, dont reinvent it.
- Port the wheel if it doesnt exist in your environment.
- Integrate the wheel into your project.
- Make sure you can replace your wooden wheel for a rubber one if someone else invents it.

Last edited by Alevice : 05-07-2009 at 03:15 PM.
Alevice is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 05-07-2009, 07:50 PM   #32
Mr.Malte
User
 
Mr.Malte's Avatar
 
Join Date: Apr 2008
Posts: 286

Submissions (2)

Mr.Malte is on a distinguished road (11)

Default

How can you check if the method is called with the first instance with this code? (To do pre-initializing).
Mr.Malte is offline   Reply With Quote
Old 05-07-2009, 08:07 PM   #33
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


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

Submissions (37)

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

Hero Contest #3 - 2nd Place

Default

huh?
__________________
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, 08:39 PM   #34
Deaod
User
 
Join Date: Jan 2007
Posts: 538

Submissions (11)

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

Send a message via ICQ to Deaod Send a message via MSN to Deaod
Default

Collapse JASS:
library TimedLoop
//********************************************************
//* TimedLoop
//* ---------
//*
//* Requires jasshelper 0.9.G.1 or greater.
//*
//*   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 TimedLoop
//* your struct needs an onTimedLoop method that takes
//* nothing and returns boolean, if the method
//* returns false, the instance will get removed
//* from the loop and destroyed, else it will continue,
//* think of it as if the call asks the method a
//* question: "Should I continue the loop afterwards?"
//*
//* Alternatively, if you are not convinced, you may
//* use the TimedLoop_CONTINUE and TimedLoop_STOP
//* constants in the method's returns.
//* 
//*   After implementing TimedLoop, you can call
//* the startTimedLoop 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. Remind
//* me to implement a topsort in jasshelper.
//*
//*  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.
//*
//********************************************************

//========================================================
// config:

    globals
        public constant real    PERIOD = 0.025
        // A lower value and everything using the module will
        // look better, yet performance will drop.
    endglobals

//========================================================
// implementation:
//
    globals
        public constant boolean STOP     = false
        public constant boolean CONTINUE = true
    endglobals
   
   
    //===========================  
    module TimedLoop
    // god bless private module members.
    //
        private static thistype array V                 // The array
        private static integer        N = 0             // The count
        private static timer          T = CreateTimer() // the timer, one per
                                                        // struct that implements this
      
        private static method onExpire takes nothing returns nothing
        local integer  i    = thistype.N-1
            loop
                exitwhen (i==0)
                if ( thistype.onTimedLoop(i) == STOP ) then
                    call thistype.destroy(i)
                    set thistype.V[i]=thistype.V[N]
                    set N=N-1
                    if N==0 then
                        call PauseTimer(thistype.T)
                    endif
                endif
                set i=i-1
            endloop
        endmethod
      
        public method startTimedLoop 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

Vex, would you please take a look at this? It should be more efficient than your current implementation.

Oh, and the not keyword still isnt being highlighted.
__________________
Deaod is offline   Reply With Quote
Old 05-07-2009, 09:32 PM   #35
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


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

Submissions (37)

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

Hero Contest #3 - 2nd Place

Default

Current can work even if you start loops during the loop expiration, that one can't.
__________________
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-13-2009, 07:15 PM   #36
Anitarf
Procrastination Incarnate


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

Submissions (19)

Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)

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

Default

I still don't understand why you won't make the code support .destroy calls instead of this return boolean nonsense that people can't agree on, all in the name of not looping backwards through the list.
__________________
Anitarf is offline   Reply With Quote
Old 05-13-2009, 11:11 PM   #37
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


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

Submissions (37)

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

Hero Contest #3 - 2nd Place

Default

Quote:
Originally Posted by Anitarf
I still don't understand why you won't make the code support .destroy calls instead of this return boolean nonsense that people can't agree on, all in the name of not looping backwards through the list.
Because it is impossible. Simple as that. (Ok, it is possible to allow .release, but that complicates things too much, I graveyarded that one)

Looping backwards got absolutely nothing to do with it, you may change it to loop backwards, people using .destroy will still screw it up -- unless you implemented onDestroy but then the struct using the module won't be able to have its onDestroy... . Plus there's no benefit from it if you want to be able to add to the loop during the timeout.

If I wanted to use .release or remove onDestroy rights from the calling struct it would work regardless of whether the broken backwards loop was used or not.
__________________
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-13-2009, 11:49 PM   #38
Anitarf
Procrastination Incarnate


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

Submissions (19)

Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)

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

Default

Right, I forgot you need to be able to do stuff in the onDestroy method for the .destroy way to work. Modules really don't live up to their hype without the ability to insert module stuff in the create and onDestroy methods.

Anyway, looks good, approved.
__________________
Anitarf is offline   Reply With Quote
Old 05-13-2009, 11:55 PM   #39
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


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

Submissions (37)

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

Hero Contest #3 - 2nd Place

Default

That ability is not really that necessary for the stuff modules were meant for. It makes it sound like inheritance anyway. They will eventually get it though.
__________________
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 06-16-2009, 07:21 PM   #40
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

I am using this script now and I have a question: is it possible to stop our struct without returning TimedLoop_STOP in the onTimedLoop method? Because I am making a ward and a storm spell, and I would only stop when the unit dies or moves, and I was thinking of using events for that ... will it be possible in a nearby future?
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 06-16-2009, 07:27 PM   #41
akolyt0r
In Flames
 
akolyt0r's Avatar
 
Join Date: Jan 2006
Posts: 1,153

Submissions (3)

akolyt0r has a spectacular aura about (120)

Default

Quote:
Originally Posted by Flame_Phoenix
I am using this script now and I have a question: is it possible to stop our struct without returning TimedLoop_STOP in the onTimedLoop method? Because I am making a ward and a storm spell, and I would only stop when the unit dies or moves, and I was thinking of using events for that ... will it be possible in a nearby future?

??? i dont see your problem, you totally CAN use events for that !
__________________
akolyt0r is offline   Reply With Quote
Old 06-16-2009, 07:42 PM   #42
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
??? i dont see your problem, you totally CAN use events for that !
Wermmm... I don't see how =S
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 06-16-2009, 07:58 PM   #43
Anitarf
Procrastination Incarnate


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

Submissions (19)

Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)Anitarf has a brilliant future (883)

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

Default

...

It's all explained at the end of the documentation.
__________________
Anitarf is offline   Reply With Quote
Old 06-16-2009, 08:15 PM   #44
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

I read the documentation before posting on this thread Anitarf, you taught me that the hard way ...
Quote:
//* 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.

This does not solve my problem ...
Assume for instance my user is an idiot, or a newb bigger than me, and that he makes:
Collapse JASS:
set TimedLoop_PERIOD = 10 //in seconds...

So, when my hero dies I set a boolean to false and ... 10 SECONDS later the spells dies ...
Correct me if I am wrong, but this is horrible =S
My question is: "Is there a way to make this work without having to wait TimedLoop_PERIOD seconds?"
If no, can it be added?
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 06-16-2009 at 08:25 PM.
Flame_Phoenix is offline   Reply With Quote
Old 06-16-2009, 08:51 PM   #45
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


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

Submissions (37)

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

Hero Contest #3 - 2nd Place

Default

If the user is an idiot enough to make it last 10 seconds, he is an idiot and must die.

Quote:
This does not solve my problem ...
It definitely does.
__________________
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 08:03 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

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