compare with a string that isn't created?

For questions about using Classic.

Post » Fri Jan 18, 2008 7:17 am

Is it possible to check how many private strings an object has? In mmf it was possible by a bunch of events looking like this: Alterable string A of "object = <> "". But that's not possible in construct cus you cant compare with a string that issn't created.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Fri Jan 18, 2008 10:14 am

Why do you need to know how many private variables an object has? There's no expression to get the count at the moment. I guess you could always add spares and compare to see if those are empty or not?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Jan 18, 2008 3:28 pm

I'm creating a system for my rpg where you can talk to people, and to make it easy to create levels i want to just ad any number of strings to an object, and when you overlap it, one of the strings are displayed at random. So i want to create an event like

Player overlaps Talking-Set text "Talking.String(1+random(number of strings))"

Something like that. I don't want to write how many strings the object has in a separate value, and i don't want to create ten strings for every new guy i create.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Fri Jan 18, 2008 4:31 pm

You could have a private variable for the number of strings on each talking NPC.
So it would be "Set text "Talking.String(1+random(Talking('numstrings'))" or something to that effect. (I believe private variables are referenced with object('variable') are they not? Or at least, object.variable has never worked for me)
B
3
S
2
G
4
Posts: 130
Reputation: 1,735

Post » Fri Jan 18, 2008 7:47 pm

I try to avoid repetitions. Its very unpractical if i'm going to have 100 diffrent persons talking, and if i want to change around while i create the game. I would like a simple way to retrieve the number of strings, and/or a way to name a string by a number, and not just the name (for example, display string #3 would display the third string, if it exists. Otherwise the string counts as empty.)
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Fri Jan 18, 2008 8:45 pm

Well, it's easy to add. 0.91 has a 'get private variable count' (Sprite.NumVars) expression.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Jan 18, 2008 10:15 pm

Wow, you're really incredible. Thank you very much.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests