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

TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

guo wrote:Could you please upload the slice collection for the default status menu?
http://tmc.castleparadox.com/ohr/statusmenu.slice
Import it into the slice collection editor by pressing F3. Note that it contains lots of special embed codes like ${HERONAME}, none of which will work outside of the builtin status menu, so you will have to replace all of them.
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 :(
${...} embed codes do work in menu item captions. But by "captions for inventory items" I guess you mean descriptions of inventory items? I don't think they work in item descriptions.
It would be really nice if we could just display strings in menu items and slice text without having to run extra commands.
Aside from menu item captions, which is already implemented, I nearly finished implementing support for embed codes in text slices, so that will be in Fufluns.
Even better would be an option to display a hero stat with a simple #{$nameofstat}. Mind you, I am fairly lazy.
Yes, that's pretty natural, but it requires knowing which hero to grab the stat from. It can work inside the status menu because the status menu provides a "context". I'm working on something for this too.
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.
So what you're asking for is, firstly, the ability to use of the name of the global variable in the embed code, rather than the ID number. Yes, that's something I want to allow too. I doubt that this would make it into Fufluns. And you also want hamsterspeak expressions in embed codes, rather than just variables. That's something I've considered too. But I would probably only allow that in strings you put in a script, not text slice contents, which is a lot more complexity because hspeak can't be used to parse those expressions in-game. I'll consider that a vote in favour of it, though.
Last edited by TMC on Wed Dec 13, 2017 2:46 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 TMC. I tested a new menu earlier using #{$V} but I must have entered something wrong as it just presented the raw characters instead of displaying the value of the variable. Didn't think about "#{$nameofstat} not knowing which hero to grab from, but cool to know it's being worked on.

Thanks heaps for the statusmenu slice. Progress is being made! In the meantime, I had made a slice collection with a large text string that looked kind of like:

Code: Select all

Stat:    Old:       New:      Cost:
         #{$Vx}     #{$Vy}    #{$Vz}
         #{$Vx}     #{$Vy}    #{$Vz}
         #{$Vx}     #{$Vy}    #{$Vz}
         #{$Vx}     #{$Vy}    #{$Vz}
         #{$Vx}     #{$Vy}    #{$Vz}
         #{$Vx}     #{$Vy}    #{$Vz}

Remaining $: #{$Va}
Which displays when the menu is opened, and then the menu itself is drawn over top of the blank areas under "stat:".
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

You probably want to make each column a different text slice, so that the columns line up nicely regardless of the number of digits.

Or alternatively you could write a script to add each stat to the map using a for loop and the 'clone slice' command. That's the way I would do it, to avoid having lots of global variables which I have to manually fill. However if what you have already works, throwing it out would be counter productive.

Note, you keep writing {$V#}, but the correct syntax is ${V#}. All embed codes are of the form ${...}, with the stuff in the brackets being a code. If it starts with V it's a global variable.
Last edited by TMC on Wed Dec 13, 2017 8:55 am, edited 2 times in total.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Oops, the syntax is indeed wrong. I was bashing keys without thinking. Could you elaborate on your "clone slice" and for loop idea? It sounds interesting, and I always like to learn new things.

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

Post by TMC »

Goes like this: see that list of slices in the collection I gave you; where there's a separate container slice for each stat, which has two child text slices? Well you would delete all but one, and use that one as a template. The script duplicates the template repeatedly, filling in the stat name and value each time.

Oh... hmm, there's no command to get the name of a stat. OK, instead the list of stat names would be manually created, and the script just creates the slices for the stat values.
So as a template you would use a text slice (it doesn't matter what its text is, as it'll be replaced by the script), which is the only child of a grid slice.
Give it a lookup code, say "stat".

Code: Select all

variable(template, sl)
template := lookupslice(sli:stat)
for (stat, stat:hp, stat:hits) do (
  sl := clone slice(template)
  clear string(0)
  append number(0, get hero stat(who, stat, current value)
  set slice text(sl, 0)
)
# Delete the template because we don't need it any more
free slice (template)
This assumes you want to show all the stats between HP (the first one) and Hits (the last).
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Is there a way to free an entire slice collection at once?

variable (sl)
sl := lookup slice (sli:statlist)
free slice (sl)

The above removes the text slice but not the rectangle that is the parent. Should I just assign another variable to the parent and free that instead?
vvight.wordpress.com
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Also, it would be a nifty feature (for me especially :angel: ) if we could choose how many integers to display as a default. For example, if a stat is 20 we could have it display as 020 instead.
vvight.wordpress.com
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Yes, it is best to save the collection in another variable and free that.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

guo wrote:Should I just assign another variable to the parent and free that instead?
There are many different ways to get a handle to a slice, but since you already have it, it's simplest to just store it in a global to use later.


Hmm, really there are a ton of obvious string functions that are missing, such as trimming to the left or right X characters or padding.
OK, I added some arguments to appendnumber to specify padding. I figured it would be quick and easy. It wasn't! (Honestly a better solution would be to add support to stringsprintf for that kind of stuff, like other programming languages have.)
Also, I've seen at least one script to add a number with padding... maybe I even wrote it myself.
Last edited by TMC on Wed Dec 20, 2017 11:00 am, edited 1 time in total.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Swell! I'll post an update after the silly season is done ruining my free time.
vvight.wordpress.com
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Salutations!

Question: Is there a way to change item spacing for a text slice, ala menus?

edit: Also, can the text in a text slice be aligned (eg, left, center, right)?
Last edited by guo on Wed Jan 03, 2018 3:09 am, edited 1 time in total.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Unfortunately, no and no. Both thigns I want to add. To achieve either of those you would have to split each line into a separate text slice and position/align those. And there's no builtin way to determine how a line of text wraps around, so you would have to work that out yourself if you want wrapping.

Hmm, actually it would be quite easy to add a line spacing option...
Last edited by TMC on Thu Jan 04, 2018 5:23 am, edited 1 time in total.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Yea , too much effort to do them all as separate text slices - especially when so many strings are being displayed/expanded. As it is, the level up menu is working great - I know it's not much but I'm proud of it.

I appreciate all the help, and now that I'm comfortable working with slices I can start incorporating them more. Should be some interesting puzzles and minigames cropping up, and no doubt plenty of questions.

Cheers.
vvight.wordpress.com
Post Reply