#dict help

1 messages · Page 1 of 1 (latest)

kind cloud
#

ok

onyx thunder
#

foreach(Vector3Int activeTile in cellDict.Values){ Debug.Log(activeTile); }
add this also

#

oh yeah and to differentiate make like this

#

foreach(Vector3Int activeTile in cellDict.Values){ Debug.Log("Dict Values:" + activeTile); }

#

that shows whats in active list
whats in dictionary as key and whats value in dict

#

if every value in dict is null, you prob have problem filling dict with values and setup is generally fine

#

but what i think the problem is, is that only last value in your dict is not null

kind cloud
#

178 seems to be showing a long list of vector3ints like i would expect, but 177 is only showing 2. but actually that's correct because on my tilemap that i drew from palette there are 2 active water tiles, so that seems ok

#

i could count them but it looks ok at first glance

onyx thunder
#

dont know lines

kind cloud
#

oh right

#

well the two foreaches you gave me seem ok

onyx thunder
#

foreach(Vector3Int activeTile in cellDict.Values){ Debug.Log(activeTile); }

#

what does this one say

#

think its most important

kind cloud
#

just a sec

#

in that dict the vector3int is the key, should i make it .keys?

onyx thunder
#

nope

kind cloud
#

it is erroring then

onyx thunder
#

values just prints out all values

#

oh yeah

#

foreach(CellData activeTile in cellDict.Values){ Debug.Log(activeTile); }

#

right

kind cloud
#

type mismatch

onyx thunder
#

CellData is value

kind cloud
#

sec

#

yeah all null

onyx thunder
#

didnt look but i think this is only place your cellDict is filled

#

instead of passing initCellData

#

make it
cellDict.Add(tileLocation, new CellData(put your values here with cell data));

#

then see if your line 163 still throws errors

kind cloud
#

one moment

onyx thunder
#

basically create new cellData and then change values to what you want

#

based on your setup think you will need to do this again

#

but instead of initCellData you would need to put cellDict[tileLocation].Index = something

kind cloud
#

in your last comment, when you said instead of passing initCellData, which line?

onyx thunder
#

145

#

FOR TESTING PURPOSES
cellDict.Add(tileLocation, new CellData());

change it to this only and then run code with
foreach(CellData activeTile in cellDict.Values){ Debug.Log(activeTile); }
in evaluteTiles function

#

just to be faster and sure

#

if you understand

#

and see if its all null still

kind cloud
#

i'm reading and absorbing lol

#

i guess i thought i was creating a new cellData in EvaluateTiles then adding it to the dict toward the end...

onyx thunder
#

?

#

can you elaborate

kind cloud
#

sure

onyx thunder
#

change only line 143 to
cellDict.Add(tileLocation, new CellData());

#

then add
foreach(CellData activeTile in cellDict.Values){ Debug.Log(activeTile); }

at start of evaluateTiles

#

it was all null before

kind cloud
#

ok let me try that one sec

#

when you say line 143 you mean the empty line?

#

err the one with }

onyx thunder
#

sry

#

145

kind cloud
#

np got it

onyx thunder
#

where you add to dictionary

kind cloud
#

still null

#

btw it is 76 tiles and 76 null

onyx thunder
#

oh and DictChecker report well?

#

all positions get debuged?

kind cloud
#

i had disabled, one sec

#

were you wanting me to replace the line at 145 or just add another one w/ the one you suggested? and actually no dictchecker seems to be reporting all 0,0,0 which is new ( i think it is commenting out 145 tbh)

#

lemme try uncommenting that and see

onyx thunder
onyx thunder
#

how is EvaluateTiles reporting null

kind cloud
#

ah i think i know what's happening there. new cell data has a 0,0,0 default vector3int but it's still got a tilelocation var you're passing in

#

idk lol

#

1 sec testing something

onyx thunder
#

can you paste new code

kind cloud
#

sure i was just thinking the same. but just for a report: the line at 145 (original) is needed for dictchecker to work. dictchecker reports all 0's without it etc. but with both dict add lines it throws error bc vector3int already exists in dictionary, but the one that you gave me doesn't actually associate w/ an existing celldata.

#

if i give you a code update it will look a lot like the original bc i commented some stuff out to test. you want me to send you a version f the one that wasn't working w/ your suggestion? sorry i don't mean to be confusing

#

the v3i is the key

#

for the dict

onyx thunder
#

send current version

kind cloud
#

aight

#

gimme a sec i gotta remove a bunch of extra comments lol

onyx thunder
#

ok, run program like it is and tell me what DictChecker says

#

then swap commentes on these lines

#

and do it again

kind cloud
#

76x default value (0,0,0). i don't see how it could be adding the data with a new celldata..

#

without populating it after

#

my strategy is to look at the tilemap and create a data file for each that exist at start, and assoicate w/ a vector3int and flag some of them as 'active' then in evaluate tiles i am going over that list of active tiles and pulling up the data file (class), applying changes as needed, and adding it back to the library. if no data file exists for a given vector3int in evaluatetiles(), then something has gone wrong already according to my strategy

#

err, when i say adding it back to the library, i meant updating the dict entry

#

slight misspeak there: if no data file exists for a given vector3int that has a tile, something broken

onyx thunder
#

and with 167?

#

do they both report error on new line 192?

kind cloud
#

no with both it throws a red error bc the key for the vector3ints already exist

onyx thunder
#

that makes no sense

kind cloud
#

lemme double check but yeah 192 is always reporting problems so far

#

i know right?

#

yeah it's throwing critical errors for the two active tiles in the list (from line 192)

#

not actual critical errors they're my own

onyx thunder
#

makes no sense since DictChecker reports every cell.Position to be 0,0,0

#

yet evaluate reports them as null

kind cloud
#

you're right that makes no sense

#

is my syntax for checking null right?

onyx thunder
#
foreach (Vector3Int key in cellDict.Keys) {
  Debug.Log("For key:" + key);
  Debug.Log(cellDict[key]);
  Debug.Log("Is active?" + activeTileList.Contains(key));
}
#

can you add this at end of DictChecker

#

and report what does it say?

kind cloud
#

sure 1 sec

onyx thunder
#

and for which lines debug reports Is Active?true

#

screenshot those lines

kind cloud
#

so the first part for key is reporting all of the v3i's apparently but there are no active tiles

#

it's a lot, bc it's all the v3is

#

wait

onyx thunder
#

there is no lines that report "Is Active?true"?

kind cloud
#

i take that back, it's reporting 2/76 as active, which is correct

#

and it's reporting the other 74 as false

onyx thunder
#

you can do WINDOWS key + shift + s

#

and you can screenshot only ones that are active

kind cloud
#

sorry i'm unclear what you want me to screenshot exactly. it's saying Is active?True twice and False 74 times, as well as listing the Vector3Ints

#

i could expand the list and sceenshot it but why lol

#

you're being helpful so i don't mean to be diffucult

onyx thunder
#

what does it say "For key"

#

and second part of debug

#

where it says value

kind cloud
#

For key(:Vector3Ints) <---- a list of all of them

onyx thunder
#

for lines that are true

kind cloud
#

it's not 0s

#

oh

#

ah i see now, i had it collapsed, oops

#

how do i attach my png

#

sorry i'm new to discord lol

#

nvmd

#

idk how to read that exactly

onyx thunder
#

yeah

#

now do the same buuuut

#

on these lines

#

comment line 167

kind cloud
#

k

onyx thunder
#

uncomment line 166

#

and do the same screenshotđ

kind cloud
#

seems the same. screen3 is for reference to show it's the same tiles v3i as the ones throwing the error in evaluatetiles

#

wait did you want my to uncomment 166 without commenting 167?

#

err, wait, which did you want me to comment lol

onyx thunder
#

167 to be commented

#

166 not

kind cloud
#

ok

#

that's what it was the first time..

#

i think. heck i'll just do it again

#

yep it's the same

#

either way, apparently. except the top part is 0s when i use the new CellData instead of initCellData, like we talked about before. it's the other debug.log

#

it's from dictchecker

#

top part of

onyx thunder
#

can you send CelllData scripts

#

script

kind cloud
#

sure

onyx thunder
#

betweeen these two lines

#

add

#
Debug.Log(initCellData);
Debug.Log(cellDict[tileLocation]);
#

see what it gives out

kind cloud
#

you got it

onyx thunder
#

see what is actually stored in storing part

kind cloud
#

to be clear at the moment i have cellDict.Add(tileLocation, new CellData()); instead of 167 .. only one will go.. which should i try first?

onyx thunder
#

line 167

#

with initCellData

kind cloud
#

k

onyx thunder
#

no need to try new CellData()

kind cloud
#

k, thought so

#

i think you found it? both null for some reason

#

(for all)

#

yep every 76 tile iterations for both

#

null

#

i dont get it lol. all in the same scope wtf

onyx thunder
#

check value of initCellData at line 119

#

right after asigning it

#

see if its null there also

kind cloud
#

do you mean just InitCellData or you want .Position?

onyx thunder
#

just initCellData

kind cloud
#

k

onyx thunder
#

just checking if its null

kind cloud
#

that actually looks redundant looking at it,

#

but that's probably irrelevant

#

1 sec

#

ok so this is going to trip you out

#

i'm getting null on that, but if i do .Position i get vector3ints

#

idk really know what this means, but is initCellData getting initialized correctly?

onyx thunder
#

if you can debug log initCellData and its null

#

then debug log its position and its there

kind cloud
#

yup

onyx thunder
#

idk

kind cloud
#

hahaha

onyx thunder
#

you put those 2 lines

#

together

kind cloud
#

you know what? i respect that

onyx thunder
#

119 and 120?

kind cloud
#

what's the question?

onyx thunder
#

debug for initCellData and positon

kind cloud
#

yes, i did both and the initCellData is null but initCellData.Position shows correct values

#

a class is something you can just Debug.Log normally right?

#

by itself..

#

either way it's showing null in results

#

so weird

onyx thunder
#

hey

kind cloud
#

yo

onyx thunder
#

add this to CellData

#

to script of cell data

kind cloud
#

k

onyx thunder
#

public override string ToString() { return "Position of this CellData:" + Position; }

kind cloud
#

just in vars?

onyx thunder
kind cloud
#

right but just with my vars

#

?

onyx thunder
#

what your vars?

kind cloud
#

variables, sorry

#

got it

#

i mean declarations

onyx thunder
#

yeah anywhere in public class CellData

kind cloud
#

alright it's in there..

onyx thunder
#

when debugging initCellData

#

type

#

Debug.Log(initCellData.ToString());

#

instead of Debug.Log(initCellData);

#

does it still give you null or ?

kind cloud
#

nope, lemme screenshot it

#

etc

onyx thunder
#

yeah

#

it has data

#

but initCellData reports null

kind cloud
#

does it matter that i'm naming my CellData class instances differently before trying to add them?

onyx thunder
#

what do you mean

kind cloud
#

like i have initcelldata in the first part and um

#

in EvaluateTiles i am using thisActiveTileData

#

it's the same Class

onyx thunder
#

nah

kind cloud
#

same constructor info

#

thought not

onyx thunder
#

thats different variable

#

and its not problem there

kind cloud
#

either way i want to say thanks for taking so much time. it's really appreciated.

onyx thunder
#

can you have

#

Debug.Log(initCellData.ToString());

#

and right below

#

Debug.Log(initCellData);

#

thats lines 119 and 120 i think

#

and screenshot it to me

kind cloud
#

two new lines?

#

er one

onyx thunder
#

idk how you have it right now

#

just after initializing var initCellData

#

and giving it values

#

have those 2 lines

kind cloud
#

oh right i had those. ok one sec

#

just commenting out some other debug stuff it's geting crowded

#

one sec tho

#

ok so those are both reporting their info correctly

#

you want a screen?

onyx thunder
#

yeah

kind cloud
#

k

onyx thunder
#

oh yeah tostring automatically is reported

#

hahahahahahaha

kind cloud
#

screen7 is better than screen6

onyx thunder
#

do the Debug.Log(initCellData==null); instead of Debug.Log(initCellData);

#

just making sure its null in if

kind cloud
#

yeah it's reporting true

onyx thunder
#

honestly have no idea

#

i mean

kind cloud
#

that's fair, it was still really helpful diagnostic

onyx thunder
#

wait a sec

kind cloud
#

i've been writing down what does/doesn't work

onyx thunder
#

try this

#

and then

#

if doesnt work

#

ask in code-advanced

kind cloud
#

k

onyx thunder
#

var initCellData = new CellData();

#

remove this line

kind cloud
#

where?

onyx thunder
#

and replace it with this line

#

no comments

onyx thunder
#

should be

#

cellDict.Add(tileLocation, new CellData());

#

replace it with this

#

wait

#

where you declare dictionary

#

remove the static part

#

do it public Dictionary...

#

this stuff

#

and leave your old code

kind cloud
#

k 1 sec

onyx thunder
#

does Debug.Log(initCellData==null); report true if you remove static from dictionary declaration

kind cloud
#

wait i'm confused. replace var initCellData = new CellData(); with cellDict.Add(tileLocation, new CellData());

#

??

#

if i comment the first it throws errors..

onyx thunder
#

leave var initCellData = new CellData();

kind cloud
#

k

onyx thunder
#

only thing to change is to remove static

kind cloud
#

k

onyx thunder
#

just to test if it messes with dictionary cause i never made static dictionary

kind cloud
#

damn i forgot i left that in there

#

i was just testing it for goofs

onyx thunder
#

dont see why it would mess it up but doesnt hurt to try

kind cloud
#

without changing anything else it doesn't seem to have done anything

onyx thunder
#

Debug.Log(initCellData==null);

#

still reports true?

kind cloud
#

yeah that's returning true

onyx thunder
#

okay

#

then

#

replace var initCellData = new CellData();

#

with

#

cellDict.Add(tileLocation, new CellData());

#

thats line 111

#

that should give you lots of errors where initCellData was

kind cloud
#

yya

#

i was waiting to see if VS would surprise me but nope lots of errors lol

onyx thunder
#

just replace initCellData

#

with cellDict[tileLocation]

#

where it gives error

kind cloud
#

interesting

#

ill try it

onyx thunder
#

that way you affect dictionary instead of variable

#

Debug.Log(cellDict[tileLocation]==null);

#

that should be new debug

kind cloud
#

i'm getting an error.. one sec

#

172 in the console is actually 166 in the code i posted. sorry i guess taking out the comments wasn't th ebest idea lol

#

that was also replaced with cellDict.Add(tileLocation, cellDict[tileLocation]); btw

onyx thunder
#

that needs to be removed

kind cloud
#

oh

#

right

onyx thunder
#

no need to add it twice to dictionary

kind cloud
#

yeah makes sense i'm just tired xd

#

exactly the same as before

#

w/ initcelldata

onyx thunder
#

hmmmm

#

then i have no idea

kind cloud
#

well, some of the debug stuff was removed, but for the stuff you asked for recenlty

#

it's still showing vector3ints though

onyx thunder
kind cloud
#

yep

onyx thunder
#

well still reports cellDict[tileLocation].Position correctly

kind cloud
#

all of em

onyx thunder
#

right

kind cloud
#

let me double check

onyx thunder
#

and cellDict[tileLocation] == null is true?

kind cloud
#

yea that's true

onyx thunder
kind cloud
#

yes, it does

#

er

#

it does report cellDict[tileLocation].Position

#

well like i said it's been very helpful diagnostic anyway. i'm following what you're doing.

onyx thunder
#

Ask in code-advanced
why
Debug.Log(cellDict[tileLocation].Position); reports position
but
Debug.Log(cellDict[tileLocation] == null); reports true

kind cloud
#

i will do exactly that, thank you very much again for your time

onyx thunder
#

can give them screenshots as proof

onyx thunder
#

and screenshot part of code that initializes
cellDict.Add(tileLocation, cellDict[tileLocation]);
assign of variables and then debug

#

i dont have any more ideas how to debug, never seen this problem before

kind cloud
#

well at least i feel better about going crazy for a couple days xD

#

take care, i'll be back i'm sure

onyx thunder
#

yeah sure, post here any info about situation

#

i would like to see how this is resolved

onyx thunder
#

oh got idea

#

remove : MonoBehaviour

#

and then see what debug.log gives

#

true of false

#

i think this is problem

#

@kind cloud

kind cloud
#

sec

kind cloud
onyx thunder
#

what?

onyx thunder
#

can you screenshot

#

error

#

and top of class

#

like this

kind cloud
onyx thunder
#

yeah

#

do you create that celldata somewhere

#

or assign it to some object?

#

that is problem i think

#

what you are looking at == null is gameobject which doesnt exist

kind cloud
onyx thunder
#

okay

#

do you use CellData

#

on some object

#

does some object have variabled public CellData

#

and then you drag this script to it?

#

OKAY

#

for simple resolution

#

change public class CellData to public class CellDataX

#

and see what problems come

#

class with data cant have monobehaviour

#

since it needs gameobject

kind cloud
#

nope there are no objects in the scene that have this script on it as far as i'm aware

#

i could put it on the tilemap or something

onyx thunder
#

then change name to CellDataX

kind cloud
#

which part, the script itself?

onyx thunder
#

yeah

kind cloud
#

and the class?

#

k..

onyx thunder
#

change that to public class CellDataX

kind cloud
#

k

#

without monobehavior right

#

?

#

ok i got a gazillion errors

#

lol

onyx thunder
#

yeah

#

just change every place that has CellData to CellDataX

kind cloud
#

can i ask why?

#

that's gonna really mess things up with vaiables

onyx thunder
#

well unity think CellData is monobehaviour from before

kind cloud
#

variables

onyx thunder
#

so we need different name

#

for class that is not monobehaviour

kind cloud
#

oh

#

no way to just get unity to reset or something?

onyx thunder
#

monobehaviour cant be used as regular class of storing data and needs gameobject

#

what we have done before is checking if class had gameobject but didnt since you used new CellData();

#

that cant be done

onyx thunder
kind cloud
#

ok

#

no worries

onyx thunder
#

easiest way is to close unity and delete Library folder in your project but that messes other things also

#

you can later change name back to CellData

#

when we make sure CellDataX works

#

when it works you go to CellDataX, right click and choose rename

#

change name and hit apply

#

this way visual studio will change class name everywhere

kind cloud
#

i got it. getting a different error now

#

progress!

onyx thunder
#

wait you have 2 scripts with public class CellDataX?

kind cloud
#

no..

onyx thunder
#

think you have 2 class definitions for CellDataX

kind cloud
#

no it's on line 11 hnag on

onyx thunder
#

this search will look for every definition of CellDataX class

kind cloud
onyx thunder
#

just make sure current project is selected

#

ctrl + f

#

and search should look like this

kind cloud
#

ohhh

#

lol i think might know

#

wait no

#

it's def possible i had another class called CellData in a different folder or something but no shot i had one called CellDataX, there's only one

#

and there's only 2 scripts in this project so far other than the scriptable object

onyx thunder
#

make search like on picture above

#

but

#

find all

kind cloud
#

ok

onyx thunder
#

downward arrow

#

it should throw list of all instances

#

can screenshot it for me

kind cloud
#

yep just one

onyx thunder
#

hmm cant really tell like this

kind cloud
onyx thunder
#

but there are definitions of CellDataX 2 times

#

i cant look it up myself hahahah

#

but you need to remove second one somehow and then it will work

kind cloud
#

sec

#

i swear on my life i was doing it right and somehow it didn't detect that unity had made another copy of celldata instead of renaming it (i used f2). welp yeah it's gone one sec

#

i just found it with the windows explorer

#

ok i think that did it. i'm getting false now

#

the copy wasn't showing in the assets folder either

#

wtf man lol

#

thing is trying to make me look bad

onyx thunder
#

refresh your inspector

#

and your code

kind cloud
#

it's good now

onyx thunder
#

evaluate should work now

kind cloud
#

oh wait

#

weird. one sec

#

gonna just exit both programs

#

is there something special i need to do to refresh other than restart? it's doing this again

onyx thunder
#

can you make new c# script

#

copy entire content of current script to that one

#

and delete current one

#

leaving only new one

#

i think this is only problem with unity

kind cloud
#

i was suspecting that as well

onyx thunder
#

if you understand what iam saying

kind cloud
#

oh i do

#

boy do i ever!

#

sure hang on

#

let me close both again

#

what's the best way to cleanly uninstall a package? i have the entities thing install and probably won't use it. i seriously doubt it is causing issues but it is in experimental so..

#

i'm not actually 'using' it for anything to my knowledge

onyx thunder
#

just deleting it from folder of project

#

but dont think you need to care about it

#

btw why are you using DataSpace namespace?

kind cloud
#

honestly i'm a noob i just wanted to make it so i could have access to it

#

without always referencing it

#

via object

onyx thunder
#

remove namespace, not useable

#

namespace is when you create modular tool that can be used in many projects

#

so you just import the tool and use it with namespace

#

namespace doesnt help with referencing, for that, take a look into singleton

#

object that can always be referenced

kind cloud
#

k, almost there

#

ok i've done that. exited everything dragged all but flowmaster out, copied contents of celldatax to new file new name dragged it back, updated references in flowmaster

#

and gonna open unity again

#

er, new file, not celldatax obviously

onyx thunder
#

whatever you want

kind cloud
#

hmmm it seems like it might be working?

#

remind me what i'm looking for

#

or i can screen

#

no errors reported by unity, and i'm getting false plus positions

onyx thunder
#

it means it works

kind cloud
#

YAY

#

damn you're a saint

onyx thunder
#

now evaluate should now correctly pass the if

#

and do your later code

kind cloud
#

let me see

onyx thunder
#

whatever you were doing it

#

took me way too much to check the class hgahhhahahha

kind cloud
#

hey i appreciate it. i never ever would have caught that. not without like 2 courses

#

not to mention solving it

#

yeesh

#

can i rename it again or is unity going to remember celldata still?

#

i liked that name 😦

onyx thunder
#

yeah change it now

#

dont think it should cause more issues

#

unity can act weird sometimes

#

dont use namespaces until you become good at programming and start creating your tools, its usefull but can overwhelm you

kind cloud
#

a thing of beauty

onyx thunder
#

for naming, try to name your script same as your class

kind cloud
#

ok thanks again. what an annoying issue. i really could have wasted weeks on that. we were at it for like 5+ hours! seriously. thank you.

#

i'm gonna go make some tea. have a great day. hope i see ya around soon!

onyx thunder
#

hahahahahaa

#

np

kind cloud
#

i'm gonna go tell the other thread(s) that it's solved