Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
programmatic text
MrBehemoth Offline
Senior Member

Posts: 408
Threads: 19
Joined: Feb 2014
Reputation: 40
#1
programmatic text

I think I already know the answer to this question... and it's "no", but I thought I'd ask anyway in case some genius out there has found a solution.

Is it possible to display programmatic (script-generated) text, that is either not produced from a lang file, or is an altered version of a lang entry, using tokens or something like that.

I know there are various ways you can script text entities to appear in the world, but I was specifically wondering about HUD text.

For example, is there a work around that could achieve the same thing as these made-up, non-existent functions?
SetCustomMessage("I like apples!", 5.0f);
or
string FruitString = "apples";
CreateLangEntry("Custom", "FruitILike", "I like " + FruitString + "!");
SetMessage("Custom", "FruitILike", 5.0f);

Any thoughts?

10-25-2014, 01:47 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: programmatic text

I don't think this is achievable. You may be able to toy with events which occur in game which will modify a string in script, but I do not think you can create lang entries on the go.

Something like this, as far as I know, may be possible. (Untested)
PHP Code: (Select All)
void OnStart()
{
AddEntityCollideCallback("Player""ScriptArea_1""Increment"false1);
SetLocalVarString("Pass""Pass_");       //Pass_ is a constant. Don't think it can be modified, but can be appended?
SetLocalVarInt("Number"0);
}

void Increment(string &in asParentstring &in asChildint alState
{
AddLocalVarInt("Number"0);
SetMessage("Custom"GetLocalVarString("Pass")+GetLocalVarInt("Number"), 0.0f);


And so, the game would keep track of how many times you pass through a Script Area. The problem is, you'll have to specify in the lang file for each possible pass through the Player can perform - for example, if the player can pass through the ScriptArea 100 times, that is 100 lines of lang file entries.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 10-25-2014, 03:37 PM by Romulator.)
10-25-2014, 03:35 PM
Find
MrBehemoth Offline
Senior Member

Posts: 408
Threads: 19
Joined: Feb 2014
Reputation: 40
#3
RE: programmatic text

Thanks Rom. That's not quite what I'm after, but it's a useful tip all the same!

I've already considered this approach (having the script choose the lang entry). What I'm trying to do is create a scoreboard, that would look something like this (just an example!):

.                                  Score
Levels complete:              20    200
Levels completed with dying:  17    170
Enemies killed:               15     15
Barrels smashed:              27     27
Potions drank:                 8      8

Completion bonus:                   x10

Total score:                       4200

So there would need to be a huge number of lang entries! I guess I'll have to do it in the world with entities, similarly to how Flawless shows stats and menus in Monsters.

10-26-2014, 10:56 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: programmatic text

You could perhaps make use of Mudbill's Animated Gif Tool to import a gif containing all the numbers you need, then keep track of variables which select the 'frame' of the animation. You can then place these in the map where appropriate and in script, modify which number is to display correspondent to the frame.

Think of it as there are 4 frames, and you want frame 2 for number two. Then you would have to call on the 2nd frame through a variable appropriate to it.

That probably wasn't as clear either... Tongue

Discord: Romulator#0001
[Image: 3f6f01a904.png]
10-27-2014, 09:24 AM
Find
Ongka Offline
Member

Posts: 225
Threads: 3
Joined: Nov 2010
Reputation: 20
#5
RE: programmatic text

You could also use spotlights with numbers as gobos and control the lights per script.
I once made a functioning timer with this method.
Feel free to pm me if you need the gobos.

[Image: 18694.png]
10-27-2014, 12:21 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#6
RE: programmatic text

(10-26-2014, 10:56 PM)MrBehemoth Wrote: I guess I'll have to do it in the world with entities, similarly to how Flawless shows stats and menus in Monsters.
That sounds fun. Let us know how you solved it, I'm curious how the code it's gonna look. :>

10-27-2014, 01:15 PM
Find
MrBehemoth Offline
Senior Member

Posts: 408
Threads: 19
Joined: Feb 2014
Reputation: 40
#7
RE: programmatic text

(10-27-2014, 01:15 PM)Daemian Wrote:
(10-26-2014, 10:56 PM)MrBehemoth Wrote: I guess I'll have to do it in the world with entities, similarly to how Flawless shows stats and menus in Monsters.
That sounds fun. Let us know how you solved it, I'm curious how the code it's gonna look. :>

Will do Smile

Thanks for the tips, all.

10-27-2014, 06:20 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#8
RE: programmatic text

(10-26-2014, 10:56 PM)MrBehemoth Wrote: So there would need to be a huge number of lang entries! I guess I'll have to do it in the world with entities, similarly to how Flawless shows stats and menus in Monsters.

Dude you could've just asked me! Big Grin

It's literally a bunch of entries. If you organize it properly, it should not be a problem. Entries and variables.

It's a workaround, but it's much better than nothing, and it still looks fine in-game

Trying is the first step to success.
(This post was last modified: 10-28-2014, 12:14 PM by FlawlessHappiness.)
10-28-2014, 12:08 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#9
RE: programmatic text

^ Yeah, I can see how it would work pretty well to do it that way, but he's talking about potentially thousands of entries. That would be a great chunk of the lang file and might even add some noticeable file size.

Nevertheless that does seem to be the only easy way around this. It's a shame you can't input scripted text as on-screen text. It seems only the AddDebugMessage does that :l

Edit: Oh, and MrBehemoth, how are you gonna display the scoreboard? How do lang entries come into play? Are you thinking of using SetMessage or something? Can't imagine that function to look that good considering it's 1 line, so I guess you're doing it some other way.

Another idea that might work is to use billboards for digits 0-9, then create them on the go as you need them. Might even be able to create a script that automatically creates the number you have out of these digits, by calculating the size of the variable and then creating an appropriate amount of billboard/entity digits next to each other.

For a scoreboard, I think a fance-looking entity would serve better than lang entries.

(This post was last modified: 10-28-2014, 12:26 PM by Mudbill.)
10-28-2014, 12:19 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#10
RE: programmatic text

(10-28-2014, 12:19 PM)Mudbill Wrote: ^ Yeah, I can see how it would work pretty well to do it that way, but he's talking about potentially thousands of entries. That would be a great chunk of the lang file and might even add some noticeable file size.

Nevertheless that does seem to be the only easy way around this. It's a shame you can't input scripted text as on-screen text. It seems only the AddDebugMessage does that :l

Edit: Oh, and MrBehemoth, how are you gonna display the scoreboard? How do lang entries come into play? Are you thinking of using SetMessage or something? Can't imagine that function to look that good considering it's 1 line, so I guess you're doing it some other way.

Another idea that might work is to use billboards for digits 0-9, then create them on the go as you need them. Might even be able to create a script that automatically creates the number you have out of these digits, by calculating the size of the variable and then creating an appropriate amount of billboard/entity digits next to each other.

For a scoreboard, I think a fance-looking entity would serve better than lang entries.

^^^What I did. Just use variables...


But yea... The .lang file isn't very convenient... I hope Unity will work better, whenever I get to utilize that program.



By the way, the way I showed numbers is by having an invisible lamp with a billboard tied to it. This way I can just turn it on and off with a nice fade-effect.

Trying is the first step to success.
(This post was last modified: 10-28-2014, 12:40 PM by FlawlessHappiness.)
10-28-2014, 12:27 PM
Find




Users browsing this thread: 3 Guest(s)