#Save system help
1 messages · Page 1 of 1 (latest)
yes so what do we do now?
You need to get the index of the item
also i cannot loop here to get index
cuz if i do so, there same prefab will be build n number of timems
times
Of course you can. You can loop anywhere.
That method doesn't have to be in the loop...
But it's better to do what Praetor suggested
Where does the item here comes from?
No, I mean where does the item variable in the previous screenshot comes from?
It would be simpler if you share your script properly.
properly like? whole thing ?
Yes. Check #854851968446365696 on how to share code.
Share this script and InventoryManager too
And Item?
You can add a public int itemId or something to the item.
Then in your inventoryManager.Start change foreach to a regular loop and assign the iterator to itemId
Then you can use that itemId in your saving system.
assign iterator to itemId mening?
iterator is the int variable that you use in a for loop to iterate the array
for(int i = 0; i < length; i++) < i is the iterator
you assign the iterator to itemId
of each item
Don't tell me I need to explain how to assign a value to a variable...
No, the loop needs to be a normal loop iterating your startItems
wait this is not a normal loop?
inside the loop block, you assign the value to the itemId
doesn't seem so.
How do we write a for loop?
assign the iterator value to the itemId
to itemId of an item that we are currently iterating
what does that have to do with what we're doing?
then how do i get itemId of Item class
I'm not gonna explain that because that's the very basics of basics of programming. Either google that or go do the beginner course and come back when you know how to do that.
wrong
That is a type. You can't apply indexing operator to a type.
Array was jus representing any array
If you wanted to represent any array, why not actually use the array that you do need to access?
i dont kow which array we need
I've mentioned that at least several times.
And you even have it in the loop declaration
Obviously, because you need to do something with it
assign the id of the iterated item
this?
all the items that are iterated one by one from the loop
so it's an Item instance, right?
yes
and what did I ask you to assign?
assign the id of all the items that are iterated one by one from the loop
assign to who tho
to all the items that are iterated one by one from the loop
that's what I said
when I say assign id of X, it's the same as saying assign some value to id of X
- I said that multiple times.
the iterator - You're not assigning the Id here.
you want to assign the iterator to an id of the item...
This assigns an item id to an item variable
Which is not gonna work
because Item != int
doesnt iterator here mean i?
Yes
so i assigned i?
Not in this screenshot
but but.. u said this
Yes. And the reply was still wrong
How do we assign some value to the id of an item?
with =
left should be the variable in which we need to assign the item to
and right shud the which value to assign to the left side
correct
finally something correct
so write it according to your reply
Are you just trying random things..?😅
nooo
what's supposed to be on the right side?
assign the id
isnt id the startItem[i]?
id was the iterator?
whaaa....
oh yes this is not id, these are items in the array
Yes
what is the id?
when u say id, item.itemId comes to mind
That's right
what....
I'm asking again, what's startItem[i]?
items that are iterated
... What's startItem[0] then?
Okay, good
We want to set the Ids of each item in the array
startItem[i] is not "items"
it's one item
yes
Okay, then how do we set an id of one item?
Nooo....
Why are you keeping on changing the correct part?
the right side was correct
it needs to be i
yes, but instead of the item it needs to be the item that we are iterating in the loop
i had no idea we could do this, well now it makes sense tho
dont tell me m wrong again
And that's why I refuse to help you until you do C# beginner course.
I'm sorry. But that's too much...
sorry for the trouble
Anyways, with this you've got half of the job done.
umm thank you
But please do your learning before continuing with the project. I'm saying it for your own good, trust me.
okayy
no last part?
The last part is to save the ids of the items. And use the saved ids when you load the saved data to instantiate the corresponding prefab.
That is all very simple code wise. If you learn the basics properly, you'll be able to implement that easily.
And you don't need to
You use the id to get the right prefab from the startItem array and instantiate it
If data.prefabs is the ids, then that part at least should work.
is it is itemIds that was stored in data
Then yes. That should instantiate the correct prefab. Assuming there are no mistakes anywhere along the way.
i am getting null rip, i fked up again. i go check
i dont wanna disturb u more but again idk who else to ask so. very sorry
Do some learning, then you'll be able to solve the issues yourself or ask more appropriate questions.
i picked this topic for a uni project and i dont have mcuh time so this all is in a rush
thats why i cudnt do much learning
How much time do you have?
my vacation is for 8 more days and then we will get more assignments so m trying to complete as much as possible in this vacation
Spend a day or 2 on learning C# basics and debugging and you still have 6 days to get it done.
but this part is not the only thing left to do
well its fine ill try to figure it out
thank you for the help today
Well, what other option do you have? Ask other people to do the project for you?
Next time be careful with the scale of the project and make sure you have the skills required to complete it.
ill do it myself
if i cudve chosen i wudve chosen a differnt topic welp
What was the topic?
i vudnt bring out ideas for web dev that were promising and this was the only one that thought was good enough so iiwii
The error is pretty clear: you can't instantiate scriptable objects with position and rotation.
Anyways, I'm off to sleep.
oke