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
Passing Code into a lang entry?
DanielRand47 Away
Member

Posts: 109
Threads: 16
Joined: Mar 2012
Reputation: 3
#3
RE: Passing Code into a lang entry?

(02-16-2016, 02:51 AM)Romulator Wrote: Unfortunately, you cannot. You have to define the values in your lang file, then use code to call it.

<CATEGORY Name="Messages">
    <Entry Name="Percentage_100">100%</Entry>
    <Entry Name="Percentage_99">99%</Entry>
...
    <Entry Name="Percentage_1">1%</Entry>
</CATEGORY>

Using code, you'd have to call it in a timer that plays every 5 seconds and lowers your value. I've slightly adjusted my code to suit my knowledge of the engine, but it'll work in its simplest form, like this:

PHP Code: (Select All)
void OnStart()
{
    
SetLocalVarInt("PowerRemain"101); //Becomes 100 in first Timer step.
    
AddTimer(""5.0f"DimLights");
}

void DimLights(string &in asTimer)
{
    
AddLocalVarInt("PowerRemain", -1);
    if(
GetLocalVarInt("PowerRemain") == 0)
    {
        
//We have no power lol
    
}
    else
    {
        
SetMessage("Messages""Percentage_"+PowerRemain3.0f);
    }
    
AddTimer(""5.0f"DimLights");


The best way to make your entries for your lang, would best be if you have any experience in a computer language (C, Lua, Vb.NET) to get the computer to type out your entries using a loop. In something psuedocode-like, it may appear like this:

BEGIN
var <-- 100
do until var = 0
    print "<Entry Name=""Percentage_"""+var+">"+var+"%</Entry>"
    var <-- var - 1
loop
END

If you can't, I'll type one up later. I did all of this on my phone. https://dotnetfiddle.net/4sHWe5

Keep in mind, there are other methods! I believe FlawlessHappiness can help you by using numbered particle systems, but keep in mind that these likely won't always be on the screen.

Moving to the Development Support subforum. Please remember to keep all scripting and custom story related problems over there.

I figured I wouldn't be able to. I'll see what I can do. I'll also be more aware as to where threads such as this should go.
02-17-2016, 02:19 AM
Find


Messages In This Thread
Passing Code into a lang entry? - by DanielRand47 - 02-16-2016, 12:50 AM
RE: Passing Code into a lang entry? - by DanielRand47 - 02-17-2016, 02:19 AM



Users browsing this thread: 1 Guest(s)