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
256
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.
  • 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

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top