tokenat, global var & function problem

1 favourites
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Yo,

    I'm fighting with one function call. Basically I'm using tokenat to get global variable, and send its value to function. But it doesn't work! The variable is not being called ( as it's being taken as a string). Don't know if it's a bug or by the design - can anyone help?

  • I've had similar weird frustrations in the past but I've not encountered this one. Try creating a local variable and first assign it the token-at value before then passing the local variable in the function call? Ie no text calcs inside the function call command. Hopefully might help you...

  • I've had similar weird frustrations in the past but I've not encountered this one. Try creating a local variable and first assign it the token-at value before then passing the local variable in the function call? Ie no text calcs inside the function call command. Hopefully might help you...

    Thanks, but I've tired that already and with no luck. :/

  • Can you post a sample? I've tried this, as I understand it, and it works as expected.

  • Can you post a sample? I've tried this, as I understand it, and it works as expected.

    Thanks, but I'm still using r163.

    Here's the screenshot of the calls. If you need capx, I can pm it to you.

    [attachment=0:lt38ngsh][/attachment:lt38ngsh]

  • tokenat is a text expression. Use int(tokenat()) if it needs to be (is) an integer.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • tokenat is a text expression. Use int(tokenat()) if it needs to be (is) an integer.

    I did try that too, but it doesn't work either.

  • As long as your ItemDat_Stat is correctly formatted, it should work fine.

  • As long as your ItemDat_Stat is correctly formatted, it should work fine.

    Still can't open the capx. It says it was saved in 167.2.

  • megatronx,

    Screenshot of blackhornet capx.

    It does work.

  • Sorry - got three versions installed.

  • megatronx,

    Screenshot of blackhornet capx.

    It does work.

    Thanks for that.

    blackhornet I can see now that there must be some misunderstanding. Basically tokenat(Item,ItemDat_Stat,"'") is returning the name of a global variable ( for example PlayDat_HP ), that holds a number. And I want to access that number within that call.

    tokenat(Item,ItemDat_Stat,"'") -> PlayDat_HP -> varPlayDat_HP -> Number [/code:1d8grc0y]
    
    

    Ashley We do not have some kind of forcing string "" in to calling a var of the same name? Something like var("PlayDat_HP")?

  • > megatronx,

    >

    > Screenshot of blackhornet capx.

    >

    > It does work.

    >

    Thanks for that.

    blackhornet I can see now that there must be some misunderstanding. Basically tokenat(Item,ItemDat_Stat,"'") is returning the name of a global variable ( for example PlayDat_HP ), that holds a number. And I want to access that number within that call.

    tokenat(Item,ItemDat_Stat,"'") -> PlayDat_HP -> varPlayDat_HP -> Number [/code:1lqkcohk]
    
    

    Ashley We do not have some kind of forcing string "" in to calling a var of the same name? Something like var("PlayDat_HP")?[/p]

    NP,

    And itemDat_Stat is a variable right? And have you checked that variable is a number not text.

    I see you using itemDat_Stat as an index which requires it to be a number.

    Edit: I am going to have to play around a bit. Will look at this a little later

    Can you put together a small test capx just dummy variables with itemdat_stat and the tokenat culculation. I will try and mess around with it. Or a little more detail so I can build a simple example.

    Also regex might be a better fit for complicated searches etc

  • DUTOIT, megatronx is looking for an expression that turns a string into a variable. No such functionality exists in C2.

  • DUTOIT, megatronx is looking for an expression that turns a string into a variable. No such functionality exists in C2.

    I thought so! :/ At first I thought it would work automatically. Bugger. Shall I make a request?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)