HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Method Teaching?

03-25-2009, 07:19 AM#1
Anachron
Well I've just read the code of the Custom Bar Library 1.3.1 and I am having more and more question.

First of all I am not very good in vJASS, that is because for once I have used LHV firstly for storing things (because its really easy, Init Data, Add Data, Change Data, GetData and clear data), secondly because my teacher (Flame_Phoenix) has not really much time for me atm.

What I am generelly seeking for:
Good Storing System (LHV is bugged hell, you know)
Good Effect System (Attaching effects X seconds)

I know there is no perfect storing system for handle IDs, but I guess
you know which one I should take a look at.

What want is safety.

Where I need help:
Understanding structs (I know what they do, how they do it and what they are, but I can't get a rid how to make them).

for example:
Collapse JASS:
private static method LockCallback takes nothing returns nothing
Whats does the static mean?

Collapse JASS:
method operator Size takes nothing returns real
What does a method operator do? And wth is that? xD

What I've already done:
Changed from MUI GUI to JASS
Changed from JASS to vJASS

Please help me becoming better.

I guess I have alot to do (at least not only because learning new things, but change my LHV spells to another system).
03-25-2009, 07:33 AM#2
akolyt0r
normal methods should only operate with one instance of the struct ... (which means they exist more often, when you got more instances... well at least virtually)
static methods only exist one timer per struct ... most of the time static methods operate with more than one instance of a struct ...
static methods are basically normal functions ...

Collapse JASS:
struct myStruct
   private real myRealVar
    static method A takes nothing returns nothing
       //... do something
    endmethod
    method B takes nothing returns nothing
       //... do something
    endmethod
    method operator getReal takes nothing returns real
        return this.myRealVar
    endmethod
    method operator setReal= takes real  r returns nothing
        set this.myRealvar = r
    endmethod
endstruct
//...
local myStruct myInstance = myInstance.create() //allocate an instance
call myInstance.B() //calling a normal method   InstanceName.MethodName(Parameters)
call myStruct.A()    //calling a static method    StructName.MethodName(Parameters)
set myInstance.setReal = myInstance.getReal + 1 //using operators ...notice how they behave like variables even though they are functions

another famous application for static methods are callbacks for timers, forgroup calls etc ...because you can only use static methods as callbacks ...(because all normal methods take one integer parameter once they are converted to normal Jass ...and callbacks only work for functions which have takes nothing...
03-25-2009, 07:44 AM#3
Anachron
Thanks, that helped me alot.

Well do you have other useful tutorials? I've just read
Vexorians From LVH to Structs Tutorial through, but
I am quite not really enough experienced to do everything
with structs.

Do you have some easy structs examples so I can learn
from them?

Thanks.

Edit: So this is like the OOP in PHP and other programing languages?
The struct is classlike? Is that true?
03-25-2009, 09:29 AM#4
akolyt0r
yes struct are excactly the same as classes ....(in other languages ..)

some more tutorials (i liked those):
Coding an efficient knockback (vJass) ..convert a normal jass knockback to vjass...
JASS Making safe and effective code maybe you already know that stuff
vJass event handling I (function interfaces) (really fun to read ..however maybe still a bit to difficult for you ...)
03-25-2009, 10:20 AM#5
Anachron
Thanks, so we need to use Return0-Bug to store the IDs, so we don't need the whole LHV System, is that true?
03-25-2009, 11:11 AM#6
akolyt0r
what do you mean excactly with "store the IDs" ..what do you want to store, and why ?
03-25-2009, 11:22 AM#7
Anachron
I mean attaching the data to a timer...
03-25-2009, 01:26 PM#8
akolyt0r
we dont need LHV at all ...for timers ..use TimerUtils.
03-25-2009, 03:18 PM#9
Anachron
Ok, but there isn't any Tutorial about TimerUtils, is there?
Btw, which one is better for safety, Red or blue one?
03-25-2009, 03:20 PM#10
Michael Peppers
Quote:
Originally Posted by Anachron
Ok, but there isn't any Tutorial about TimerUtils, is there?
Btw, which one is better for safety, Red or blue one?

Blue is safer than Red, Red is faster than Blue...
03-25-2009, 03:39 PM#11
Anitarf
Quote:
Originally Posted by Michael Peppers
Blue is safer than Red, Red is faster than Blue...
Purple is said to be better than both, though. Also, green is the "safest" but it doesn't exist yet.
03-25-2009, 03:41 PM#12
Anachron
Purple???
Are you joking? xD
03-25-2009, 03:51 PM#13
Veev
There is a purple one somewhere, Anachron ;).

Edit: Somewhere is now here: http://www.wc3c.net/showthread.php?t=104590
03-25-2009, 07:57 PM#14
Anachron
Thanks, didn't knew that.