I couldn't find another thread for this, so I figured I'd make one.
I'm currently scripting a battle system for a game and I'm having trouble displaying the hp in the corner and the name of the enemy. Right now I have the blank text slices loaded up in a slice collection along with everything else in the battle scene. I figured this would be the easiest way to do it, rather than having to use show string at().
I assume I'm not supposed to treat it as a string since it's a slice, but I don't know how else to add things to it. Do I not use append number()? Also how would I do the same with an enemy's name?
That's right, text slices and strings are completely different objects. To set the text of a textslice, you use the set slice text command, after filing a string with the content you want. For example:
I added more stuff to Stand. I figured out text slices, but making them children of each other doesn't work right, which is obvious if you go into a battle. They move and I'm not sure why.
I had a brief look. The battle system is a cool project.
Why are you triyng to parent the text slices to one another? Is it get them to appear end-to-end? (Assume you just haven't set the anchor positions yet in the slice editor.) That will work, If you want to do that, just set up the parenting in the slice editor directly rather than with a script. The reason that the slcies move when you change the parent with setparent is that using setparent does not behave the same as setting a slice's parent in the slcie editor (with the shift key). A slice's x/y position is relative to its parent (or whichever edge or corner that might be). When you setparent a slice its position goes from being relative to the top left of th screen to relative to the new parent. On the other hand in the slcie editor when you reparent the offset is recalculated to keep the slice in the same position relative to the screen. Hint, you can press ctrl+F4 in game to investigate the slice tree.
I think I mentioned the alternative in another thread, "string sprintf"
script, set parent keep pos, sl, new parent, begin
variable(oldx, oldy)
oldx := slice screen x(sl)
oldy := slice screen y(sl)
set parent(sl, new parent)
set slice screen x(sl, oldx)
set slice screen y(sl, oldy)
end
I could never figure out how to set parents in the slice editor. Now I know! That will be incredibly helpful in the future. Thank you, I will fix this.
EDIT: I want to set the numbers as parents because the number of digits will potentially change as the players HP increases or decreases.
Last edited by kylekrack on Wed Oct 08, 2014 10:36 pm, edited 1 time in total.
I feel like we could make an actual hss or whatever file with a bunch of things, maybe organized by type... I know I have a bunch of slice functions I'm using in Silhouette that could be made more generic...
kylekrack wrote:I could never figure out how to set parents in the slice editor. Now I know! That will be incredibly helpful in the future. Thank you, I will fix this.
EDIT: I want to set the numbers as parents because the number of digits will potentially change as the players HP increases or decreases.
I assumed that you did it like that because you wanted the ability to make the numbers different colours (in which case, that's the best way to do it). If you don't want different colours, you can just use a single slice and "string sprintf", as I showed further up this thread.
Mystic wrote:I feel like we could make an actual hss or whatever file with a bunch of things, maybe organized by type... I know I have a bunch of slice functions I'm using in Silhouette that could be made more generic...
Maybe! The 3rd party HSI did this long ago but is now fairly obsolete. If you just have some possibly useful but not generalised scripts, it's still nice to put them in the script dump or link to them from there (i.e. make the scripts freely available for use, so that someone else can clean them up and put them on the wiki).