Display stat screen with menu

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Display stat screen with menu

Post by guo »

Hi,

As the title implies, I would like to have the stat screen visible while the user navigates and uses a menu. If you've played Bale, you know you can increase your stats manually. I would like the stat screen to be visible during this process. Help? I am horrible with slices.
vvight.wordpress.com
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

You could run script to display text slices which load the hero stats as the contents of the text. From, say, a textbox.
"Imagination. Life is your creation."
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Yep, I had considered something similar but using global variables and "get hero stat". Am I correct in assuming that using "base stat" will return the stat without taking into account boosts from equipment?

Cheers.
vvight.wordpress.com
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Side question: Can you show strings in menu items the same way you can in textboxes?
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

You can use embed codes in menu item captions. But if you want them to work in text slices, then you need to manually expand them using the "expand string" command.
Yes, basestat is the stat without equip bonuses, and also before stat caps are applied.

So, you can create a slice collection for a custom status menu which contains a bunch of ${V#} codes for global variables. Let's assume you give that text slice the "stats list" lookup code. You could load it like so:

Code: Select all

plotscript, show status, begin
  # First, set all the global variables
  # ....

  variable(collection, sl)
  collection := load slice collection(1)
  sl := lookup slice(sli:stats list)
  get slice text(0, sl)   # put the contents of the text slice in string 0
  expand string(0)
  set slice text(sl, 0)
end
If you want, I can give you the slice collection used for the default status menu, but it's got heaps of other stuff in it such as level, experience, level MP, portrait, etc, which you probably don't want to have to bother to reimplement (you would have to set them all with a script, or delete them from the collection).
Last edited by TMC on Wed Dec 06, 2017 7:33 am, edited 1 time in total.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Thanks! Unfortunately, I am "slicelexic". I've tried (not hard, admittedly) but I still struggle with the implementation. Is there a "slices for dummies"? Even better in my case would an ELI5 for slices.

Cheers!
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

What are you struggling with? Creating the slice collection in the slice editor, or the coding? The code I posted was almost complete; the only thing it's really missing (aside from the getherostat commands) is the "free slice(collection)" which you would put at the end, to get rid of the stats list. You may want to make 'collection' a global variable so that can happen in a different script.

There are two different slice tutorials, see http://rpg.hamsterrepublic.com/ohrrpgce/Slices_Tutorial
The one on the the wiki written by James, and the one written by BMR. Sadly, all the image links in BMR's are broken :( And the one James wrote isn't really a tutorial, but it doe explain the concepts.
However, there's no tutorial for using the slice collection editor. Play around.
Note: you don't need to know how to do any scripting with slices, because in this case your slice collection is quite static, with the exception of updating a text slice.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

I'm going to have a big play around tomorrow, try some tutorials etc. It's new and scary because I've never really played with it much, I appreciate the help.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

I think it's easier to get a grip on the slice editor if you load up some existing collections. For example, have a look at the ones in Mr. Hamster's Math Class. Some are quite complicated, others are simple.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

It would be really cool to play around with the Special Slice Collections, including calling our own from scripts.
It is much easier to lay things out in the slice editor than to script it.
Isn't it possible to alter the layout of the status scene by script? But the status scene isn't just display, it has functionality to allow it to turn to different pages. (would be neat to be able to add pages to the status screen btw)
And is it possible to special screens open at the same time as menus? Never tried it :p Okay, it doesn't work, you can't use a menu at the same time as a special screen/menu. Really they are like menus, and menus could do the job of some of the status screen, especially if you call slices at the same time.

You would want to have a menu with a script which will call your customised status screen (made of slices).
You can design it in the editor, and have the script write the current stats to text slices, using, append number and then clear string.
(If you want to refer to slice in a script, you can change their lookup codes)
(it would be nice if text slices could access game-information)

After calling e.g. your slice collection onto the screen, the script would then call your menu.
Give your menu an "on-close" script that will free your slice collection when you are done with it.


If you want your stats to be updated when you use the menu, you need to call a script that will do that every time. You can give menu options extra data to change their behaviour by script, such as writing an exit handler that will drop the user at the correct place depending on which menu item was used (depends how complicated your menus are)
You could write this all out as a script, but it is easier to design it in the editors. First step would be to load your slice collection at the same time as using the menu, then the next step to populate the slice collection with your display, and the last step would be to write the data to the slices.
Don't forget to free slices if you're not using them anymore! (alternatively, make them invisible)
You will want each menu option to alter your hero and update the display.

It would be easier if you referred to each part by script and calling it repeatedly with different arguments.
For example, set hero stat could take arguments from the Extra Data of a menu item.

If you have more complicated stat changes, like more than 1 stat change at a time, you would run the scripts for each stat being changed, or loop through them.

You might try loading the current hero graphics on the screen at the same time as your menu.

For selecting which hero to alter stats (if you want to do it one at a time. Which I assume is the case)
I imagine you would use a menu with 4 options, 1 for each active party member (where applicable) and they would have extra data set as 0,1,2,3 corresponding to hero rank.
Then you can use
"hero by rank (where)"
to refer that.
The script for each hero would be the same, but it would take the extra data as an argument to refer to the hero.


Here, UrMenu is the hero selector (not sure if this is the most efficient way...)

UrMenu := Open Menu(ID)

This menu has 1 option for each hero, with extra data set to 0,1,2,3 respectively.
Each runs the following script:

- Load slice collection. Display stats.
- write all data to slices.
You can do this for all stats at once by looping through your stats as a numbered list.

You need to open the menu which can change stats.

User selects a Menu option to e.g. Alter Stat.
Run Script:

- set hero stat (who,stat,value,type)
who = Which Hero. You can refer to extra data.

Stat = You can set this as the menu options extra data.
You can refer to stats as entries in a numbered list
Then you can refer to them using Extra Data.
It's also easier to loop through them.

Value = You can set this as
"current stat +/- the menu options extra data value"
Then you need to update the display. You can use the same script you used before.


You could make the menu options procedurally generated. It could include data about e.g. the stat increase
Then your menu would read like so:
"Hero Atk+10"
"Hero Def+15"
etc.,
But you are probably using names for stat increases (?)

For example, you could modify the caption with a script or write a variable in the caption and modify this variable with a script.
Or, you know, Hero Codes ${H0}, etc., but the other methods are good when you want to procedurally name more complicated stuff/

Is it possible to write constants to string, or directly to text slice? It would be cool to be able to use that stuff in the editor.

Is it possible to clone the status screen slices, and then alter them ?

edit: Crazy idea, what about if the slice editor could use the constants in the .hsi ?

EDIT: Hey this is a bit out there. But it would be cool to give special properties to menus, such as having a slice collection associated with them, or being able to display the contents of some special screens.
Last edited by SwordPlay on Fri Dec 08, 2017 4:28 am, edited 5 times in total.
"Imagination. Life is your creation."
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Virtuous Sword wrote:Isn't it possible to alter the layout of the status scene by script? ... And is it possible to special screens open at the same time as menus?
Nope, and nope. All of the built-in menus pause the rest of the engine, just like battles.
For selecting which hero to alter stats (if you want to do it one at a time. Which I assume is the case)
I imagine you would use a menu with 4 options, 1 for each active party member (where applicable) and they would have extra data set as 0,1,2,3 corresponding to hero rank.
There is a "pick hero" command to pick a hero in the active party.
Is it possible to write constants to string, or directly to text slice? It would be cool to be able to use that stuff in the editor.
Constants? Defined with "define constant" in the scripts file? Constants are just numbers, so you use "append number" or "string sprintf" to write them to a string and then to a text slice.
Is it possible to clone the status screen slices, and then alter them ?
Soon. James has done most of the work on that.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

BMR's tutorials were amazing. Took me about 10 minutes to read through, and now I think I get slices! Should be much easier to build on that solid foundation now. Thanks.
vvight.wordpress.com
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

An advantage of using script data (such as extra data) to pick a hero rather than the "pick hero" command is that you can make exact results, including picking a hero not in the party. (can "Pick Hero" select a hero in the reserves? that would be a nice function. Maybe like "Pick Hero, All" Defaulting to False)
You might set the extra data by script as well and thereby give the script a handler for complicated behaviour (such as conditions or restrictions), or you might script changes to it based on events in your game.
I am not the best, but I would love to hash it out with anyone, just for self-study.
"Imagination. Life is your creation."
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

It would be good to add an option to pick reserve party heroes, but it's not that simple to add, so I would wait until someone actually needs it. Oddly, there are about three different hero pickers in the engine (which all look the same).
Last edited by TMC on Sun Dec 10, 2017 4:53 am, edited 1 time in total.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Could you please upload the slice collection for the default status menu?

When I asked if you could plug ${#V} into menu items, I meant the items that constitute a menu, not the captions for inventory items. Doesn't seem to work unfortunately :(

I know how to do this now, thanks to your guys help, but it still seems awfully time consuming and inefficient to have to create all these global variables, strings and slices. It would be really nice if we could just display strings in menu items and slice text without having to run extra commands. Even better would be an option to display a hero stat with a simple #{$nameofstat}. Mind you, I am fairly lazy.

Edit: I reread your first reply TMC, and the script you posted is quite elegant for this purpose. Is there a way to run operations on strings like #{$V} ?
For example, the text slice would read:

"Attack Old: #{$gv_attack} new: #{ ($gv_attack ++ 1) }"

Is this coming across clearly? It would save having to create so many globals for displaying things like old and new values of a stat.

Cheers. Also Thanks Virtuous Sword, your input has been valuable and has my brain working on other ideas as well.
Last edited by guo on Wed Dec 13, 2017 1:26 am, edited 3 times in total.
vvight.wordpress.com
Post Reply