Read Private Variable Dynamically?

For questions about using Classic.

Post » Sun May 31, 2009 5:32 pm

I was answering this segment of the opening post:

SET NPC('STRING'): "MOVEMENT" & NPC('NUMERIC')
SET NPC('STATUS'): NPC.Value(NPC.Value('STRING'))

which attempts to dynamically read a private variable without explicitly naming it. This is not possible.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sun May 31, 2009 6:31 pm

[quote="Rich":1nd7w4n3]I was answering this segment of the opening post:

SET NPC('STRING'): "MOVEMENT" & NPC('NUMERIC')
SET NPC('STATUS'): NPC.Value(NPC.Value('STRING'))

which attempts to dynamically read a private variable without explicitly naming it. This is not possible.[/quote:1nd7w4n3]

right:
[quote:1nd7w4n3]--STATUS = WHAT NPC IS DOING
--NUMERIC = TEMPORARY NUMERIC VARIABLE HOLDER
--STRING = TEMPORARY STRING VARIABLE HOLDER[/quote:1nd7w4n3]
that's all the variables he needs

I believe he meant to say:
SET NPC('STRING'): "MOVEMENT" & NPC('NUMERIC')
SET NPC('STATUS'): NPC.Value('STRING')

the symptoms he was having also point to that. he said when he read the value of Status is was coming out as a long number instead of the value of NPC.Value('STRING'), which was holding the correct value

this statement
NPC.Value(NPC.Value('STRING')),
would cause that problem, because by accident or design, this statement is valid, but does not automatically convert STRING to a string value. Unless he explicitly made it a string in the private variable editor, by default, STRING is a numeric value, which normally doesn't matter unless you use that exact (npc.value(npc.value('STRING')) syntax. i think it was a typo
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests