Scripts / [SOLVED] User Interface Customization - Where to Begin?

Author
Message
jjumisko
5
Years of Service
User Offline
Joined: 11th Dec 2019
Location: Los Angeles
Posted: 17th Jan 2020 17:08
I want to create a custom, transparent user interface (Minority Report style) that would be a frame around the player viewport.

I found how to create a custom HUD by DVader Here: https://forum.game-guru.com/thread/216400?page=1#msg2559566

I can use that for various measures of different data, I can see, but how would one go about creating the framework that sort of organizes these data points (such as hunger, thirst, O2 levels, health, weapon activated, and ammo)?

I can create the graphics in Photoshop, but I'm also curious about placement and the various resolutions I will need to create for player experience.

I would appreciate any thoughts, and IF I can get this going, I would happily share freely all of the code and assets I create, for personal AND commercial use.
Acer Nitro 5
2.4 GHz Core i5
GeForce GTX1050
32Mb SDRAM

The author of this post has marked a post as an answer.

Go to answer
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 17th Jan 2020 18:32
Sorry, I don't understand the question.
You can just create each part of the hud in their own script or one script to control them all... It just depends on how you want to set it up really.
Either way you will need other scripts to effect the values - such as drinking some water or eating some food.

Sprites use % system so you can use your normal resolution then use sprites and they will roughly scale to any resolution - but other aspect ratios will look different.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
jjumisko
5
Years of Service
User Offline
Joined: 11th Dec 2019
Location: Los Angeles
Posted: 17th Jan 2020 19:15
First of all, thanks smallg. Maybe I can clarify.

First, Simple questions. Where do I place the graphic for my HUD. Where do I place my script for it in game?

Now for the more complicated questions:

I want a very thin frame overlay, that may or may not have transparency. If it is too taxing on frame rate, I would make it simply a light solid. Here's an example, though it is FAR more elaborate than my aesthetic:



Would this be a sprite? I want it active at all times the player is alive in that level.

Within that frame I would leave blank areas in which I could place the remaining sprites for hunger, thirst, health, etc. Will I make them relative to the frame sprite, or will I have to fiddle with the location on screen, and thus perhaps have problems with varying frame resolutions?

I totally get what you are saying about needing scripts to affect the values for hunger, etc. Can I use the basic game mechanics for health, ammo, weapon?

Again, thanks so much. I want to work on this this weekend, so if you can answer the first questions, that will allow me to experiment a bit.
Acer Nitro 5
2.4 GHz Core i5
GeForce GTX1050
32Mb SDRAM
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 17th Jan 2020 19:21 Edited at: 17th Jan 2020 19:21
Put your images in scriptbank/images, make sure they are .png.

Make your main sprite at a high resolution and simply position it at 0,0 and 100%.

You can specify a depth value for sprites so you can paste them on top of your main sprite.
Been there, done that, got all the T-Shirts!
PM
jjumisko
5
Years of Service
User Offline
Joined: 11th Dec 2019
Location: Los Angeles
Posted: 17th Jan 2020 21:01
Cool. That is way simpler than I thought.
Acer Nitro 5
2.4 GHz Core i5
GeForce GTX1050
32Mb SDRAM
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 17th Jan 2020 22:19 Edited at: 17th Jan 2020 22:29
This post has been marked by the post author as the answer.
Quote: "First, Simple questions. Where do I place the graphic for my HUD?"

as amen says, placing them in scriptbank\images is best, you can load them with
imgID = LoadImage("scriptbank\\images\\foldername\\imagename.png")
Quote: "Where do I place my script for it in game?"

on any non-static entity in the 'ai' property - for huds you will want them 'alwaysactive' = yes
Quote: "Would this be a sprite?"

yes
Quote: " I want it active at all times the player is alive in that level."

alwaysactive = yes in the properties panel makes scripts run every frame regardless of distance to player
Quote: "Within that frame I would leave blank areas in which I could place the remaining sprites for hunger, thirst, health, etc. Will I make them relative to the frame sprite, or will I have to fiddle with the location on screen, and thus perhaps have problems with varying frame resolutions?"

make them as you see them on your screen, if users are using the same aspect ratio (i.e. 16:9) it will look the same just larger or smaller etc - other aspect ratios (i.e. 4:3) would look similar but different.
Quote: "I totally get what you are saying about needing scripts to affect the values for hunger, etc. Can I use the basic game mechanics for health, ammo, weapon?"

yes, as long as you use the stock variables to read the values it can be adjusted by stock scripts (g_PlayerHealth etc)
Quote: "Make your main sprite at a high resolution and simply position it at 0,0 and 100%.
You can specify a depth value for sprites so you can paste them on top of your main sprite."

the key word here is "paste" if you want to show any stock GG text (i.e. prompt or TextCenterOnX) on screen that is covered by a sprite, if you do then you need to use PasteSpritePosition().
so a basic set up will look like this
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
jjumisko
5
Years of Service
User Offline
Joined: 11th Dec 2019
Location: Los Angeles
Posted: 18th Jan 2020 19:00
Dang, smallg, that was a LOT of help. Thank you so much for your time and expertise! What a gold mine you are.
Acer Nitro 5
2.4 GHz Core i5
GeForce GTX1050
32Mb SDRAM
PM
jjumisko
5
Years of Service
User Offline
Joined: 11th Dec 2019
Location: Los Angeles
Posted: 20th Jan 2020 21:32 Edited at: 20th Jan 2020 21:33
Thanks for all help thus far. Especially @smallg I'm getting there.

I have my hud showing, but I'm getting a lua error.


I am just making a small hud for now, until I can get the coding set up. I'm getting the error I remarked in the code at line 13. Anyone able to assist?

Acer Nitro 5
2.4 GHz Core i5
GeForce GTX1050
32Mb SDRAM

Attachments

Login to view attachments
PM
Ratall
16
Years of Service
User Offline
Joined: 29th Jun 2008
Location: Not Here
Posted: 21st Jan 2020 06:52 Edited at: 21st Jan 2020 06:53
the problem is you are using hud2.png as a variable an it is not defined.
I suspect the code below will be more successful.

“Everything should be made as simple as possible, but not simpler.”
Albert Einstein


"Ye count your selfe wele lettred , your lernyng is starke nought."
Anon
PM
jjumisko
5
Years of Service
User Offline
Joined: 11th Dec 2019
Location: Los Angeles
Posted: 21st Jan 2020 23:40
It was. Thanks a lot, Ratall! I'm still learning Lua. I'm not sure how to now define my health and energy sprites. Since the PNGs have transparency, can they be placed in the same position? Can I call any local variable anything I like in lowercase? Like spr_energy and spr_health?

My plan is to have the health sprite respond to the GetPlayerHealth(e) command, and I want for the energy to be simply time dependent for now, so I will need the timer commands, and some way of increasing the health sprite when players get food and sleep (load screens will restore energy to 100%).

I'm reading the Lua manual now, and getting some idea from that, but a guide to coding Lua just for GG would be so cool. I found the basic one on Steam, but it is mainly a list of available code, but not exactly how to write the code. I'm trying things in other people's scripts for now, and learning a lot. I was excited to get my sprites on the screen and get to adjust them to where I want them!
Acer Nitro 5
2.4 GHz Core i5
GeForce GTX1050
32Mb SDRAM
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st Jan 2020 23:55
Quote: "Since the PNGs have transparency, can they be placed in the same position?"

yes, transparency is fine and works by default in GG
Quote: "Like spr_energy and spr_health?"

yes
Quote: "and some way of increasing the health sprite when players get food and sleep"

add

to the script for food or sleeping - best to study a normal item pick up script for this.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
jjumisko
5
Years of Service
User Offline
Joined: 11th Dec 2019
Location: Los Angeles
Posted: 22nd Jan 2020 00:32
I think I have one of yours, smallg! Thanks. You are a godsend.
Acer Nitro 5
2.4 GHz Core i5
GeForce GTX1050
32Mb SDRAM
PM

Login to post a reply

Server time is: 2024-12-22 09:23:17
Your offset time is: 2024-12-22 09:23:17