Status notifications

Talk about things that are not making games here. But you should also make games!

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Status notifications

Post by maunderingcabal »

Is there a way to trigger alerts in a textbox to show current health and MP? Like when you enter a map it pulls up a teaxtbox that shows how much MP and health is left? Thanks.
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Pretty easy. You just write a textbox which embeds some global variables by their ID number, like "HP: ${V10}/${V11} MP: ${V12}/${V13}" and then fill in those globals with a script, which you can call from whereever you want, like map autorun:

Code: Select all

global variable(10, cur hp)
global variable(11, max hp)
global variable(12, cur mp)
global variable(13, max mp)

plotscript, show hp mp, begin
  variable(who)
  who := find hero(leader)
  cur hp := get hero stat(who, stat:hp, current stat)  # Note: you have to change stat:hp if you renamed that stat
  max hp := get hero stat(who, stat:hp, maximum stat)
  cur mp := get hero stat(who, stat:mp, current stat)  
  max mp := get hero stat(who, stat:mp, maximum stat)
  show textbox (5)  # ID of the textbox containing HP: ${V10}/${V11}  MP: ${V12}/${V13}
end
Last edited by TMC on Mon Aug 07, 2017 10:59 pm, edited 1 time in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

Not sure, but why don't you display this info in a slice? It can be displayed at the same time as textboxes, and it can be displayed continuously like a HUD, and it has more display options and styles!
You could display it in a fancy graphic for instance, rather than a plain ol' text box.
Design elements matter a lot when displaying information.
Text in a textbox says "This is information in the game, likely speech or description"
Numbers/text in a HUD says "This is the game information for the player to be aware of"

The advantage to using slices is that you can display it as a lifebar, or other methods than just numbers/texts, for example, life hearts or what-have-you.
Using as slice probably also takes up less room on the screen than a textbox, and doesn't interfere with gameplay or scripts in the same way a textbox does (not sure, don't quote me on this)
Last edited by SwordPlay on Tue Aug 08, 2017 12:45 am, edited 1 time in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Right, displaying a slice has no sideeffects, unlike textboxes (pausing the player)
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

Oh! and you can also make the slice "slide" onto and off the screen, which is a fancy effect, amongst other things.

Slices don't just have to appear on the screen and vanish, they can move around and outside the screen and be obscured by or layered with other slices.

You could even have a thing where you put your mouse cursor on a slice and it expands to show information (as well as by holding down a key) and it hides the info when your mouse cursor isn't over it (or if you let go of the key)
That way, a player can check that info whenever they like, with mouse hover/click or keypress

edit: sorry if you already know all this and i'm boring you btw
Last edited by SwordPlay on Tue Aug 08, 2017 2:54 pm, edited 1 time in total.
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

TMC wrote:Pretty easy. You just write a textbox which embeds some global variables by their ID number, like "HP: ${V10}/${V11} MP: ${V12}/${V13}" and then fill in those globals with a script, which you can call from whereever you want, like map autorun:

Code: Select all

global variable(10, cur hp)
global variable(11, max hp)
global variable(12, cur mp)
global variable(13, max mp)

plotscript, show hp mp, begin
  variable(who)
  who := find hero(leader)
  cur hp := get hero stat(who, stat:hp, current stat)  # Note: you have to change stat:hp if you renamed that stat
  max hp := get hero stat(who, stat:hp, maximum stat)
  cur mp := get hero stat(who, stat:mp, current stat)  
  max mp := get hero stat(who, stat:mp, maximum stat)
  show textbox (5)  # ID of the textbox containing HP: ${V10}/${V11}  MP: ${V12}/${V13}
end
This makes a lot more sense than What I came up with

Code: Select all

Global Variable (1,e)
Global Variable (2,l)

plotscript, update, begin
 e:=get hero stat (0,stat:energy,current stat)
 l:=get hero stat (0,stat:laser,current stat)
 show value (l) ## ${V1}
 if ((get hero stat (0,0,current stat))==300) then
 (show text box (85) ## ${V0}
 wait for textbox) else if
 ((get hero stat (0,0,current stat))==200) then
 (show text box (85) ## ${V0}
 wait for textbox) else if
 ((get hero stat (0,0,current stat))==100) then
 (show text box (85) ## ${V0}
 wait for textbox)
end
Last edited by maunderingcabal on Tue Aug 08, 2017 7:02 pm, edited 2 times in total.
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

Virtuous Sword wrote:Not sure, but why don't you display this info in a slice? It can be displayed at the same time as textboxes, and it can be displayed continuously like a HUD, and it has more display options and styles!
You could display it in a fancy graphic for instance, rather than a plain ol' text box.
Design elements matter a lot when displaying information.
Text in a textbox says "This is information in the game, likely speech or description"
Numbers/text in a HUD says "This is the game information for the player to be aware of"

The advantage to using slices is that you can display it as a lifebar, or other methods than just numbers/texts, for example, life hearts or what-have-you.
Using as slice probably also takes up less room on the screen than a textbox, and doesn't interfere with gameplay or scripts in the same way a textbox does (not sure, don't quote me on this)
How would I code this then?
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

It's really simple, depending on what you want to do.
If there's something specific, just ask, and I, or someone more talented, will try to do it for you.

The simplest way is to use "show value"
OR
record your data in a string and use "show string (ID)"
This is really simple and no-frills.
If you want to position this you can use the following commands:
http://hamsterrepublic.com/ohrrpgce/doc ... lotstrings


Making a proper HUD?
The easiest way (IMO), use the slice editor to create your HUD.
In the attached image you can see a HUD i'm messing around with, as an example. It's really ugly, so don't take it too seriously, you can probably do better.
Then have your autorun script load this slice collection: Voila! It will appear on-screen.

Want to mess around with slices?
Give a slice a lookup code so you can refer to it in your script.
If you want to refer to a collection of slices, do it by operating on the root, or parent slice.
Putting your slices in a container allows you to quickly move, delete, modify, and change visibility of children all at once!
You can hide your entire collection by making the parent invisible, or move all the slices together by moving the parent slice.

Fancy stuff like icons?
You can make icons appear conditionally based on switches for example.
That's fairly easy to do.
Changing visibility of slices is straightforward:
http://hamsterrepublic.com/ohrrpgce/doc ... 20Clipping
Just set a slice to visible or invisible based on a switch.

If you want to display life as a bar/gauge, or using icons, that's a little complicated-ish.
To make a bar or gauge, you need to use a panel slice, with 2 children (rectangles, for example)
Then you need to set the ratio of the children to represent the player's life vs their max life.
Then it will act like a lifebar, pretty much.
You want to use
"set panel percent (handle, percent)"
and make "percent" "((current HP/max HP)*100)", I think, substituting the appropriate terms.
http://hamsterrepublic.com/ohrrpgce/doc ... l%20Slices

If you want to use a fancy effect like moving your HUD on/off screen, that's a bit complicated.
Use one of the moving commands.
Probably "move slice to (handle, x, y, ticks)"
http://hamsterrepublic.com/ohrrpgce/doc ... g%20Slices

You need to use at least a text slice if you want to display text/numbers.
You can write strings to text slices.
Use "set slice text(handle, string id)"
http://hamsterrepublic.com/ohrrpgce/doc ... t%20Slices

For example, you can see I've written "$123456" which is a placeholder.
By script, it will be overwritten with the current value.
Put things like "HP" or "$" in a separate slice which is unchanging (I forgot to do that in my example) or use an icon, like a heart or something.

Add some other slices like rectangles or sprites to make a fancy HUD of your design.
It doesn't have to be boring rectangles, it can be any shape you can draw, ovals, a mixture of shapes, whatever. It's quite versatile.

Need any help or ideas? Just ask. I might have written something wrong or not quite right, in which case, I hope someone will point it out to me.
Attachments
Screenshot from 2017-08-09 01-06-57.png
Screenshot from 2017-08-09 01-06-57.png (24.12 KiB) Viewed 2581 times
Last edited by SwordPlay on Wed Aug 09, 2017 12:40 am, edited 1 time in total.
User avatar
maunderingcabal
Red Slime
Posts: 37
Joined: Sun Oct 30, 2016 8:49 am
Location: Hell, California
Contact:

Post by maunderingcabal »

Virtuous Sword wrote:It's really simple, depending on what you want to do.
If there's something specific, just ask, and I, or someone more talented, will try to do it for you.

The simplest way is to use "show value"
OR
record your data in a string and use "show string (ID)"
This is really simple and no-frills.
If you want to position this you can use the following commands:
http://hamsterrepublic.com/ohrrpgce/doc ... lotstrings


Making a proper HUD?
The easiest way (IMO), use the slice editor to create your HUD.
In the attached image you can see a HUD i'm messing around with, as an example. It's really ugly, so don't take it too seriously, you can probably do better.
Then have your autorun script load this slice collection: Voila! It will appear on-screen.

Want to mess around with slices?
Give a slice a lookup code so you can refer to it in your script.
If you want to refer to a collection of slices, do it by operating on the root, or parent slice.
Putting your slices in a container allows you to quickly move, delete, modify, and change visibility of children all at once!
You can hide your entire collection by making the parent invisible, or move all the slices together by moving the parent slice.

Fancy stuff like icons?
You can make icons appear conditionally based on switches for example.
That's fairly easy to do.
Changing visibility of slices is straightforward:
http://hamsterrepublic.com/ohrrpgce/doc ... 20Clipping
Just set a slice to visible or invisible based on a switch.

If you want to display life as a bar/gauge, or using icons, that's a little complicated-ish.
To make a bar or gauge, you need to use a panel slice, with 2 children (rectangles, for example)
Then you need to set the ratio of the children to represent the player's life vs their max life.
Then it will act like a lifebar, pretty much.
You want to use
"set panel percent (handle, percent)"
and make "percent" "((current HP/max HP)*100)", I think, substituting the appropriate terms.
http://hamsterrepublic.com/ohrrpgce/doc ... l%20Slices

If you want to use a fancy effect like moving your HUD on/off screen, that's a bit complicated.
Use one of the moving commands.
Probably "move slice to (handle, x, y, ticks)"
http://hamsterrepublic.com/ohrrpgce/doc ... g%20Slices

You need to use at least a text slice if you want to display text/numbers.
You can write strings to text slices.
Use "set slice text(handle, string id)"
http://hamsterrepublic.com/ohrrpgce/doc ... t%20Slices

For example, you can see I've written "$123456" which is a placeholder.
By script, it will be overwritten with the current value.
Put things like "HP" or "$" in a separate slice which is unchanging (I forgot to do that in my example) or use an icon, like a heart or something.

Add some other slices like rectangles or sprites to make a fancy HUD of your design.
It doesn't have to be boring rectangles, it can be any shape you can draw, ovals, a mixture of shapes, whatever. It's quite versatile.

Need any help or ideas? Just ask. I might have written something wrong or not quite right, in which case, I hope someone will point it out to me.
Thanks man! Very helpful. It's going to take me a while to figure slices out.
Here is my OHRRPGCE Development Page: https://startru.wordpress.com. Follow us on Twitter @startruckerdev
Post Reply