• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Code

Status
Not open for further replies.
Level 17
Joined
Dec 11, 2014
Messages
2,004
How can I change the limiting function of function something? I have multiple TimerStarts and I need to use method something for example, which doesn't compile.

Also, I want to call a native by a timer, but native ClearTextMessages doesn't compile as well. I must have a BJ-With-No-Particular-Use function to do that.

JASS:
        private function ClearTextMessage takes nothing returns nothing
            call ClearTextMessages()
        endfunction
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
A method is still a function.

Just use "function thistype.something" instead of "method something".
Remember that only static methods can be called.

Are you also sure that you wrote "function ClearTextMessages" and not "native ClearTextMessages"?
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
A method is still a function.

Just use "function thistype.something" instead of "method something".
Remember that only static methods can be called.

Are you also sure that you wrote "function ClearTextMessages" and not "native ClearTextMessages"?

thistype and static methods?? I think you mean the strucname, right? Because structname.method worked. Thanks a lot.

Second one worked (function ClearTextMessages not native ClearTextMessages).

Solved.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Do be aware that this does not work for non-static methods. Non-static methods are internally implemented as functions with a struct reference parameter. Timers, actions and conditions must be functions with no parameters and hence non-static method functions cannot be used.

To use non-static methods in code you need to use a static method or function which recalls the struct reference from some data management system (eg hashtable used to map it to the expiring timer) and then call the method from the struct reference.
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
thistype is the same as the struct name of the current struct.

It is for convenience in "local thistype this" and "function thistype.foo" etc.

Dont forget to +rep and donate to me :D

I will, but nobody sees your rep :p

Do be aware that this does not work for non-static methods. Non-static methods are internally implemented as functions with a struct reference parameter. Timers, actions and conditions must be functions with no parameters and hence non-static method functions cannot be used.

To use non-static methods in code you need to use a static method or function which recalls the struct reference from some data management system (eg hashtable used to map it to the expiring timer) and then call the method from the struct reference.

I am not using instance members, actually no instance hopefully. I just liked the "." syntax therefor I'm using it. Thanks anyways!

mmmhmmm, +rep to both of you
 
Status
Not open for further replies.
Top