Functions and Fixes

Note About Bugs:

We've been busy behind the scenes at Hack Wars, fixing some nasty bugs -- Which is why you might not have seen us as much as usual lately (also I think Alex and Stephen, the other two developers are dead). We seem to be back at a fairly stable build again. Another note, don't think that we're ignoring your suggestions, we've just been run off our feet recently... which brings us to an important note...

Script Updates:

Yes! you can now use functions in your scripts simply put this on the first line of your script:
#define functions
And make sure you a main function, so:
#define functions
int main(){
func();
}
void func(){
}

Cameron, as far as I know, is also hard at work adding in line based error reporting to the scripting.

The Future:

We've also been hard at work getting Hacktendo designed, for those who haven't heard about it, this will introduce player-made sprites, music, and arcade games into Hack Wars -- it should be super awesome cool.

Comments

Awesome news, great work guys

Awesome news, great work guys :)

EDIT: Just found the first bug with those, if the function name starts with an underscore (example: _foo) , the IDE will lock-up.. weird.. here's the function I was writing:


void _withdraw(string ip, float amount)
{
withdraw(ip, amount);
}

Apparently underscores can

Apparently underscores can only be used in variables/function names when they follow other characters in HackScript, kind of like numbers.... The difference is that underscores are whitespace every other time. The bug would be happening because it runs in to infinite recursion because "_withdraw()" is evaluated as being identical as withdraw() within it.

Note:The above was edited to correct my statements >.>

The bugs here would be:
-When infinite recursion happens and you press the compile button, it seems to detect it, but nothing ever pops up.
-It lets you write a function called _withdraw without complaint.

Bleh7777's picture

Wewt! A couple of questions:

Wewt! A couple of questions: What is the scope of variables defined in a function? And what is the scope of the function itself? Can I call blehwithdraw(); from deposit? Furthermore, if variables can't be read from a different function, is there a way to make a script-global variable without using the game's current global variables?

Come visit BlehCo at 2.718.2.818 for free challenge answers!

It would appear to me

It would appear to me (although I could very well be wrong) that these functions are actually just, i.e. inline functions without stack usage. I say this because recursion seems pretty broken. I tried compiling a script with pretty heavy recursion and the app froze. After over a minute (maybe two) I killed the firefox process and started again. I changed the script to infinitely recurse and now it won't compile at all. No error message or nothing, as if the toolbar button isn't hooked up to anything. Is it true the functions are macros? I guess this is how you guys can stop us from extending the while loop (which IMHO is a questionable limitation anyway).

From Wartt Hog

Bleh7777's picture

You mean like labels and

You mean like labels and returns?

Come visit BlehCo at 2.718.2.818 for free challenge answers!

Wow, I missed the most

Wow, I missed the most important word of the post. I was saying that it looks like functions are just "MACROS".

From Wartt Hog

Uh, what do you mean, Bleh?

Uh, what do you mean, Bleh? I think a "function" should technically be a label, push, call, return, pop like in any other imperative language, yeah. Really I was just pointing out that it seems to me that hackwars C functions are not this kind, hoping that either someone would correct me if I'm on crack or maybe one of the devs will comment on why things are this way.

From Wartt Hog