#Save system help

1 messages · Page 1 of 1 (latest)

atomic ibex
#

Because your method takes an int. Not an Item

limpid locust
#

yes so what do we do now?

atomic ibex
#

You need to get the index of the item

limpid locust
#

also i cannot loop here to get index

#

cuz if i do so, there same prefab will be build n number of timems

#

times

atomic ibex
#

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

atomic ibex
limpid locust
atomic ibex
#

No, I mean where does the item variable in the previous screenshot comes from?

#

It would be simpler if you share your script properly.

limpid locust
limpid locust
atomic ibex
atomic ibex
atomic ibex
#

And Item?

atomic ibex
#

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.

limpid locust
#

assign iterator to itemId mening?

atomic ibex
#

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

limpid locust
#

yes yes ik that but i meant how itemId used there

#

sorry man

atomic ibex
#

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...

limpid locust
#

i dont know...

#

how do i use itemId of another class in this loop?

atomic ibex
#

No, the loop needs to be a normal loop iterating your startItems

limpid locust
#

wait this is not a normal loop?

atomic ibex
#

inside the loop block, you assign the value to the itemId

atomic ibex
#

How do we write a for loop?

limpid locust
#

like this sir

atomic ibex
#

to itemId of an item that we are currently iterating

limpid locust
atomic ibex
#

what is item here?

#

It's not an item that you iterate

limpid locust
atomic ibex
#

what does that have to do with what we're doing?

limpid locust
#

then how do i get itemId of Item class

atomic ibex
#

how do we iterate elements of an array?

#

in a for loop

limpid locust
atomic ibex
#

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.

atomic ibex
limpid locust
#

wrong? o no

#

i go google

atomic ibex
limpid locust
#

Array was jus representing any array

atomic ibex
limpid locust
#

i dont kow which array we need

atomic ibex
#

I've mentioned that at least several times.

#

And you even have it in the loop declaration

limpid locust
#

but i got error with that

atomic ibex
#

Obviously, because you need to do something with it

limpid locust
#

ohh sorry sorry i jumped to conclusion too fast

#

please continue to guide me sir

atomic ibex
#

assign the id of the iterated item

limpid locust
atomic ibex
#

no...

#

what is startItems[i]? What object is it?

limpid locust
#

all the items that are iterated one by one from the loop

atomic ibex
#

so it's an Item instance, right?

limpid locust
#

yes

atomic ibex
#

and what did I ask you to assign?

limpid locust
#

assign the id of item to this startItem?

#

i am wrong again arent i

#

uhhh

atomic ibex
limpid locust
#

assign to who tho

atomic ibex
#

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

limpid locust
#

assign what value to it tho?

atomic ibex
#
  1. I said that multiple times. the iterator
  2. You're not assigning the Id here.
limpid locust
atomic ibex
#

2

#

How do we assign an id of an item?

limpid locust
#

id of an item

#

assign to startitem

atomic ibex
#

you want to assign the iterator to an id of the item...

atomic ibex
#

Which is not gonna work

#

because Item != int

atomic ibex
#

Yes

limpid locust
atomic ibex
limpid locust
atomic ibex
#

How do we assign some value to the id of an item?

limpid locust
#

with =

atomic ibex
#

okay

#

but what should be on the left and right side..?

limpid locust
#

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

limpid locust
#

finally something correct

atomic ibex
#

so write it according to your reply

limpid locust
atomic ibex
#

Are you just trying random things..?😅

limpid locust
#

nooo

atomic ibex
#

what's supposed to be on the right side?

limpid locust
#

isnt id the startItem[i]?

atomic ibex
#

no

#

what's startItem[i]?

limpid locust
#

id was the iterator?

atomic ibex
#

id is not the iterator

#

but we want to assign the value of the iterator to the id

limpid locust
#

whaaa....

limpid locust
atomic ibex
#

Yes

limpid locust
#

when u say id, item.itemId comes to mind

atomic ibex
#

That's right

limpid locust
#

what....

atomic ibex
#

I'm asking again, what's startItem[i]?

limpid locust
#

items that are iterated

atomic ibex
#

... What's startItem[0] then?

limpid locust
#

the 1st item in the array

#

item in 0 index of the array

atomic ibex
#

Okay, good

#

We want to set the Ids of each item in the array

#

startItem[i] is not "items"

#

it's one item

limpid locust
#

yes

atomic ibex
#

Okay, then how do we set an id of one item?

limpid locust
#

set id of item as the item

atomic ibex
#

Nooo....

limpid locust
#

this must be right

#

fkkk

#

howwww

atomic ibex
#

Why are you keeping on changing the correct part?

#

the right side was correct

#

it needs to be i

limpid locust
#

whattt....

atomic ibex
#

yes, but instead of the item it needs to be the item that we are iterating in the loop

limpid locust
#

i had no idea we could do this, well now it makes sense tho

#

dont tell me m wrong again

atomic ibex
#

And that's why I refuse to help you until you do C# beginner course.

#

I'm sorry. But that's too much...

limpid locust
#

sorry for the trouble

atomic ibex
#

Anyways, with this you've got half of the job done.

limpid locust
#

umm thank you

atomic ibex
#

But please do your learning before continuing with the project. I'm saying it for your own good, trust me.

limpid locust
#

okayy

limpid locust
#

no last part?

atomic ibex
#

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.

limpid locust
#

i am not able to instantiate by using the id

#

itemId

atomic ibex
#

And you don't need to

#

You use the id to get the right prefab from the startItem array and instantiate it

limpid locust
#

i did store it but i dont know how to use that id to instantitate

#

uhhh

atomic ibex
#

If data.prefabs is the ids, then that part at least should work.

limpid locust
#

is it is itemIds that was stored in data

atomic ibex
#

Then yes. That should instantiate the correct prefab. Assuming there are no mistakes anywhere along the way.

limpid locust
#

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

atomic ibex
#

Do some learning, then you'll be able to solve the issues yourself or ask more appropriate questions.

limpid locust
#

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

atomic ibex
#

How much time do you have?

limpid locust
#

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

atomic ibex
#

Spend a day or 2 on learning C# basics and debugging and you still have 6 days to get it done.

limpid locust
#

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

atomic ibex
#

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.

limpid locust
#

if i cudve chosen i wudve chosen a differnt topic welp

atomic ibex
#

What was the topic?

limpid locust
#

i vudnt bring out ideas for web dev that were promising and this was the only one that thought was good enough so iiwii

atomic ibex
#

The error is pretty clear: you can't instantiate scriptable objects with position and rotation.

#

Anyways, I'm off to sleep.

limpid locust
#

oke