Hmm, that's actually not a bad idea. I'll look into that next time I'm toying with that branch.Gez wrote:Ideally it'd ouput raw wikicode and then a wikibot could automatically put it.
ZScript Discussion
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!)
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!)
-
-
- Posts: 3132
- Joined: Sat May 28, 2016 1:01 pm
Re: ZScript Discussion
-
- Lead GZDoom+Raze Developer
- Posts: 49179
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: ZScript Discussion
They are virtual methods of Menu, so ListMenu shouldn't duplicate them on the script side as long as they are natively implemented. You can already use them.Nash wrote:Ok understood. And what about the commented out Responder, MenuEvent, MouseEvent, Ticker and Drawer methods for ListMenu? Will they eventually be virtual?Graf Zahl wrote:Yes, it is a menu. No, for the time being there won't be any more scriptification. Maybe later.
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
String.Format seems to read new lines (when you press Enter) instead of ignoring them... bug or intended feature?
Asking because in ACS, you can put as many new lines as you want and they will be ignored.
Asking because in ACS, you can put as many new lines as you want and they will be ignored.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
??? What do you mean read instead of ignoring and how is this related to String.Format?
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
Code: Select all
String s = String.Format("Health: %d\nLevel: %d\nExperience: %d", health, level, experience);
Result:
Health: 100
Level: 1
Experience: 0
String s = String.Format("Health: %d
\nLevel: %d
\nExperience: %d",
health, level, experience);
Result:
Health: 100
Level: 1
Experience: 0
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
That's not a problem with String.Format. That's a problem with ZScript's string literal parsing. Not sure if it's a problem anyway.
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
Ah, okay. Well it doesn't do that in ACS, and I can't imagine shoving all this into 1 line, soooo...
Code: Select all
function void DebugText_Weather(void)
{
PrintDebugString(StrParam(
s:"bumi.timeUpdateTics = ", d:bumi.timeUpdateTics,
s:"\n",
s:"bumi.timeUpdateInc = ", d:bumi.timeUpdateInc,
s:"\n",
s:"bumi.timeUpdateTicDelay = ", d:bumi.timeUpdateTicDelay,
s:"\n",
s:"bumi.timeTotalDays = ", d:T_GetTotalDays(),
s:"\n",
s:"bumi.timeDayOfWeek = ", d:1 + T_GetDayOfWeek(),
s:"\n", s:"date (Short) = ", s:T_GetDateString(DATE_SHORT),
s:"\n", s:"date (Long) = ", s:T_GetDateString(DATE_LONG),
s:"\n",
s:"TotalSecondOfDay = ", d:T_GetSecondOfDay(),
s:"\n", s:"time (24hr) = ", s:T_GetTimeString(false, DATE_LONG),
s:"\n", s:"time (12hr) = ", s:T_GetTimeString(true, DATE_LONG),
s:"\n", s:"date + time (24hr) = ", s:T_GetDateString(DATE_LONG), s:" ", s:T_GetTimeString(false, DATE_LONG),
s:"\n", s:"date + time (12hr) = ", s:T_GetDateString(DATE_LONG), s:" ", s:T_GetTimeString(true, DATE_LONG),
s:"\n", s:"This month has ", d:bumi.monthDay[bumi.timeMonth - 1], s:" days",
s:"\n",
s:"clouds = ", d:ThingCountName("Z_Cloud1", 0) + ThingCountName("Z_Cloud2", 0),
s:"\n",
s:"bumi.overcast = ", d:W_GetOvercast(),
s:"\n",
s:"bumi.overcastLastHour = ", d:_W_GetOvercastLastHour(),
s:"\n",
s:"bumi.overcastTransitionCounter = ", d:_W_GetOvercastTransition(),
s:"\n",
s:"desat = ", d:bumi.desat,
s:"\n",
s:"bumi.raining = ", d:W_GetRaining(),
s:"\n",
s:"bumi.rainingTransitionCounter = ", d:_W_GetRainingTransition(),
s:"\n",
s:"raindrops = ", d:ThingCountName("Z_RainDrop", 0),
s:"\n",
s:"bumi.thunderstorm = ", d:W_GetThunderstorm(),
s:"\n",
s:"bumi.foggy = ", d:W_GetFoggy(),
s:"\n",
s:"bumi.foggyTransitionCounter = ", d:_W_GetFoggyTransition(),
s:"\n",
s:"fog alpha ", f:W_GetFogAlpha(),
s:"\n",
s:"bumi.snow = ", d:W_GetSnow(),
s:"\n",
s:"bumi.snowTransitionCounter = ", d:_W_GetSnowTransition(),
s:"\n",
s:"snow + mist = ", d:ThingCountName("Z_Snow", 0) + ThingCountName("Z_Mist", 0),
s:"\n",
s:"sun alpha counter = ", d:bumi.sunAlphaCounter, s:" / ", d:bumi.sunAlphaCounterMax, s:" = ", f:bumi.sunAlpha,
s:"\n",
s:"bumi.sunAngle = ", f:bumi.sunAngle,
s:"\n",
s:"moon alpha counter = ", d:bumi.moonAlphaCounter, s:" / ", d:bumi.moonAlphaCounterMax, s:" = ", f:bumi.moonAlpha,
s:"\n",
s:"bumi.moonAngle = ", f:bumi.moonAngle,
s:"\n",
s:"moon phase = ", d:bumi.moonPhase,
s:"\n",
s:"outside sectors = ", d:bumi.outsideSectorStart, s:" ~ ", d:bumi.outsideSectorEnd,
s:"\n",
s:"bumi.puddleCounter = ", d:bumi.puddleCounter,
s:"\n",
s:"day ", d:W_CheckDay(), s:" night ", d:W_CheckNight(),
s:"\n",
s:"skydome alpha ", f:bumi.skyDomeRandomAlpha, s:" target ", f:bumi.skyDomeRandomAlphaTarget,
s:"\n",
s:"stars alpha ", f:bumi.starsRandomAlpha, s:" target ", f:bumi.starsRandomAlphaTarget,
s:"\n",
s:"season = ", s:StrToLower(T_GetSeasonName())
));
}
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
I'd advise you to just remove the \n since regular newline works (in ZScript).
Or even using AppendFormat().
Or even using AppendFormat().
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
Assuming one day it won't be "fixed" and suddenly regular newlines get discarded and therefore breaking the text layout...
I'll take a look at AppendFormat, thanks.
I'll take a look at AppendFormat, thanks.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript Discussion
Please JSON or XML, not some already done format. It's fairly straightforward to output raw wikicode using a Python/PHP/JS/Perl/whatever script and XML/JSON.dpJudas wrote:Hmm, that's actually not a bad idea. I'll look into that next time I'm toying with that branch.Gez wrote:Ideally it'd ouput raw wikicode and then a wikibot could automatically put it.
-
- Posts: 265
- Joined: Mon Jan 24, 2011 6:04 pm
Re: ZScript Discussion
ACS != zscriptNash wrote:Ah, okay. Well it doesn't do that in ACS, and I can't imagine shoving all this into 1 line, soooo...
This should probably be guarded against in the grammar. How that even works in ACS is amazing, though. I would follow the advice and use AppendFormat for now. Maybe some form of compile-time string concatenation could be a possibility in the future? Would be cleaner than this for longer string literals.
-
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: ZScript Discussion
Nowhere else anywhere in DECORATE, ZScript or ACS (or, for that matter, HTML) have I ever seen regular carriage returns parsed like this. This is really off-puttingly and confusingly inconsistent. If there's a vote I vote this gets "fixed".
-
- Posts: 4349
- Joined: Sun Feb 06, 2005 6:39 am
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Capital of Explodistan
Re: ZScript Discussion
I'd consider it a problem especially if you're used to.. just about any known language not doing that.ZZYZX wrote:That's not a problem with String.Format. That's a problem with ZScript's string literal parsing. Not sure if it's a problem anyway.
-
-
- Posts: 10773
- Joined: Sun Jul 20, 2003 12:15 pm
Re: ZScript Discussion
This is a tricky situation to handle, but not for the reasons folks are pointing out.
Suppose I write the following block of code:
[This is technically a poor use case for String.Format since we don't have any parameters, but I digress.]
Now, we've discussed newlines, but a bigger problem becomes obvious when we take a look at how the engine views the string 's' (where '\n' represents a newline.):
Whoops! We've got spaces in the string too because of our indentation. Even if we "fix" the newline issue, we've got to also collapse the extra space, which blocks other use cases (e.g. trying to align stuff with a monospace font on screen). That's a no-go.
Fortunately, we've got a string concatenation operator, so let's instead write:
Voila! Desired behavior achieved.
[This is the part where the StringBuilder proponents chime in; I dunno if ZScript has an equivalent, so I'll leave it to those folks to weigh the pros and cons.]
P.S. though HTML (in)famously condenses consecutive whitespace into a single space, the problem still leaks through on occasion. Read this page if you're overdue for some eye-bulge therapy.
Suppose I write the following block of code:
Code: Select all
class Something : Actor
{
...
action void PrintSomeStuff() {
String s = String.Format("This is a long piece of exposition. It's longer
than a sentence, so I'm splitting it across
multiple lines in order to preserve my sanity.");
A_Print(s);
}
...
}
Now, we've discussed newlines, but a bigger problem becomes obvious when we take a look at how the engine views the string 's' (where '\n' represents a newline.):
Code: Select all
"This is a long piece of exposition. It's longer\n than a sentence, so I'm splitting it across\n multiple lines in order to preserve my sanity."
Fortunately, we've got a string concatenation operator, so let's instead write:
Code: Select all
class Something : Actor
{
...
action void PrintSomeStuff() {
String s = String.Format("This is a long piece of exposition. It's longer\n"
.. "than a sentence, so I'm splitting it across\n"
.. "multiple lines in order to preserve my sanity.");
A_Print(s);
}
...
}
[This is the part where the StringBuilder proponents chime in; I dunno if ZScript has an equivalent, so I'll leave it to those folks to weigh the pros and cons.]
P.S. though HTML (in)famously condenses consecutive whitespace into a single space, the problem still leaks through on occasion. Read this page if you're overdue for some eye-bulge therapy.
-
-
- Posts: 17465
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ZScript Discussion
Actually that's what I already resorted to doing earlier, in fact you don't even need the .., just put the new quotes on the next line. Stumbled on this solution while having a look at GZDoom's very own MAPINFO LANGUAGE lump.
And just as a BTW - WRT to the "spaces" - the parser seems to happily ignore Tabs (but not newlines????????) so that just seems wildly inconsistent to me.
EDIT: sorry not MAPINFO, I mean the intermission strings inside GZDoom's LANGUAGE lump
And just as a BTW - WRT to the "spaces" - the parser seems to happily ignore Tabs (but not newlines????????) so that just seems wildly inconsistent to me.
EDIT: sorry not MAPINFO, I mean the intermission strings inside GZDoom's LANGUAGE lump
Last edited by Nash on Mon Feb 20, 2017 10:40 am, edited 4 times in total.