#The gameobject has the same variable as the other gameobject, even though they have seperate scripts

1 messages · Page 1 of 1 (latest)

glacial scarab
#

I will explain more tommorow, gotta go. Goodnight

gaunt fjord
#

Yeah gn

static elk
#

i think the issue is InteractionRadius is running on all flasks instances. so when a 2nd flask is added, after combining the mixture, it is added to all (in this case both) instances . . .

#

that is why you receive the error. only the current flask should have InteractionRadius enabled to run . . .

#

or when you press confirm, it should only add to the current flask instance of InteractionRadius . . .

gaunt fjord
#

After your exams, create a flask and then fill out the info. Create another flask and then fill out its info. We already know that it errors once, but hypothetically if the first flask is the one that error’d that message, then if you create a third flask you should get 2 error messages from the first 2 flasks (totalling to 3). If that’s the case, then we know that the issue is that interactions are being shared among all of them for some reason. Anyways good luck on your exams!

glacial scarab
#

Having extra lessons etc

#

The actual exam is on 24th of may

gaunt fjord
#

Yeah thats understandable, I have exams also this week

glacial scarab
#

ah, good luck on them then!

#

well huh

#

not sure how to interpret this

glacial scarab
#

fuck

#

Forgot to revive the thread

glacial scarab
#

again

#

so uh, @static elk , I hope you don't mind being pingged

glacial scarab
#

I don't see your message for some reason @static elk

#

weird

#

either way - not sure what to do with that

static elk
#

Which message?

glacial scarab
#

where you said s'up

#

either way

#

I have no clue how to fix this

#

Hm, I have an idea.

#

Basically a seperate script which would store the values individually

static elk
#

Did you read my previous messages? Log the name of the object right before you add it to the dictionary. That way we can see what object is doing it . . .

glacial scarab
#

I did that

#

wait..

#

interesting

#

it sends it 3 times

#

ah fuck hold on

static elk
#

you didn't log the name of the object so you know which object is adding it . . .

#

multiple components are attempting to add to a dictionary. just log the object before you add it to the dictionary. then you will know, that's it . . .

glacial scarab
static elk
#

So it's adding multiple times on the same one and not each separate one . . .

glacial scarab
#

Well, both of the gameobjects are named the same so

glacial scarab
#

so what shalt I do

glacial scarab
#

@static elk (sorry for the ping again 😦 )

static elk
glacial scarab
glacial scarab
#

so yeah

#

not sure what's wrong

#

okay well time to try something

static elk
#

Oh, they are originally the flask, but change to the name of the element?

#

So each flask (or instrument) used to contain the element has their own script with a dictionary, correct?

static elk
#

Okay, so, when you create the final compound, that compound is added to the instruments' dict, right? (trying to get the process down) . . .

glacial scarab
#

mhm

#

but here the error appears on the stage of parsing/tokenizing

#

basically splitting up the equation into seperate atoms etc

static elk
#

The question is: what code is executed when the button is pressed (that creates the final compound)? Because, when it's pressed, it adds to the instrument (flask) dict — this works correctly the first time — but when you create a 2nd flask and press the button to add the compound, it adds it to the 1st flask and receives the duplicate key error . . .

glacial scarab
#

OH SHIT

#

I JUST REALISED

#

I HAVE A BUTTON LISTENER

#

THAT'S THE CAUSE

static elk
#

So I would check the button and how it calls the method . . .

glacial scarab
#

nono like

#

when that button is pressed

#

the listener activates the rest of the code

#

in this case it does it for all flasks that have the listener

static elk
#

If every instrument listens to it, they all will attempt to add the compound . . .

glacial scarab
#

so I have to change the method

#

yup

#

but the issue now is how to change it so it only works on the flask that has the reaction

static elk
#

Hold on, BRB . . .

glacial scarab
#
confirm.onClick.AddListener(Amount);```
#

hmmm

glacial scarab
#

okay I'm not sure bruh

#

it would seem like a simple thing to solve but nope

static elk
#

you can do 2 different things: what i mentioned before was, reference the current instrument (flask) and call the method via the reference; or add the instrument (flask) method to the button listener when it's the current one and remove it from the button listener after using it . . .

glacial scarab
#

uh, what do you mean by the first one?

gaunt fjord
glacial scarab
#

Okay but what if I'll need to reuse this flask? Aka add some more reactants to the flask?

gaunt fjord
#

And then store that reference, and once you are finished, remove the listener

glacial scarab
#

hm, maybe

static elk
# glacial scarab uh, what do you mean by the first one?

first off, you should really have a manager/oversight class that handles/tracks all the compounds of the equation. when you hit the button to add the compound, it'll go into a list/dict on the manager instead of on the actual instrument. this avoids needing to select the current instrument to add to their dict . . .

glacial scarab
#

YES I FIXED IT

#

THANKS LADS