ZScript Discussion

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.

Re: ZScript Discussion

Postby Graf Zahl » Wed Apr 12, 2017 9:00 am

The compiler is well capable of resolving an anonymous function with just a single function in it to call the inner function directly.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Major Cooke » Wed Apr 12, 2017 9:10 am

What about multiple functions inside of the anonymous function?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Graf Zahl » Wed Apr 12, 2017 9:24 am

In that case a VM script function needs to be created because a state can only hold one function pointer.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby Gutawer » Mon Apr 17, 2017 12:35 pm

https://streamable.com/w9dcc
Should this be doable? Seems like it should be unintended, but I don't want to make a report on mantis since I'm not sure this is actually a bug. Done with this code, for testing:
Code: Select allExpand view
Class BreakEverythingMaybe : EventHandler {
   override void UiTick() {
      EventHandler.SendNetworkEvent("BreakEverything?");
   }
   
   override void NetworkProcess(ConsoleEvent e) {
      if (e.Name == "BreakEverything?") {
         ThinkerIterator spinnyIterator = ThinkerIterator.Create("Zombieman");
         Actor(spinnyIterator.Next()).angle += 1;
      }
   }
}
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: ZScript Discussion

Postby ZZYZX » Mon Apr 17, 2017 1:27 pm

That's exactly what SendNetworkEvent is for.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

Re: ZScript Discussion

Postby Xaser » Sat Apr 22, 2017 2:02 pm

Quick question: can we define const arrays in the namespace yet? The wiki claims so, but the example provided (and a few other permutations I tried) causes a syntax error when used outside of a function.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: ZScript Discussion

Postby Major Cooke » Tue Apr 25, 2017 2:14 pm

Meant anonymous functions, not namespace. Fixed.

Anyway, no, it's not possible right now outside of functions. That or my memory is fried.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Graf Zahl » Tue Apr 25, 2017 3:03 pm

I have added static const arrays inside classes. Unless something broke they should work. The initial problem here was the memory organization as implemented by Randi. I had to refactor a lot of the data into static memory before I could make these arrays work without becoming a drag, that's wgy it took longer.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: ZScript Discussion

Postby D2JK » Tue Apr 25, 2017 3:22 pm

Would it be possible to extend the usable range of the AimTarget() function, or preferably, add a range option as a parameter? I'm using this function in my sniper rifle code, but its current maximum range is insufficient with distant targets.
D2JK
 
Joined: 30 Aug 2014

Re: ZScript Discussion

Postby Lavender Moon » Wed Apr 26, 2017 8:16 pm

How do you convert a String to a StateLabel? I need an array of state labels, and ZScript doesn't support arrays of StateLabels.
Lavender Moon
 
Joined: 21 May 2015

Re: ZScript Discussion

Postby Gutawer » Thu Apr 27, 2017 9:53 am

This is better suited for the "How do I ZScript?" (viewtopic.php?f=3&t=55073) thread, but to answer the question - you can use the ResolveState function, for example:
Code: Select allExpand view
ResolveState(<state string>)
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: ZScript Discussion

Postby Lavender Moon » Thu Apr 27, 2017 3:08 pm

Whoops, got this thread confused for that one. ResolveState doesn't work, BTW. It only accepts strings at compile time, not runtime.
Lavender Moon
 
Joined: 21 May 2015

Re: ZScript Discussion

Postby Major Cooke » Wed May 03, 2017 6:26 pm

Use a StateLabel instead of a String as the variable type.

Code: Select allExpand view
StateLabel next = "yourstatehere";
return ResolveState(next);
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript Discussion

Postby Chl » Mon May 08, 2017 11:29 am

I've been out of the loop for over a year and now I'm trying to read up on what this is. But I'm no programmer so I can't really understand what I can do with this. So my question is, what can I do with ZS that wasn't possible before? And with that I mean stuff that affects gameplay/visuals/engine and that is not possible with ACS or decorate.
User avatar
Chl
 
Joined: 05 Dec 2015

Re: ZScript Discussion

Postby Enjay » Mon May 08, 2017 12:33 pm

Sorry if this has been discussed already but there are 118 pages here.

I understand that on startup, ZScript is processed first, then DECORATE. What would happen if a ZScript actor made reference to a DECORATE actor in its definition (e.g. the ZScript actor spawned a DECORATE actor (say as a projectile), or had an inventory check for a DECORATE actor etc etc.)
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest