Tutorial How To Convert To 1.24

Sevion

The DIY Ninja
Reaction score
413
Done.

Left DoNothing in there but commented it out ;)

There's still a chance it'll be in there. And if I'm off on one thing, someone'll screw up. I've had that happen before >_<
 

Steel

Software Engineer
Reaction score
109
DO NOT DO THIS. THIS IS CATASTROPHICALLY WRONG!!!
DO NOT DO THIS. THIS IS CATASTROPHICALLY WRONG!!!
DO NOT DO THIS. THIS IS CATASTROPHICALLY WRONG!!!

JASS:
if i == 1 then
    call KillUnit(u)
    return
else
    call PauseUnit(u)
endif


becomes

JASS:
if i == 1 then
    call KillUnit(u)
    return
endif
call PauseUnit(u)

DO NOT DO THIS. THIS IS CATASTROPHICALLY WRONG!!!
DO NOT DO THIS. THIS IS CATASTROPHICALLY WRONG!!!
DO NOT DO THIS. THIS IS CATASTROPHICALLY WRONG!!!
quraji pointed this out too...change your initial post.


You're saying if you had...
JASS:

function test takes nothing returns nothing
local unit u = GetTriggerUnit()
local boolean killunit = true

if killunit then
call KillUnit(u)
else
call ReviveUnit(u)
endif


...that would translate to....
JASS:

function test takes nothing returns nothing
local unit u = GetTriggerUnit()
local boolean killunit = true

if killunit then
call KillUnit(u)
endif
call ReviveUnit(u)



Yea ok, kill the unit then immediately after we exit the if statement, revive it regardless of a boolean check. NO.
 

Sevion

The DIY Ninja
Reaction score
413
Whoops. I removed that part >_<. Sec, let me fix it.

I had it in there. But removed it on accident.

Edit: I believe I've fixed it, hopefully to your satisfaction.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>But wait, what about the part of else(if)'s that does something only if the first statement is false?

The example above and below this line are useless as they do not feature return statements in if statements, which is the only bug there is in the first place.

In fact, returning nothing doesn't bug, I believe. Only when the function returns a value of some sort does any of this apply at all...

In the example above that line, the return is at the end so it is not a problem. In the example below, there are no returns at all. An "else" statement should be used.

The rule of thumb is right: "If you use return in an if, follow it immediately with an endif. Anything after endif is else anyhow."

Please let your examples reflect it. :)
 

Sevion

The DIY Ninja
Reaction score
413
The example above goes with the line above the example:

Another way of fixing this is having a local variable of return type then in the if/then/else instead of returning, you can set the local to the value to be returned then returning that after all your stuff.

Tip from Renendaru.

Second one, will fix.

I think I understood what you were going at, so I've edited it. Please correct me if I'm wrong.
 

Ouguiya

New Member
Reaction score
11
Great

Aboluto-friggin great.

A good manual, totally foolproof. Even I think I can get my map working now :D

One last question: Is this now completely working and not messing up anything?

Thanks in advance.

Yours,

Ouguiya
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
You may want to know there is a new jasshelper version, which fix the false return positive with an extra function call, as a temp fix, if blizzard doesn't fix it the (soon ...) next patch, he will handle better theses cases.
 

waaaks!

Zinctified
Reaction score
255
JASS:
return 0.
call DoNothing()
return 1.

in this code, does vex's wc3 optimizer removes the call DoNothing() line?

JASS:
function test takes nothing returns nothing
local unit u = GetTriggerUnit()
local boolean killunit = true

if killunit then
call KillUnit(u)
endif
call ReviveUnit(u)

I don't get this, in the first example, if killunit is true, the unit will be killed and never be revived, but in this translated code (to be compatible with 1.24), killunit is true, which kills the unit, but after the if statement, it revives the unit again, do I really need to follow that? while there are some cases like this (or I don't know if they are the same):
JASS:
function act takes nothing returns nothing
local unit c = GetAttacker()
local unit t = GetAttackedUnit()
if GetWidgetLife(t) &lt; 500 then
call KillUnit(t)
else
call UnitDamageTarget(c,t,200,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
endif


"If you use return in an if, follow it immediately with an endif. Anything after endif is else anyhow."
so only for if statements with returns? then how about this?:
JASS:
function test takes nothing returns nothing
local unit u = GetTriggerUnit()
local boolean killunit = true

if killunit then
call KillUnit(u)
endif
call ReviveUnit(u)
 
Reaction score
91
And reports for return bugs so you can trace and remove them. I think you should suggest getting the latest jasshelper so people can quickly spot their mistakes if they don't know where they are. Of course the bug with the false positives still remains as long as there is no jasshelper enabled but it's a fine option for now... I hope 1.24b fixes that.
(God, people are fixing the game company's bugs instead of the employers... :/ )
 

UndeadDragon

Super Moderator
Reaction score
447
JASS:
if i == 1 then
    call KillUnit(u)
    return x
else
    call PauseUnit(u)
endif


becomes

JASS:
if i == 1 then
    call KillUnit(u)
    return x
endif
call PauseUnit(u)

That is not the same, because if "i==1", it will do KillUnit(u), return x and PauseUnit(u), whereas the first one did either "KillUnit(u) and return x" or "PauseUnit(u)".
 

Rainther

I guess I should write something of value here...
Reaction score
61
Um... return ignores the rest of the function (which means it won't pause). So those 2 is the same deal, really.
 

Steel

Software Engineer
Reaction score
109
You people aren't following this properly. Read my post again, it quotes Sevion's original message. Sevion has since changed the original post to reflect what I pointed out.
 

Sevion

The DIY Ninja
Reaction score
413
>New JassHelper

Mine broke o_O'

I kept getting I/O error 105 whenever I save. I've been since using the version before. 9.0.I.0 or whatever.

>Inlining DoNothing

Not sure. :-/ Someone ought to test that.

>People who commented before reading the entire tutorial (as in all words included in the tutorial...)

Please, stop doing that -_-'
 

quraji

zap
Reaction score
144
Just to clarify for people about the if statements.

You only need to edit your if statements if the return keyword is inside:
JASS:

if (u == null) then
    return false
else
    call KillUnit(u)
    return true
endif

You would change the above to:
JASS:

if (u == null) then
    return false
endif
call KillUnit(u)
return true

Remember that the function ends whenever it hits the return keyword! Thus, anything after the endif is essentially an else.

If you find this confusing, you can use a variable to store your return value:
JASS:

if (u == null) then
    return false
endif
call KillUnit(u)
return true

becomes:
JASS:

if (u == null) then
    set b = false
else
    call KillUnit(u)
    set b = true
endif
return b
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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