Frictional Games Forum (read-only)
programmatic text - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: programmatic text (/thread-26953.html)

Pages: 1 2


programmatic text - MrBehemoth - 10-25-2014

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?
Code:
SetCustomMessage("I like apples!", 5.0f);
or
Code:
string FruitString = "apples";
CreateLangEntry("Custom", "FruitILike", "I like " + FruitString + "!");
SetMessage("Custom", "FruitILike", 5.0f);

Any thoughts?


RE: programmatic text - Romulator - 10-25-2014

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:
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.


RE: programmatic text - MrBehemoth - 10-26-2014

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!):

Code:
.                                  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.


RE: programmatic text - Romulator - 10-27-2014

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


RE: programmatic text - Ongka - 10-27-2014

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.


RE: programmatic text - Daemian - 10-27-2014

(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. :>


RE: programmatic text - MrBehemoth - 10-27-2014

(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.


RE: programmatic text - FlawlessHappiness - 10-28-2014

(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


RE: programmatic text - Mudbill - 10-28-2014

^ 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.


RE: programmatic text - FlawlessHappiness - 10-28-2014

(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.