How do I Pick Instance with UID

Get help using Construct 2

Post » Wed Nov 04, 2015 2:16 am

not sure why this is not working,
Image

with is blank and no checks it changes them all. when the check for the text "U" is only changes all the stars that are "U". If I select
Pick nearest/furthest and set the exact coordinates of the star right bellow each text it works, but sometimes it will change other stars next to it, so not working perfect. do you have another idea to pick the right label with the right uid so only that object gets its text changed?

so run the game, select the star with a U, scan it, and wait. the closer the star to the ship the faster the scan. just FYI for debuging

here is the capx:
https://app.box.com/bridge-command

Its in the Main Event sheet. the code will take each text.uid and store it in an array next to the star.uid when created.

"S"&starData.At(starData.IndexOf(Star.UID), 10) position

the star UID is stored in a global var called starselected for each star you select. the text on the right of the screen if for debugging.

Snumber = Charted Stars
U = Uncharted ( percent will scale down to 1% change to spawn, set to 90% for debugging)

Controls are:
G = hide grid
S = save state
L = Load state
mouse Scroll in or out to Zoom
Left click to select
if you enter coordinates in the textbox on top double click it when finished to move the ship in the angle of the direction you entered.
B
8
S
1
Posts: 72
Reputation: 721

Post » Wed Nov 04, 2015 3:16 am

Two issues,

First you have:
Pick Instance with UID starData.At(starData.IndexOf(StarSelected))

when it should be: starData.At(starData.IndexOf(StarSelected), 10)

Second, when you create your data in your Functions Event sheet. You have a condition for when stars have not been picked. The Data is then pushed on the array and edited. You had this AFTER your naming < 10 and else condition...it needs to be before it.

Example:

Currently you have

if naming < 0
---do blah
else
---do other blah
If star has been not selected
---do some blah

But it should be:

If star has been not selected
---do some blah
if naming < 0
---do blah
else
---do other blah

After those 2 changes, it works.
B
41
S
17
G
8
Posts: 484
Reputation: 8,261

Post » Wed Nov 04, 2015 3:32 am

OMG you are the best! I didn't even think of the order of creation, so simple too! I feel better now haha!
B
8
S
1
Posts: 72
Reputation: 721


Return to How do I....?

Who is online

Users browsing this forum: varr and 3 guests