Author Topic: Is there anyway to inform the PC on the value of a certain variable?  (Read 331 times)

Legacy_simomate2

  • Full Member
  • ***
  • Posts: 133
  • Karma: +0/-0


                Through conversation? Its to do with my relationship system I mentioned on another thread. i want to be able to tell the player exactly what value the variable (the relationship they have the the NPC) is. Obviously this is possible by making 30 different possible dialogue possiblities each testing for a specific value but this is not worth the effort quite frankly '<img'>

So is there a simplier way? If not, I shall just have to inform the PC on what of the 3 relationship types they have. 
               
               

               


                     Modifié par simomate2, 24 mars 2013 - 10:09 .
                     
                  


            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Is there anyway to inform the PC on the value of a certain variable?
« Reply #1 on: March 24, 2013, 01:37:08 pm »


               Dialogue texts can make use of so-called "custom" tokens, which act much like placeholders that will be substituted with arbitrary content that a script can fill on-the-fly. If you are used to C or a C-like language this is the closest thing to a printf().

Look up the function SetCustomToken() in the Lexicon to learn more.

[edit]
Technically you can use any token number in the range [0 to 2147483647], but I advice you to avoid the tokens in the range [0 to 9] as they are used by the engine. Any content you place in them is liable to be overwritten as soon as the game sends you a console message.

Before you ask: No, there is no function to *query* the current content of a given token. Either you know it already or you are in the dark. Know that any script anywhere can modify any token number at any time. Meaning that you have no guarantee that your tokens will retain your last entered values for the time being. Best practice when using custom tokens is to constantly *refresh* their content right before making use of them.


-fox
               
               

               


                     Modifié par the.gray.fox, 24 mars 2013 - 02:25 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Is there anyway to inform the PC on the value of a certain variable?
« Reply #2 on: March 24, 2013, 02:41:00 pm »


               I would just do it in a floating text string over the pcs head at end of conversation - much easier than adding a token, unless you need the conversation to proceed after that. Heck, if you're using a chat event, you might as well just give the pc a command to check all their relationship statuses and print them to their combat log with SendMessageToPC. Or, if that strikes you as too complex, just give them an item with an onused that does that.

As for the mechanics of it, you just need to convert each integer variable to a string with IntToString, and stick them in whatever text string you like (you'd wind up doing that for the custom token as well.)

Custom tokens are, of course, a perfectly fine way to do this, but I think also a needlessly complex way for a simple info dump.

Funky