tokenat, global var & function problem

Discussion and feedback on Construct 2

Post » Mon Apr 21, 2014 2:15 pm

Sorry - got three versions installed.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Mon Apr 21, 2014 2:22 pm

DUTOIT wrote:@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.

Code: Select all
tokenat(Item,ItemDat_Stat,"'") -> PlayDat_HP -> varPlayDat_HP -> Number


@Ashley We do not have some kind of forcing string "" in to calling a var of the same name? Something like var("PlayDat_HP")?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Mon Apr 21, 2014 3:07 pm

megatronx wrote:
DUTOIT wrote:@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.

Code: Select all
tokenat(Item,ItemDat_Stat,"'") -> PlayDat_HP -> varPlayDat_HP -> Number


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


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
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Mon Apr 21, 2014 3:39 pm

@DUTOIT, megatronx is looking for an expression that turns a string into a variable. No such functionality exists in C2.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Mon Apr 21, 2014 3:44 pm

blackhornet wrote:@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?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Mon Apr 21, 2014 3:55 pm

I've never heard of any language that could do that, although I'm sure somebody will come along and prove otherwise.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Mon Apr 21, 2014 3:57 pm

blackhornet wrote:I've never heard of any language that could do that, although I'm sure somebody will come along and prove otherwise.


Well it's not exactly turning string in to variable, but turning string in to a variable name ( that is already set ), so it can request it's value.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Mon Apr 21, 2014 3:58 pm

You can use the Dictionary if you need this type of functionality.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Mon Apr 21, 2014 3:59 pm

blackhornet wrote:You can use the Dictionary if you need this type of functionality.


ok, will look in to it. Thanks for the advice.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
30
G
22
Posts: 1,985
Reputation: 20,099

Post » Mon Apr 21, 2014 5:19 pm

That's kind of like that Star Trek episode where the aliens only spoke in metaphors.
If you don't know what the metaphor is referencing it means noting to you.
Basically its out of scope to the computer.
Image ImageImage
B
169
S
50
G
174
Posts: 8,327
Reputation: 110,798

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 21 guests