Author Topic: How can i make my Computer tell me a INT variable?  (Read 1899 times)

ullih

  • Guest
How can i make my Computer tell me a INT variable?
« on: June 22, 2019, 06:57:25 AM »
Hello Everybody,

this may be a stupid question but...
EDDI gives me a variable how many limpets i have aboard ( {INT:Ship limpets carried} )
How can i change this to a variable my Computer will tell me (We have XXX limpets aboard!)
I thought it was easy to do, but somehow, what ever i try it don't tells me the number of limpets aboard!

Best regards,

Ulli

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: How can i make my Computer tell me a INT variable?
« Reply #1 on: June 22, 2019, 07:57:01 AM »
"{INT:Ship limpets carried}" is not a variable by itself, it's a variable name wrapped in an "{INT:}" token, so it'll be replaced by the value of that variable.

If you want to use the variable by itself the name would be "Ship limpets carried".


If you want to use the variable in a TTS action, you'd use the token:
Code: [Select]
Say, 'We have {INT:Ship limpets carried} limpets aboard!'

If you want to use it in a condition, for example, you'd use the variable name:
Code: [Select]
Begin Integer Compare : [Ship limpets carried] Is Greater Than 0
    Say, 'We have limpets aboard!'
End Condition

ullih

  • Guest
Re: How can i make my Computer tell me a INT variable?
« Reply #2 on: June 23, 2019, 05:31:45 AM »
Hm, ok, i did and it says "We have still 0 (zero) limpets aboard!"
Anytime!
Even if i have 6 or 2 or how much ever limpets aboard, it always says "0 limpets"!
Confusing!  ???

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: How can i make my Computer tell me a INT variable?
« Reply #3 on: June 23, 2019, 06:28:32 AM »
If it says "zero", the variable has been set by something (otherwise it would say "not set").

Unless you're explicitly changing the value within your profile, that likely means EDDI is setting it that way, so you'd have to ask the author of that plugin about probable causes.

corinthian

  • Newbie
  • *
  • Posts: 2
Re: How can i make my Computer tell me a INT variable?
« Reply #4 on: June 26, 2019, 09:04:07 PM »
I find the EDDI INT variables difficult to work with. Usually I just convert them to the format I want, as in this example:
Code: [Select]
Set integer [eddi_context_landing_pad_pad] value to the converted value of {INT:EDDI docking granted landingpad}

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: How can i make my Computer tell me a INT variable?
« Reply #5 on: June 26, 2019, 09:46:53 PM »
That conversion should not change the value at all; The only thing it will achieve is making a copy of the value under another name, by first using a token to return the value as text, then converting that text back into an integer value...

If you want to use variables set by EDDI in fields that directly accept variable names, you need to remove the token from it.

E.G.
Code: [Select]
{INT:EDDI docking granted landingpad}is an "{INT:}" token wrapping the actual variable
Code: [Select]
EDDI docking granted landingpadis the name of the integer variable EDDI sets

corinthian

  • Newbie
  • *
  • Posts: 2
Re: How can i make my Computer tell me a INT variable?
« Reply #6 on: July 03, 2019, 06:00:44 PM »
Thanks, the difference between tokens and variable names is probably the root of my confusion.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: How can i make my Computer tell me a INT variable?
« Reply #7 on: July 03, 2019, 07:49:26 PM »
All tokens are a replacement for literal text (in fields that parse tokens).

E.G. if you have a text variable named "MyText" with the value "This is some text",
Code: [Select]
Say, '{TXT:MyText}'
would have the exact same outcome as
Code: [Select]
Say, 'This is some text'

Tokens that take variables do read the current value as they're parsed, so if you were to change the value of "MyText" to "This is some other text", in the above example the token would be replaced my "This is some other text", rather than "This is some text".


A variable name by itself is meaningless in fields that expect literal text, so if you have
Code: [Select]
Say, 'MyText'
the TTS engine will just say "my text", as it has no way of knowing that you're referencing a variable.



A caveat to this is that fields that take both tokens and variable names, will assume you're entering literal text if you use tokens, rather than a variable name.

E.G.
Code: [Select]
Set integer [count] value to 1
Set Text [variable1] to 'text'
Begin Text Compare : [variable{INT:count}] Equals 'text'
End Condition
will not work as expected, as "variable{INT:count}" will be replaced by "variable1",  but interpreted as literal text, in which case "variable1" does not match "text"

To make such a comparison work, you need to get the value of the variable using another token, so the condition will compare the literal text of that value, to the literal text you entered in the "Text" field:
Code: [Select]
Set integer [count] value to 1
Set Text [variable1] to 'text'
Begin Text Compare : [{TXT:variable{INT:count}}] Equals 'text'
End Condition


In addition, because literal text (which is what tokens become after they're parsed) is not a reference to a variable, checking whether it has been set to a value will not work.
E.G.
Code: [Select]
Set integer [count] value to 1
Set Text [variable1] to 'text'
Begin Text Compare : [{TXT:variable{INT:count}}] Has Been Set
End Condition
will always return false.


The only way to check whether a variable is likely to have a value when using tokens, it to compare against the literal text "Not set":
Code: [Select]
Set integer [count] value to 1
Set Text [variable1] to 'text'
Begin Text Compare : [{TXT:variable{INT:count}}] Does Not Equal 'Not set'
End Condition

The limitation to that is that there is no way to know whether it's the variable you're checking that doesn't have a value, or whether it has the literal text value "Not set" (which could happen when you set the value of that variable using tokens).