Post new topic    
How to place a text slice connected to a timer. 
 PostWed Aug 19, 2020 1:42 am
Send private message Reply with quote
I made a timer that counts down for two minutes. I want a text slice to visually display how much time is left on the screen. But I have no idea how to use slices, I find the tutorial on the wiki to be completely incomprehensible. Can someone simply tell me what the script for making a simple single text slice, connected to a timer would be like?
Slime Knight
Send private message
 PostWed Aug 19, 2020 3:04 am
Send private message Reply with quote
Alright, so you first gotta have a text slice to work with and a way to refer to it.

You do that with something like:

variable (myTextSlice) # Sets up a new variable called myTextSlice
myTextSlice:=create text # Makes a new text slice, returns the "handle", and since we're setting myTextSlice to whatever "create text" returns, myTextSlice now equals the "handle" is.

Now myTextSlice is the "handle" of the text slice you just created, meaning you can manipulate it.

We can do a few things here.

set slice text(myTextSlice, 1)

This sets the "text" attribute of your slice to whatever string 1 is, which is "Banana". That means it'll show "Banana" wherever the slice is now.

set slice x(myTextSlice,0)
set slice y(myTextSlice,0)

This sets the x and y coordinates of your slice to 0,0 (relative to camera, by default). You should see "Banana" on the top left of the screen.

When you're done, you'll want to use:
free slice (myTextSlice)

This will get rid of the slice. Not "hide" it, but actually get rid of it. Important to clean up, otherwise you'll end up with a bunch of unnecessary objects layered all over you screen, or in memory.

That's a real simple tl;dr.

Further than that, you'll have to understand how parentage works, which to be honest, is best seen and experienced rather than taught. Best way to learn it is by playing around with the Slice Collection Editor in custom, or by looking at the Slice Debug in gam.exe by hitting F8 and finding it so you can see how things are laid out.
Slime Knight
Send private message
 PostWed Aug 19, 2020 8:27 am
Send private message Reply with quote
The first question is... why do you need a slice? I'm a big proponent of slice use, however... you can just use a string for this. And it would look exactly the same. (Unless you're planning for special effects).

Where the
argument is, pick a string id you're not using. For this example: string 0.

set timer (1, 120, 18, @TRIGGEREDSCRIPT, 0)


center string at (0, 160, 12)

In "@TRIGGERSCRIPT": clear string (0)
Do you make love with the same urgency you make games?
 PostWed Aug 19, 2020 3:39 pm
Send private message Reply with quote
Thanks for the help, Both replies to my post were useful to know, It turned out extremely simple to place a timer.
Display posts from previous: