Jasshelper error: Cannot find Functions

retupmoc258

New Member
Reaction score
1
It's very odd, and I have had the problem a few times, but there are a few custom functions I have made that for whatever reason seem to be elusive. Sometimes I can get my map to save and compile right so that it recognizes these three functions, but even then it usually doesn't work.

I have a trigger that runs on initialization and it only runs one function called RegisterUnit. It has a unit variable that has already been assigned to use and work with (a unit that the game gave me that represented the unit). But when I compile the map, Jasshelper always says that it can't find the function. I can look for it and find it. I can move the function around in my triggers, and it still can't see it. The compilation that shows up also has everything out of order from where it is in my trigger organization (I don't know if that makes a big difference).

Then there's another function called SetAllStats, and that also seems to have problems whenever RegisterUnit does. They're virtually unrelated, other than I made them at the same time.

Sometimes I can just randomly do something and save it and they're found again (such as now when I reloaded the map and resaved it), and one time I exported the trigger data and reimported it (and that fixed it) and then it came back in both cases. It definitely sounds like there's something else wrong, but I am wondering what the problem is. Does anyone know what may be causing it? I am not a programming expert, so I imagine there might be a reason I just don't know. When everything does save and I run my game, the two triggers perform beautifully, doing exactly what they're supposed to do and run smooth as can be (don't even know if there's any noticeable lags).

The only other connection I can think of is that I created a new TimerUtils function that also sometimes doesn't register (but that tends to happen when the other two DO register).

So I am not sure what I can do, other than just ignore it and fix it once in a while so I can test my map. Any suggestions?
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
You're probably using libraries the wrong way.
Tell us, which libraries are your functions in?
 

retupmoc258

New Member
Reaction score
1
None. They aren't in libraries. If I stick them in libraries, then everything goes wrong . . . they're like the trigger functions--they're not in libraries.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Then put them in libraries already.
It's about time you started using them.

Let us say you have 3 Functions.

Function A calls Function B
Function B calls Function C

Right now, they aren't in libraries.
You try to compile.

Chances are, JassHelper will compile them randomly, ie.
B
A
C

So, when B tries to call C, there is an error because C is not above B, but below.
Functions cannot call functions below them.

However, with libraries:
JASS:
library BOTTOM requires MIDDLE
    function A takes nothing returns nothing
        //Stuff
        call B()
    endfunction
endlibrary

library MIDDLE requires TOP
    function B takes nothing returns nothing
        //Stuff
        call C()
    endfunction
endlibrary

library TOP
    function C takes nothing returns nothing
        //Stuff
    endfunction
endlibrary


JassHelper will compile it such that C is on top of A and B.
And B is above A.

This way, there will be no problems.
The 'requires' keyword is what keeps the order.

If a library requires another library, it'll be put below that library.
So, use them.
 

retupmoc258

New Member
Reaction score
1
Well, I tried it and got the same problems I had before. It didn't like the fact that I was calling functions in other libraries. I did a little poking around with other libraries in my map, and I guess I understand what the problem is now. It has saved with no errors, so I guess that's a good sign.

So . . . do you know of any good library tutorials or forums or anything like that? I feel like there's much more that I could utilize these for, I just don't know what. And is it good to have many libraries, or is it better to have a few. For example, I have a few completely unrelated libraries, each with sets of globals, and I'm wondering if it's just smart to leave them all separate, or just combine them together?
 

Bribe

vJass errors are legion
Reaction score
67
I recommend you import some good libraries like KeyTimers2 by Jesus4Lyf, or if you want to be more traditional TimerUtils by Vexorian.

You'll begin to notice how libraries can be useful because even if you put the library at the bottom of your map, JassHelper will shift them to the top of your map so you won't get a syntax error by calling them.

That's not to mention the seemingly unlimited uses for "private" and "public" keywords, and the ability to make one library require others/require optional others.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
I have a few completely unrelated libraries, each with sets of globals, and I'm wondering if it's just smart to leave them all separate, or just combine them together?

Nothing wrong with separating them.

Anything within the globals and endglobals block automatically gets sent to the top of the map, above library functions.

This is the order, I believe:
01) Globals
02) Library Functions
03) Scope Functions
04) Functions
05) Function Main <--- This is where all your 'initializer' functions are combined into.

So:
JASS:
//This
library ONE
    globals
        string Meh = &quot;I Love&quot;
    endglobals
endlibrary

function Addition takes real A, real B returns real
    return A + B
endfunction

library TWO initializer Stuff requires ONE
    globals
        string Teh = &quot; Anime!&quot;
    endglobals

    private function Stuff takes nothing returns nothing
        call BJDebugMsg(Meh + Teh)
    endfunction
endlibrary

//Will be compiled into:
globals
    string Meh = &quot;I Love&quot;
    string Teh = &quot; Anime!&quot;
endglobals

function Addition takes real A, real B returns real
    return A + B
endfunction

function main takes nothing returns nothing
    call BJDebugMsg(Meh + Teh)
endfunction

//I think =P
 

retupmoc258

New Member
Reaction score
1
I recommend you import some good libraries like KeyTimers2 by Jesus4Lyf, or if you want to be more traditional TimerUtils by Vexorian.

That's not to mention the seemingly unlimited uses for "private" and "public" keywords, and the ability to make one library require others/require optional others.

I've been using TimerUtils. I don't see much need for it, actually, other than EGUI requires it (but I don't know what functions from EGUI I'm actually using, now that I think of it). I use one timer utility from there, which is a set of functions (including one I added) that allows me to use timers to save data into a hashtable which can then be recalled later when the timer expires. Pretty handy. The rest seems really pointless (and I don't think I use anything that requires timers, yet).
 

Bribe

vJass errors are legion
Reaction score
67
I've been tinkering in JASS since February and I only recently found a use for TimerUtils. However, soon afterwards I found KeyTimers2 to do the same thing but with more overall efficiency.
 

tooltiperror

Super Moderator
Reaction score
231
Well, of course, depending on what you're doing, Timer32 might be better.
 

Bribe

vJass errors are legion
Reaction score
67
I just realized the T32x module does not create its own timer, which was my original suspicion. It seems Jesus4Lyf conceptually tied the two libraries together, after all!
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
I've been tinkering in JASS since February and I only recently found a use for TimerUtils. However, soon afterwards I found KeyTimers2 to do the same thing but with more overall efficiency.
For low frequency, TimerUtils is more efficient.
T32x is good for high frequency.
 

Bribe

vJass errors are legion
Reaction score
67
T32x does not call a static onLoop like what I need from KeyTimers2. Plus, I'm using a 0.04 interval, which is even higher frequency but it's all I need to get the job done. At what point would you consider TimerUtils more efficient than KT2?

It's a bummer that KeyTimers is a vanilla library and not a struct, because of the inability to initialize a library before a struct. I had to hack that library to make it work.
 

tooltiperror

Super Moderator
Reaction score
231
Just wondering, try adding this somewhere in your map header.

JASS:

function main takes nothing returns nothing
endfunction
 

Bribe

vJass errors are legion
Reaction score
67
That is a ghost function which initializes the map when you load it. You can kill it with a vJass command, I believe.
 

tooltiperror

Super Moderator
Reaction score
231
Yeah, but sometimes when coding vJASS on my Mac, it requires that to be in there, or calling my own functions results in strange syntax errors. Thought it could be connected, apparently not, if you say so.
 

Bribe

vJass errors are legion
Reaction score
67
If you kill the "main" function with that command, you lose access to every InitTrig and initializer and onInit staticMethod. Every program uses "main" to initialize.
 

retupmoc258

New Member
Reaction score
1
What about methods and structures. I don't understand those. I have looked at existing code, but it tremendously above my current understanding. I don't understand libraries with existing and why they work in the first place. I'll see some that seem to be testing what a unit's position and if it moves (one of the structures and methods in EGUI which can test if a unit is moving) and I just don't understand what makes it actually run, and what makes it run and all the .destroy type functions and things like that. Does anyone know of a good tutorial for structures or methods? I don't even know the difference, really. I wonder if I could just make a structure or method that would work for me really well.

I'm trying to make it so when a unit is attacked, my game overrides the built-in damage functions and runs its chain of commands to do the damage calculation. The function I have made works fine, and I have found ways to use "EGUI - Unit takes damage" to make it work. I have run it in a map where there are dozens of people attacking all at once, and there is no noticeable lag, either. But I'm wondering if a stucture or method might make it run faster.

Out of curiosity, does anyone know how to create an event of some sort that runs when teh "Aatk" ability effect takes place? There is the Event, "When a unit is attacked" but that triggers as soon as the attack starts, not when the damage would be dealt. I have tried "When ability starts effect" with condition being "Ability: Aatk" but that doesn't work.
 

tooltiperror

Super Moderator
Reaction score
231
Methods are functions associated with structs, structs are object orientated programming tools.

JASS:

//! Note: This comment serves no purpose
  struct Color
      real red
      real green
      real blue
  endstruct
  function Example takes nothing returns nothing
      local Color red=Color.create() // You create a struct with .create()
      set red.red=100 // You can set the variables that make up red.
      set red.green=0
      set red.blue=0
      call red.destroy() // You don&#039;t need them when you&#039;re done.
  endfunction


See, structs allow you to make your own types, like integers and units and locations. I mean, what is a location but two reals? Then, you have methods.

JASS:

//! Note: This comment serves no purpose
  struct Color
      real red
      real green
      real blue
      method Donothing takes nothing returns nothing
          call DoNothing() 
          call BJDebugMsg(&quot;Doing nothing!&quot;)
      endmethod
  endstruct
  function Example takes nothing returns nothing
      local Color green=Color.create()
      call green.Donothing()
  endfunction
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
At what point would you consider TimerUtils more efficient than KT2?
Jesus4lyf said that by himself.(For low frequency/high period) :)
 
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