(Zscript) using a non static function outside the class

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Zen3001
Posts: 412
Joined: Fri Nov 25, 2016 7:17 am
Location: some northern german shithole

(Zscript) using a non static function outside the class

Post by Zen3001 »

I want to use LineTrace() from the linetracer class in the DrawStatusBar class() or a class inherited from DrawStatusBar to be exact and I still have no idea how I'm supposed to do that.
I tried creating a static function but I get an error telling me "non static function called in a static context" (something like that), when I remove the static keyword it tells me that the function LineTrace() is unknown
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: (Zscript) using a non static function outside the class

Post by Graf Zahl »

In short: You can't! Any non-static function requires an instance of its containing class to work.
User avatar
Zen3001
Posts: 412
Joined: Fri Nov 25, 2016 7:17 am
Location: some northern german shithole

Re: (Zscript) using a non static function outside the class

Post by Zen3001 »

anyway arround it then? The information for the parameters it requires can only be found in the DrawStatusBar class (CPlayer.mo. and something like that)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: (Zscript) using a non static function outside the class

Post by Graf Zahl »

No way around it. Think about the calling class as an additional parameter. And if you leave out some required parameter from a normal function (e.g. call a print function without text) it cannot function. The same applies here.
Post Reply

Return to “Scripting”