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
Script Help Carrying variables and printing them [ALTERNATIVELY SOLVED]
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#1
Carrying variables and printing them [ALTERNATIVELY SOLVED]

Intro:
Hello, I'm currently working on a project that is working heavily with variables. It's a great thing and it taught me a lot so far, however I ran into a problem that is beyond my knowledge.

Problem in details:
I have a variable:
PHP Code: (Select All)
void OnStart()
{
    
SetGlobalVarInt("VarNumber"0);


It's Global since I think we need to carry it into extra_english.lang and it's Int since other functions later on are mathematically working with this variable.

Here's the problem... I want to display the variable number as a message, hopefully with some other text. My try was doing the following:
PHP Code: (Select All)
void ShowcaseFunction()
{
    
SetMessage("Messages""NumberStatus" GetLocalVarInt("VarNumber"), 0);


But that doesn't work since what it essentially does is looking for "NumberStatus0" and that doesn't exist.
I need a way of displaying the variable in the message itself.

TL;DR problem:
You have a variable that is a number. How can you display the number on player's screen?

Did you try looking for a solution somewhere else?
Yes, I'm usually not asking for help with scripts, but this got me. I'm looking for 2 days now and Google nor FrictionalGamesWiki didn't provide me with proper answer.
Thanks in advance for any response.
(This post was last modified: 07-21-2015, 10:53 AM by Spelos.)
07-20-2015, 08:20 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#2
RE: Carrying variables and printing them

Isn't it better using AddDebugMessage?

AddDebugMessage(string& asString, bool abCheckForDuplicates);

If I'm not understanding you wrong.

Derp.
(This post was last modified: 07-20-2015, 09:28 PM by Neelke.)
07-20-2015, 09:27 PM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#3
RE: Carrying variables and printing them

(07-20-2015, 09:27 PM)Neelke Wrote: Isn't it better using AddDebugMessage?

AddDebugMessage(string& asString, bool abCheckForDuplicates);

If I'm not understanding you wrong.

That would work for a developer. But unless the player has a DebugMode on it's not going to show.
I meant this like a reminder to a player about the variable.
You can think of it like: "There are 3 leavers remaining." message after you pull one of the leavers down. Now the "3" would be the variable.
07-20-2015, 09:55 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#4
RE: Carrying variables and printing them

Well, AddDebugMessage and SetMessage are not the same thing. SetMessage is something that must use the extra_english.lang. So my suggestion then is to make a category for your variables.

<CATEGORY Name="Variable">
<Entry Name="NumberStatus1">1</Entry>
</CATEGORY>

Derp.
(This post was last modified: 07-20-2015, 10:15 PM by Neelke.)
07-20-2015, 10:15 PM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#5
RE: Carrying variables and printing them

Well I would do that, but as I mentioned, the project is working with the variable on a much larger scale. I mean... we're talking numbers from 1 through 600. I cannot possibly make a message for each number.
07-20-2015, 10:25 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#6
RE: Carrying variables and printing them

Unfortunately, you cannot modify lang text dynamically. It looks like you're gonna have to do it the hard way unless you invent another way of displaying your numbers. You could perhaps use custom entities, if your mod allows such and it makes sense.

(This post was last modified: 07-20-2015, 10:31 PM by Mudbill.)
07-20-2015, 10:31 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#7
RE: Carrying variables and printing them

(07-20-2015, 10:31 PM)Mudbill Wrote: Unfortunately, you cannot modify lang text dynamically. It looks like you're gonna have to do it the hard way unless you invent another way of displaying your numbers. You could perhaps use custom entities, if your mod allows such and it makes sense.

The "hard way" as Mudbill mentions, is adding these to your .lang.

<CATEGORY Name="Messages">
<Entry Name="NumberStatus0">0</Entry>
<Entry Name="NumberStatus1">1</Entry>
<Entry Name="NumberStatus2">2</Entry>
<Entry Name="NumberStatus3">3</Entry>
</CATEGORY>

And so on.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
07-21-2015, 12:14 AM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#8
RE: Carrying variables and printing them

I settled down for a different solution.
I made categories like this:
<CATEGORY Name="Messages">
    <Entry Name="NumberStatusHIG">The variable number is 500 or higher.</Entry>
    <Entry Name="NumberStatusMED">The variable number is between 200 and 500.</Entry>
    <Entry Name="NumberStatusLOW">The variable number is lower than 200.</Entry>
</CATEGORY>

Thus making it easier to manage the number. Fortunately for my project, precision is not needed.

Thanks everyone.
(This post was last modified: 07-21-2015, 10:51 AM by Spelos.)
07-21-2015, 10:51 AM
Find




Users browsing this thread: 1 Guest(s)