❔ Cant Find Key Type Byte In Dictionary?
Dictionary contains variables which are given byte values.
These values are not in order, they go from 2 3 4 5 -> 13 then jumps a few to 30 -> 40.
Which is why I set it up in a dictionary.
This dictionary is never modified given its a static. So I have no clue why it can't find "3" in the dictionary with should and is "ItemData.MaxMP"
27 Replies
Some Screenshots:
If it would make it any easier
I can go through a screen share session.
To explain the process.
1: I look inside a dictionary and grab bytes that will translate to values higher than 0.
2: Store them inside a list of bytes.
3: Then roll a random byte out of that list (simulating rolling a random stat to enhance out of 4 stats)
4: Then call back to the same dictionary I used in step 1 to grab the value of that stat.
Finally, set the value of that stat to be increased by a random %, up to 20% and append it on top of the value the stat already had.
Everything works except that i'm getting this weird error... that of which I cant find a solution for.
AGONY
I don't know the answer, but I recommend setting a breakpoint and inspecting the contents of the dictionary in the debugger
hmm so im noticing something weird or maybe Im thinking of dictionaries wrong...
so when calling a value of a specified key, you use dictonaryName[key]? Correct?
that returns the value by default?
Wait im so much confusion...
why is 4 5 6? where is 2??? what?
where is it getting these values is my question
hmmmmmm... count 18, i have 21 elements...
that'll heavily depend on your code
okay lemme look around, im doing something wrong, i thought it was the dictionary but its not.
Hello
I see the issue I think...
To which I have a question
How can I copy over a dictonary to another variable
without modifying the original dictionary?
because I thought this would make a local clone of the dictonary in my function
so I could check which stats could be rolled
but instead, it modifies the original dictionary...
which it kinda makes sense why it doesnt clone it
it just points to the dictonary
not makes a new one
create a new dictionary and insert new keys/values into it
just to turn this into a learning experience
a dictionary is a object and is not a datatype.
It's pass by reference vs pass by value
so when u copy an object in a variable
yeah okay
and quick question
is it possible to copy a array by just doing var array = otherarray
and when u modify the array variable, only that array is modified.
not the other
Value types - C# reference
Value types vs reference types, kinds of value types, and the built-in value types in C#
is it possible to copy a variable by just doing var array = otherarrayno, you need to create a new one somehow. For an array you can do
var array = otherarray.ToArray();
so you save the reference to an array when you assign it to a variable.
to make a new array, you have to assign it to an array value?
like not value but something that returns an array.
if you wanted to do it yourself you could do:
that's what ".ToArray()" does
I think there's an equivalent "ToDictionary()" too, but I'd need to check
oh
okay thanks for the help
thats interesting, never really noticed this stuff
but it makes sense
looks like
var clone = new Dictionary(otherdictionary);
sounds good
thanks a lot, any info on how to close these?
oh wiat i found it
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.