Scripts / Text Rendering

Author
Message
Nevin
8
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 30th Apr 2017 17:49 Edited at: 30th Apr 2017 17:52
Hello,

Text rendering.. I have been trying to do with this with GG for a wile. Never for a project but every now and then I try an idea that I think will work and it never does. So before I ask for help I want to show and img to you and explain what im talking about. P.S The game is not vary good, I am using this games pic to showcase text rendering.



Do you see at the top left,middle,right, and bottom left? That is text above an img that can be coded to change. I am deliberately trying to explain this the best way I can because the last time I tried to explain it no one knew what i was talking about .

This is not text you add yourself in Paint,PS,Gimp. This is text that is coming from a script that changes.

If you know how this can be achieved in GG or if it's even possible in GG I would be extremely happy to learn how this can be done.

Thank you!
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 30th Apr 2017 18:05 Edited at: 30th Apr 2017 19:32
its very simple to do, basically fir sprites and text use layers, 1 to 100, 100 being the bottom layer and 1 being the top layer, text is in layer one by default, so you need to set your sprite depth to a layer below 1 (99 to 100), then use the PasteSprite command.

on my tablet at the moment so cant give examples, but if you look in the script forum you should find plenty of threads about huds and you should be able to work it out from one of those examples

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 30th Apr 2017 18:07 Edited at: 30th Apr 2017 18:10
use TextCenterOnX() or one of the other Text() commands and the sprite system to create sprites from the images but move them off screen and then use PasteSpritePosition() to keep them on screen when needed.

so something like this

if spr_created == 0 then
spr[1] = CreateSprite(LoadImage("scriptbank\\images\\image1.png"))
SetSpritePosition(spr[1],200,200)
spr_created = 1
end
PasteSpritePosition(spr[1],0,0)
day_number = 0
TextCenterOnX(8,0,3,"Day: "..day_number)


@belidos in GG sprites and text use different layers so it won't work like that unfortunately, text is always behind sprites no matter which depths you use unless using the special PasteSprite commands.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Nevin
8
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 30th Apr 2017 19:29
Ill have to try this out.

thank you!
Belidos
3D Media Maker
8
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 30th Apr 2017 19:32 Edited at: 30th Apr 2017 19:34
Quote: " unless using the special PasteSprite commands."


Yeah that's what I said :p

Seriously though, that is what I meant, I just forgot to add the bit about pasting, I was writing quick and assumed he would already be using PasteSprite.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Nevin
8
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 1st May 2017 01:28 Edited at: 1st May 2017 01:30
LoadImage
CreateSprite
SetSpriteSize
SetSpriteDepth
SetSpritePosition

This is what I have been using.

For text I use TextColor. But to try this out im gonna use Textx
Nevin
8
Years of Service
User Offline
Joined: 19th May 2015
Location: U.S.A
Posted: 1st May 2017 02:00 Edited at: 1st May 2017 02:15
This works!
Thanks so much SmallG!!!

Edit: For anyone that sees this down the road. TextColor so you can have color text! Here is how I went about this as a test

spr_created=0
test_number=99999999 -- just for testing

if spr_created == 0 then
spr = CreateSprite(LoadImage("scriptbank\\images\\testingimg\\test.png")) -- will have to set your own path, this was for me
SetSpritePosition(spr,200,200)
spr_created = 1
end
PasteSpritePosition(spr,0,0)
TextColor(4,6,3,"WhatAGoodDayToTest" ..test_number,153,204,102) -- Last three numbers here are color code, check link below for colors

http://www.colorschemer.com/online.html
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 1st May 2017 09:31 Edited at: 1st May 2017 09:32
You can simplify that somewhat to

my_sprite = nil
...

if my_sprite == nil then
my_sprite = CreateSprite( ... etc ...)
SetSpritePosition(my_sprite, 200, 200)
else
-- sprite handling logic etc
end
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-04-20 14:17:39
Your offset time is: 2024-04-20 14:17:39