Jump to content

"stale" items?


Recommended Posts

Does anyone knows why this happens?

weird_items

Basically, I'm trying to store chester's inventory in a custom component, so that he doesn't drops it on death and can travel to caves. Everything works so far except that whenever chester loads the items in its inventory they look like that. You can't Shift click them and they all look spoiled until you pick them and put them back in the inventory, then they behave as normal.

Weird thing is, this doesn't happens when the player is at or near the coordinate 0,0,0, nor does it happens when you host a server without caves.

 

EDIT: Fixed it by adding a 0.1 sec delay before loading items into chester, maybe items needed a tiny bit of time to update.

Edited by Ryuushu
Link to comment
Share on other sites

I guess this would be a main game "bug"?

1) pick chester and teleport to pigking 2) put seeds in chester 3) teleport to multiplayer_portal

4) notice seeds have empty background 5) teleport back to pigking 6) seeds are now green

When teleporting the inventoryitem_classifieds get dunked on the spot and thus you can't access the perish info when the items are asleep a thousand miles away.

AddPrefabPostInit("inventoryitem_classified", function(inst)
    if GLOBAL.TheWorld.ismastersim then
        inst.entity:SetCanSleep(false)
    end
end)

This could run server side and "fixes it". However, this all happens because c_gonext. You should probably (definitely) implement a different c_gonext (that teleports all your followers and the followers of your inventory items, like Teleporter.Activate) instead of forcing all the classifieds to not sleep.

You can use wormholes and this won't happen. Why, exactly? Well, because the wormhole teleports YOU and CHESTER at the same time, in the same frame. And for some reason, this is important. If I teleport myself and then let the game teleport Chester, items will lose the freshness. If I teleport myself and Chester and the same time, items won't lose it.

What was the problem again? Putting Chester on a cave? GetSaveRecord() didn't make the cut?

Link to comment
Share on other sites

@DarkXero

Original problem was items going "stale". First was because of loading/saving (I was doing some weird stuff), then because of moving away instantly.

I don't actually save chester, but rather the items it's carrying (storing them inside a special container), then I just save and load the items into chester when needed; putting it inside a cave was no problem.

I'm unsure if not letting the items sleep can cause performance issues, and overriding c_gonext  in a chester mod feels kind of wrong...

What I did to "refresh" the items was to give chester's items to chester when it opens, like so:

for k,v in pairs(chester.container.slots) do
	chester.components.container:MoveItemFromAllOfSlot(k, chester)
end

This triggers the refresh and so far it works, but I've been looking for a better way to get the items to refresh.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...