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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top