{x} to use - interactable actor prompt on hud

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
hvgcore
Posts: 5
Joined: Thu Aug 22, 2024 6:03 pm
Preferred Pronouns: She/Her

{x} to use - interactable actor prompt on hud

Post by hvgcore »

How would I go about scripting a hud element that appears next to the crosshair when looking at an interactable actor? Selaco has the exact kind that I want but the scripting for it is a lot more complex than I'd need.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: {x} to use - interactable actor prompt on hud

Post by ramon.dexter »

So, what do you think? The coding for such task IS pretty complex.
User avatar
R4L
Global Moderator
Posts: 426
Joined: Fri Mar 03, 2017 9:53 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Pro
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: {x} to use - interactable actor prompt on hud

Post by R4L »

ramon.dexter wrote: Wed Nov 06, 2024 12:42 am So, what do you think? The coding for such task IS pretty complex.
While I agree with the latter part of your post, why must you always put a sarcastic spin on things?
hvgcore wrote: Tue Nov 05, 2024 9:09 pm How would I go about scripting a hud element that appears next to the crosshair when looking at an interactable actor? Selaco has the exact kind that I want but the scripting for it is a lot more complex than I'd need.
Only thing I can suggest is checking out how Selaco did it or how other mods display information on the HUD and start from there.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: {x} to use - interactable actor prompt on hud

Post by ramon.dexter »

So, dude wants pretty complex function to add, but he doesnt like how complex the coding is. If the functionaly could be achieved with some simple coding, the simple coding would be already used. But if the functionality is missing, it usually involves a lot of custom complex coding.

I've just learned that lots of 'simple visual things' involves a big load of custom coding in the backside.
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1120
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: {x} to use - interactable actor prompt on hud

Post by Jekyll Grim Payne »

ramon.dexter wrote: Thu Nov 07, 2024 12:44 am So, dude wants pretty complex function to add, but he doesnt like how complex the coding is. If the functionaly could be achieved with some simple coding, the simple coding would be already used. But if the functionality is missing, it usually involves a lot of custom complex coding.

I've just learned that lots of 'simple visual things' involves a big load of custom coding in the backside.
How about you don't participate in a thread if you have nothing relevant to say? OP asked as question. You're not answering it. And how complex it is, is debatable.
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1120
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: {x} to use - interactable actor prompt on hud

Post by Jekyll Grim Payne »

hvgcore wrote: Tue Nov 05, 2024 9:09 pm How would I go about scripting a hud element that appears next to the crosshair when looking at an interactable actor? Selaco has the exact kind that I want but the scripting for it is a lot more complex than I'd need.
This boils down to what should be considered an "interactable actor." There's no universal identifier of such a thing. Any actor can be made interactable, provided it has the SOLID flag, and its Used() virtual function is overridden; thus, it's not possible to determine if a specific actor is interactive or not from outside. So, if these are your own actors and you have full control over them, your first task would be to come up with an actual identifier for something like this (such as a custom flag, for example).

Other than that, attaching an example of how to do this. This will print a prompt for any actor. You can modify the custom isActorInteractable function to add custom conditions instead.
InteractionPrompt.zip
(1.95 KiB) Downloaded 16 times
User avatar
hvgcore
Posts: 5
Joined: Thu Aug 22, 2024 6:03 pm
Preferred Pronouns: She/Her

Re: {x} to use - interactable actor prompt on hud

Post by hvgcore »

Jekyll Grim Payne wrote: Thu Nov 07, 2024 4:27 am
hvgcore wrote: Tue Nov 05, 2024 9:09 pm How would I go about scripting a hud element that appears next to the crosshair when looking at an interactable actor? Selaco has the exact kind that I want but the scripting for it is a lot more complex than I'd need.
This boils down to what should be considered an "interactable actor." There's no universal identifier of such a thing. Any actor can be made interactable, provided it has the SOLID flag, and its Used() virtual function is overridden; thus, it's not possible to determine if a specific actor is interactive or not from outside. So, if these are your own actors and you have full control over them, your first task would be to come up with an actual identifier for something like this (such as a custom flag, for example).

Other than that, attaching an example of how to do this. This will print a prompt for any actor. You can modify the custom isActorInteractable function to add custom conditions instead.

InteractionPrompt.zip
This is perfect! Thank you so much for this.

This will mostly be used for actors (items) that have an ACS script attached, or NPCs with dialogue. So a custom flag is the way to go I think. Thanks for the concise help!

EDIT: Getting 'Cannot use a named argument here - not all required arguments have been passed'

for line 41:
tracer.Trace(start, mo.cursector, dir, mo.radius + mo.userange, traceflags: 0, wallmask: 0, ignore: mo);
Tried adding it myself but don't think I've got the wording right
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1120
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: {x} to use - interactable actor prompt on hud

Post by Jekyll Grim Payne »

hvgcore wrote: Sun Nov 10, 2024 6:07 pm EDIT: Getting 'Cannot use a named argument here - not all required arguments have been passed'

for line 41:
tracer.Trace(start, mo.cursector, dir, mo.radius + mo.userange, traceflags: 0, wallmask: 0, ignore: mo);
Tried adding it myself but don't think I've got the wording right
In GZDoom 4.13.0 the ability to use named arguments was extended. Note that in my file I have version 4.13.0, which allows me to use extended named arguments. In earlier versions, they're more limited. Details are covered here on the wiki. I recommend using the latest version of GZDoom, however (and thus declaring your zscript version to be the latest), unless you have strong reasons to stick to an earlier version.
Post Reply

Return to “Scripting”