MUI in JASS, not vJASS

eskimojoe_66

Member
Reaction score
2
Hi, i've recently started learning JASS. Since im using a mac and I cannot get a PC for a while, I cannot use NewGen/vJASS until then. For now, I was wondering how I could make an MUI ability using timers and not the loop + call TriggerSleepAction (because it looks very sloppy). The only way i can make an ability like this right now is to make udg globals, and this does not support MUI.

Is there any way to detect local variables from other functions?
Can somebody explain the use of 'takes' and 'returns' in detail? Every tutorial I have read does not explain it well.

P.S: Please do not flame me, I am trying to learn JASS :)
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Is there any way to detect local variables from other functions?
The whole point of 'local' is that it's specific to that function.

Can somebody explain the use of 'takes' and 'returns' in detail? Every tutorial I have read does not explain it well.

Here is a native function and a use of that function:
JASS:

native CreateUnit takes player id,integer unitid,real x,real y,real face returns unit

JASS:

local unit u = CreateUnit(Player(0),'hfoo',100,-200,0)


Takes are the values inputted into the function and they act basically like local variables when you declare your own functions in that they're instance-specific and can be used in the function by their name just like locals can be. Returns is what the function gives back.

In CreateUnit, the function takes a player, an integer and three realsm creates the unit based on those parameters, and then 'returns' the unit. By 'returning' a unit, CreateUnit can be used anywhere a unit can be used. For example, KillUnit(SomeUnitVariable) and KillUnit(CreateUnit(Player(0),'hfoo',100,-200,0)) both work just fine.

In your own functions, it might look like this:
JASS:

function Multiply takes real value, real multiple returns real
return value * multiple
endfunction

function Display takes nothing returns nothing
call BJDebugMsg(R2S(Multiply(5,2)))
endfunction

If you call Display, it will show '10' on the screen.


I'll edit the post in a moment after scraping together Dusk's timer system in non-vJass form. It's rather intuitive and basically acts like TU Red.


Edit:
Create 3 variables:
timer array ax
integer Vx
integer nx

Here's the system code, paste it high in your map header:
JASS:

function DH2I takes handle h returns integer
return h
return 0
endfunction

function TimerInitialization takes nothing returns nothing
local integer i=1
set udg_ax[0]=CreateTimer()
set udg_Vx=DH2I(udg_ax[0])-1
loop
exitwhen i>512
set udg_ax<i>=CreateTimer()
set i=i+1
endloop
set udg_nx=513
endfunction

function GetTimer takes nothing returns timer
if udg_nx==0 then
call BJDebugMsg(&quot;ERROR: The timer stack has run out of timers&quot;)
return null
endif
set udg_nx=udg_nx-1
return udg_ax[udg_nx]
endfunction

function FreeTimer takes timer t returns nothing
if t!=null then
call PauseTimer(t)
set udg_ax[udg_nx]=t
set udg_nx=udg_nx+1
endif
endfunction

function T2I takes timer t returns integer
return DH2I(t)-udg_Vx
endfunction
</i>



The way you use this is, when you want a timer, you get one from the stack by using GetTimer(). When you're done using a timer, use FreeTimer(timer). You attach things to the timer by using the integer value returned by T2I(timer) and plugging it into arrays as an index. Example usage:

JASS:

function Callback takes nothing returns nothing
local integer i = T2I(GetExpiredTimer())
call BJDebugMsg(I2S(SomeIntegerArray<i>))
set SomeIntegerArray<i> = SomeIntegerArray<i> - 1
if SomeIntegerArray<i> == 0 then
call FreeTimer(GetExpiredTimer())
endif
endfunction

function Init takes nothing returns nothing
local timer t = GetTimer()
local integer i = T2I(t)
set SomeIntegerArray<i> = 5
call TimerStart(t,.1,true,function Callback)
endfunction
</i></i></i></i></i>

This should display:
5
4
3
2
1
with each number .1 seconds after the last.

edit: and give credit to Rising_Dusk if you use the system.
 

eskimojoe_66

Member
Reaction score
2
haha thank you so much :D
hmmm ok i think i understand about takes and returns now

o please that would help me so much!
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Well, if you have patch 1.24 you can make use of the hashtable functions.
Yes, although Dusk's method makes use of shorter code, and if you can fulfil the functionality requirement for inherent indexing of a preinitialized stack, you might as well use it; I haven't tested it, but I would imagine that the subtraction of the offset plus a simple O(1) array lookup puts less load on the processor than inputting two keys into an indefinitely sized two dimensional array. For timer attaching under most circumstances it's arguably preferable to hashtables.

It also allows playtesting in 1.23, and the only inconvenience from the patch is that H2I needs to be changed to a GetHandleId form, which takes, I dunno, 10 seconds maybe, if you're a slow typer?

:)
 

eskimojoe_66

Member
Reaction score
2
errrr can someone send me a link to download that patch (keep in mind that im using a mac)? ive tried to download a patch before but when I check "About World Editor" it still says that its 1.20.4

And im not a slow typer btw =.=
 
Reaction score
341
errrr can someone send me a link to download that patch (keep in mind that im using a mac)? ive tried to download a patch before but when I check "About World Editor" it still says that its 1.20.4

And im not a slow typer btw =.=

Open up your Warcraft client (not world editor), and before logging on to b.net,

Change your realm to Westfall, there the 1.24 beta patch will be installed.
 

eskimojoe_66

Member
Reaction score
2
@triggerhappy
THANKS! thats exactly what i needed :)

Edit: omg, now every trigger i have comes up with the error "Unregistered native function." how can this be fixed?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
ive tried to download a patch before but when I check "About World Editor" it still says that its 1.20.4
Yeah, Warcraft will get patched, but the World Editor for Mac has not been updated. Not surprising; it was already several revisions out of date compared to the Windows version. :(

Edit: omg, now every trigger i have comes up with the error "Unregistered native function." how can this be fixed?
I noticed that also. It's something Blizzard will have to fix for the release of 1.24, if they even bother to fix it - dunno if it's possible without them updating the actual World Editor application. In the meanwhile, if you log in to a non-beta B.net server, it will downgrade itself back to 1.23 and will work again...but you won't have hashtables, nor any other 1.24 features, of course.
 

DiVille

New Member
Reaction score
0
I have the same problem with the Mac client and whilst looking for answers I read that the Mac client is no longer supported - in any sense of the word. Anyone know if there is any truth behind this?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
I have the same problem with the Mac client and whilst looking for answers I read that the Mac client is no longer supported - in any sense of the word. Anyone know if there is any truth behind this?
By "client" do you mean the World Editor? If so, it seems to be true - Blizzard hasn't updated it since version 1.21. You can restore it to its functionality before the patch without uninstalling the patch, though - see my post here: http://www.thehelper.net/forums/showpost.php?p=1088628&postcount=31
 

DiVille

New Member
Reaction score
0
Yeah I saw that but wondered if something had changed in the mean time haha Thanks for the quick reply, now working as intended =]

+rep
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top