Page 1 of 2

Scripts for Start/Stop PDAs?

PostPosted: Sat Jul 13, 2019 4:16 pm
by Enjay
Just wondering what the best way to make multiple PDA messages would be. I plan on making a bunch of PDA items that will be scattered around the map for the player to find. Each PDA will be a persistent inventory item (persistent so that it can be read multiple times) and using it from the inventory would run a script. The script would put up a HUDmessage with text and an image (and maybe play an audio log or something).

My current thoughts on how I'd like them to behave are:

Each inventory item will run the same script but will have in its DECORATE code an ACS Execute instruction of some sort (probably ACS_ExecuteAlways will be required) plus a parameter to make sure it plays the correct message (different messages separated inside the script with "if" statements).

So far, so good and I can do all of that. However, I'm tying myself in knots trying to sort out what happens if a second PDA messages is played when one is already running or if the player wants to interrupt the currently playing message (preferably by using the inventory item again (i.e. each PDA can start and stop its own message)).

So, what I'm maybe thinking is:

an overall variable for "a message is currently playing" which, if true will do something like override the HUDmessage on screen with a blank one. This script would do this check first.

A second message specific variable used to check if the message associated wit the used PDA is running. If false, the variable is set and the message gets played. If true... um, nothing happens because the messages have already been cancelled by the earlier over all check. So, maybe that variable is not needed after all.

However, the above strikes me as a bit clumsy and possibly prone to breaking. I'm sure that eventually I could hack something together that would work but can anyone suggest some better logic (and even provide some code)?

And, lastly, I don't know if I will use sound files but, if I do, what's the best way to start/stop a sound being played by ACS? I'm thinking LocalAmbientsound for the playing (simple enough) but I'm not sure how to stop a sound that was started using that. To be fair, audiologs are unlikely but I'd like to know anyway.

I've mentioned DECORATE and ACS above and those would be my preferences but I'm not averse to ZScript. It's just that nothing else in the project is currently using ZScript.

Re: Scripts for Start/Stop PDAs?

PostPosted: Sat Jul 13, 2019 6:00 pm
by 22alpha22
If my memory serves me correctly, RTC-3057 had a PDA system something like your describing. I could be wrong since it has been about a decade since I played it but it might be worth looking into. ... 9/3057hub1

Re: Scripts for Start/Stop PDAs?

PostPosted: Sat Jul 13, 2019 11:07 pm
by Nash
Hey Enjay, I tried doing a DECORATE+ACS system but it turns out that managing and getting to currently-running ACS scripts was quite difficult. I'd originally made it so that activating a PDA would run a named script (the script names would have been assigned on a PDA-to-PDA basis)... stopping the same instance of the script was easy - when I activate Henry's PDA, the text and audio gets played; when I activate it again, the PDA gets stopped correctly. But say in the middle of Henry's PDA, I switch over to John's PDA. This was where it started to get quite difficult to find a way to stop Henry's PDA.

I think you were already facing this problem, hence why you made this thread. :P

So, I came up with something else. Now, it is ZScript-based, but the front-facing part that you edit is made in DECORATE. Technically, this is not unlike what you are already doing in GZDoom - the base actors are written in ZScript inside gzdoom.pk3, after all. :)

Here's what it would look like from your editing perspective, in DECORATE.

Code: Select allExpand view

: EnjayPDA
    EnjayPDA.Text "$PDA_TestPDA"
    EnjayPDA.Image "graphics/Test PDA Image.png"
    EnjayPDA.Audio "PDA/TestPDAAudio"

            MEDI A -1

The "Text" property can either be written directly on the actor, or it could reference a LANGUAGE lump. The reason my example uses the LANGUAGE lump is because for really long, multi-line text, it's not possible to format it in a way that's easy to edit directly inside the DECORATE file. For short, single-line logs, you can just write it directly inside that actor definition.

It is okay to omit any of the properties. Omitting the Audio property would mean the PDA won't play any sounds, for example. Same goes for the image and even text.

The ZScript stuff is neatly tucked away behind the scenes, so you don't have to worry about it.

How to use:

There are 2 PDAs you can test. give testpda and give testnote. Use the inventory bar to activate them. Activating the same PDA while it is playing will stop it. You can activate another PDA while the previous one is still playing.

I'm unsure if this system is something you can work with, so feel free to give it a go. If it works for you, then great. :) Otherwise, that's fine. Maybe someone else can either use this system or come up with something easier.

If you have any questions or suggestions, let me know. ... A.pk3?dl=1

Re: Scripts for Start/Stop PDAs?

PostPosted: Sun Jul 14, 2019 5:01 am
by Enjay
Heh, yeah, it seems like we got to exactly the same point and then got stuck right enough. The sample file that you posted does exactly what I am looking for. I'll have to look into it properly to see exactly how it's done but, yes, that's precisely the kind of system that I am trying to achieve.

Re: Scripts for Start/Stop PDAs?

PostPosted: Sun Jul 14, 2019 6:17 am
by Nash
Would you have any objections if I attempted to make this into a much more proper PDA toolkit? I was thinking of making the PDA an actual menu, instead of some floating overlay and having to fumble with the invprev/invnext keys.

Making it into an actual menu will allow it to operate exactly as all of GZDoom's built-in menus. It would pause the game (can be optionally set to not pause the game), pull up a fullscreen display and respect the user's scaling options for the image and text, will invoke the menu blur if there is one, you'd be able to navigate it with either keyboard or mouse, etc etc. Basically every behaviour that comes with an internal menu.

So, being an actual menu, I could then add a fancier user interface that shows you a list of all the PDAs you've picked up, with buttons to go to the previous or next PDA, or close the PDA screen (and therefore stop playing the audio too). Very long PDA text would then also be possible, allowing you to flip through multiple pages of text.

On the front-facing side, you would still create your PDAs the same way as my DECORATE snippet. It will continue to remain simple. The only difference would be, instead of having multiple PDA objects in your inventory, you'd only have a single PDA object - activating this will bring up the PDA menu. I think it'd help to keep the actual inventory bar tidy, too.

Re: Scripts for Start/Stop PDAs?

PostPosted: Sun Jul 14, 2019 1:14 pm
by Enjay
Would I have any objections? Of course not, that sounds amazing and I'm sure it would benefit many people.

You've already covered all the potential drawbacks that I had considered myself (the possibility of inventory clutter, too many points of entry into the system etc). A single unified system like you describe (and much more like how modern game do it) would be really nice to see.

Re: Scripts for Start/Stop PDAs?

PostPosted: Mon Sep 09, 2019 3:39 am
by Nash

A quick update on the PDA system... it's pretty much working at this point, just need to iron out a few non-user-facing issues with the code. The UI isn't really that customizable beyond replacing a few graphics to reskin the look, maybe at most I'd expose changing the colour of the text and scrollbar, and the font, but that's about it I think. Any more than that, and it would be too specific to include in a general-purpose PDA toolkit, and I'd expect anyone who wants that level of customization to edit the ZScript on their own. :P

Making PDA content is easy as before - you can do it in either DECORATE or ZScript. There will be properties to set the PDA text, sound, and a single image to use as the content background. Currently the controls are mouse-only, I will figure out how to add keyboard controls when everything is 100% done.

Picking up a PDA - any PDA - will add a "PDA Reader" to your inventory. You activate this item, and this menu pops up. Any future PDAs you pick up will be added to the list. It's very clean.

I'd like to give a HUGE thanks to Gutawer and phantombeta for creating the ZForms library; without which, this would have been an absolute NIGHTMARE to code. ZForms makes creating custom GUIs in ZScript stupid easy, it really should be implemented into GZDoom to be frank. :P

Anyway, more updates as it develops.

Re: Scripts for Start/Stop PDAs?

PostPosted: Mon Sep 09, 2019 10:14 am
by Enjay
That looks very neat indeed. I notice, however, that the interface seems to be mainly a text-based one. Using your older code, I set up each PDA that I was working with to have its own character image. Could anything similar be incorporated?


I'm currently working with 21 different PDAs so they really do clutter up the inventory (as expected) but, when displayed, they look great (IMO).

If that can't be included, your interface looks very useful - neat and simple. I'd just have to decide whether I wanted to go with clutter but character portraits, or neatness and usability with less visual stuff.

Re: Scripts for Start/Stop PDAs?

PostPosted: Mon Sep 09, 2019 10:55 am
by Cherno
May an alternative to having seperate PDAs for each message would be to have only one as an inventory item, and then when one is picked up it gets added to the player inv as a non-invbar dummy item that only serves to aknowledge that the player has found this specific one. When using the "real" PDA, when cycling, the player's inv gets checked for the next message in line until one is found.

Re: Scripts for Start/Stop PDAs?

PostPosted: Mon Sep 09, 2019 11:00 am
by Nash
Enjay: That's a very specific UI design you're doing, which I had no way of knowing beforehand. :) I tried to make mine as generic as possible, without assuming what designs the modder wants for their PDA UI.

That said, I can easily tack on a face frame to the existing one, however it'd have to be a specific modification only for your project.

I will release the generic, faceless one first in a separate thread.

[EDIT]: What dimensions are the portrait images?

Re: Scripts for Start/Stop PDAs?

PostPosted: Mon Sep 09, 2019 11:55 am
by Enjay
Nash wrote:Enjay: That's a very specific UI design you're doing, which I had no way of knowing beforehand. :)

That's OK, I was just playing around with your original one and I thought "hang on, I can give every PDA its own image".

Nash wrote:[EDIT]: What dimensions are the portrait images?

I'm using a bit of a cheat. The images are all 640x384 with the actual PDA part offset to the right. That way I could just use your code to print the image centrally but it would look offset and I could place the text on the left (I messed around with the font size/spacing a little). It also means that if I use PDAs of a slightly different appearance/dimension (which I have done) I can still just slap them on to a 640x384 background and it works. The actual PDA parts of the images shown are 256x384.

Of course, they don't have to be exactly those sizes. I just found that they looked pretty decent like that.


[edit] gonna investigate the stuff that you posted in the other thread now :) [/edit]

[edit2] And I have now checked it. It's phenomenal! Really neat stuff. I wonder if, to solve my portraits issue it would be possible "just" to print the portrait in a similar way to your strange map image, but use it as a background to the text?

Very dirty mockup...

It's not ideal because it hides the image but... I dunno, it might work. [/edit2]

Re: Scripts for Start/Stop PDAs?

PostPosted: Mon Sep 09, 2019 12:09 pm
by Nash
That was a fast mockup. :) Anyway, as I said, I can modify it to show the face on the side. Now that I know what kind of look you're going for, I know what exactly to change. It has to be a modification specific to your mod though, based on the look you showed in your screenshots. I can't do it in a generic way while still keeping the base kit useful as a clean template.

Re: Scripts for Start/Stop PDAs?

PostPosted: Mon Sep 09, 2019 10:13 pm
by Nash
@Enjay: Can you post the PDA texture, without the face? I have a cool idea. :)

Re: Scripts for Start/Stop PDAs?

PostPosted: Tue Sep 10, 2019 2:29 am
by Enjay
Just the blank PDA? Sure.

However, guessing what you might be planning, I could have a fly for the ointment. Remember that I mentioned that I am using a few different PDAs? They're not all the same size (the idea being that different groups/factions would have different PDAs). However, if need be, I could change that.

The first two are the important ones. They are actually both the same size (256x384) but their screens are different sizes. The first one is the one that I have used most commonly, the seconds less so. The third one was just for an Easter egg/joke and could easily be removed - so don't worry about that one if it's at all problematic. To be fair, with a bit of editing, I could probably make the second one comply a bit more with the screen dimensions of #1.


I really appreciate your help (actually, not so much "help" as doing it - I'm not really helping here) with this BTW. It would be beyond me to get something like this working. Even your original was brilliant IMO but I can see your new starter kit one being very useful to many people. :yup:

Re: Scripts for Start/Stop PDAs?

PostPosted: Tue Sep 10, 2019 3:45 am
by Nash
Understood. I think some new properties can be added to the PDA pickup actors:


Name and occupation should be self explanatory. Portrait would be a string to the texture path of the face graphic, and PDATexture would be the device.

I am planning to reskin and reshuffle my entire kit's layout to imitate the exact design as you've shown in the screenshots. I will be grafting the functionality of the 4 new properties on to the existing PDA, so the other stuff that was in before will still be available for you to use (audio, text, image) and will just work as before. I think owner-less PDA pickups can still be useful; like let's say you wanted to make a scribbled note containing cryptic clues to a puzzle. Don't worry, it's not that much trouble - ZForms makes it easy to do this. :)