"How do I ZScript?"

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!)
User avatar
Major Cooke
Posts: 8197
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

Did you try adding play to the end of your functions? I don't think clearscope is meant to be used like that...

And again, ZZYZX just 'broke' a lot of things with one of his recent commits so he should explain why first. You can backtrack a bit in the mean time and keep going.
User avatar
Nash
 
 
Posts: 17468
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Yes, adding play to some of the classes already helps a lot, it's now down to 46 errors instead of hundreds.

I still don't understand what I'm doing but at this point I just want to get the damn thing to even run first.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49188
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

I think your problems are a textbook case why the separation is needed. A mod that liberally mixes these things is bound to cause problems at some point in the future.
The thing is, creating menus that don't screw up the game state is very important and it is very easy and very tempting to do it wrong.
User avatar
Major Cooke
Posts: 8197
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

Ed the Bat:

Code: Select all

class MGTauntHandler : EventHandler
{
	override void ConsoleProcess(ConsoleEvent ev)
	{
		if (ev.Name == "MGTauntHandler")
			EventHandler.SendNetworkEvent("DoATaunt", 0, 0, 0);
	}
	
	override void NetworkProcess(ConsoleEvent ev)
	{
		if (ev.Name == "DoATaunt")
		{
			let plr = players[ev.Player].mo;
			if (plr)
				plr.A_PlaySound("*taunt",CHAN_VOICE);
		}
	}
}
While this will fix your boot-up problem, I can't guarantee it'll actually work itself. But at least you can start the game up again.

Allow me to explain: NetworkProcess is the place where you want to do stuff, because network compatibility matters.
User avatar
Nash
 
 
Posts: 17468
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Graf Zahl wrote:I think your problems are a textbook case why the separation is needed
The bulk of those hundreds of errors came from trying to Get the global thinker, which was code that you gave. I just followed whatever you gave me.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49188
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

No, those hundreds of errors came from using some very non-standard ways of doing stuff.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: "How do I ZScript?"

Post by Ed the Bat »

Major Cooke: Thanks, but it doesn't seem to work.
User avatar
Nash
 
 
Posts: 17468
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Code: Select all

class Z_Time play
{
	/*
	 * Gets current second of minute.
	 */
	static int T_GetSecond(void)
	{
		let bumi = FWorld.Get();
		return bumi.timeSecond;
	}
}

class FLocalWorld : Thinker
{
	FLocalWorld Init()
	{
		ChangeStatNum(STAT_INFO);
		return self;
	}

	static clearscope FLocalWorld Get()
	{
		ThinkerIterator it = ThinkerIterator.Create("FLocalWorld", STAT_INFO);
		let p = FLocalWorld(it.Next());
		if (p == null)
		{
			p = new("FLocalWorld").Init();
		}
		return p;
	}
}

How much non-standard can this get? This is literally all it's doing. It's your solution that you gave me. I didn't do anything different from what you suggested before.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49188
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

Having a class to host a single static function is pretty much non-standard, especially when all it does is calling a function from anothzer class and returning a value from that object. I would have put it into FWorld itself.

I wish there was a way to automate assignment to one of the two sides to avoid having to declare this explicitly 'play'.
User avatar
Nash
 
 
Posts: 17468
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

Alright, I will try putting every static method I use into that one FWorld class and report back whever it works or not later.

(No it's not just a single static function I'm using, there's actually several. I only posted one to save forum space)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49188
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: "How do I ZScript?"

Post by Graf Zahl »

And they still don't work after setting the classes to 'play'?
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: "How do I ZScript?"

Post by Ed the Bat »

kodi wrote:Okay. Target.ACS_NamedExecuteAlways with a property changing script works until then.
How did you get it to work? I still get this error trying to call any ACS_* functions
User avatar
Major Cooke
Posts: 8197
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: "How do I ZScript?"

Post by Major Cooke »

Ed the Bat wrote:Major Cooke: Thanks, but it doesn't seem to work.
You have to bind a key to it and press it.

bind kp* "event MGTauntHandler"

Events fired from the console won't exactly work the same anymore.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: "How do I ZScript?"

Post by Ed the Bat »

Ah, I see. I had to change that from "netevent" to just "event". Thanks, it's working again.
User avatar
Nash
 
 
Posts: 17468
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: "How do I ZScript?"

Post by Nash »

MajorCooke was kind enough to help me fix my game, MC you da real OG.

It runs now... hopefully there won't be any bugs.

Return to “Scripting”