Kisica Posted October 23, 2019 Share Posted October 23, 2019 I wonder is there a code for console to remove some items lying on the ground through the world? Like twigs, poops, etc. In order to reduce lags in old worlds Link to comment Share on other sites More sharing options...
Sweaper Posted October 23, 2019 Share Posted October 23, 2019 c_cleanup = function(prefab) for k, v in pairs(Ents) do if v.prefab == prefab and v.components.inventoryitem and v.components.inventoryitem.owner == nil then v:Remove() end end end Then choose what prefab to remove, e.g.: c_cleanup"flint" Link to comment Share on other sites More sharing options...
Fuffles Posted October 23, 2019 Share Posted October 23, 2019 c_removeall(prefab) Link to comment Share on other sites More sharing options...
Kisica Posted October 23, 2019 Author Share Posted October 23, 2019 59 minutes ago, Sweaper said: c_cleanup = function(prefab) for k, v in pairs(Ents) do if v.prefab == prefab and v.components.inventoryitem and v.components.inventoryitem.owner == nil then v:Remove() end end end Then choose what prefab to remove, e.g.: c_cleanup"flint" It works only near the character, but I need to delete ALL twigs lying on the ground in my world 53 minutes ago, FuffledBeeQueen said: c_removeall(prefab) I guess this code removes all items (even in the chests). But I only need to delete those are on the ground Link to comment Share on other sites More sharing options...
Fuffles Posted October 23, 2019 Share Posted October 23, 2019 19 minutes ago, Kisica said: I guess this code removes all items (even in the chests). But I only need to delete those are on the ground Paste this into the console Quote function c_clearall(name) for k,ent in pairs(Ents) do if ent.prefab == name and ent.components.inventoryitem ~= nil and ent.components.inventoryitem.owner == nil then ent:Remove(); end end end use c_clearall("twigs"), this is literally a copy of the original removeall with a few extra arguments to prevent items in inventories from vanishing Link to comment Share on other sites More sharing options...
Electroely Posted October 23, 2019 Share Posted October 23, 2019 24 minutes ago, Kisica said: It works only near the character, but I need to delete ALL twigs lying on the ground in my world That command should work fine. Are you sure you are executing the command remotely? Make sure it says "Remote" rather than "Local" before executing the command. Press CTRL before hitting enter to change between "Remote" and "Local" 5 minutes ago, FuffledBeeQueen said: Paste this into the console use c_clearall("twigs"), this is literally a copy of the original removeall with a few extra arguments to prevent items in inventories from vanishing That's the same command Sweaper posted... Link to comment Share on other sites More sharing options...
Kisica Posted October 23, 2019 Author Share Posted October 23, 2019 2 minutes ago, Electroely said: That command should work fine. Are you sure you are executing the command remotely? Make sure it says "Remote" rather than "Local" before executing the command. Press CTRL before hitting enter to change between "Remote" and "Local" That's the same command Sweaper posted... Yes, ofc Link to comment Share on other sites More sharing options...
Fuffles Posted October 23, 2019 Share Posted October 23, 2019 44 minutes ago, Electroely said: That's the same command Sweaper posted... Pardon? They said it apparently didn't work so I went into the code and tailored around c_removeall Link to comment Share on other sites More sharing options...
Electroely Posted October 23, 2019 Share Posted October 23, 2019 34 minutes ago, FuffledBeeQueen said: Pardon? They said it apparently didn't work so I went into the code and tailored around c_removeall The command you've made is identical to Sweaper's, though, minus a few differently named variables. I don't see how yours will work if Sweaper's didn't. 1 hour ago, Kisica said: Yes, ofc It should have worked, then... If it only removed items near your character, that means that it was only done locally. You should make sure both commands were done in Remote mode. It wouldn't hurt to try them again. Link to comment Share on other sites More sharing options...
Kisica Posted October 24, 2019 Author Share Posted October 24, 2019 20 hours ago, Electroely said: It should have worked, then... If it only removed items near your character, that means that it was only done locally. You should make sure both commands were done in Remote mode. It wouldn't hurt to try them again. I paste this code: c_cleanup = function(prefab) for k, v in pairs(Ents) do if v.prefab == prefab and v.components.inventoryitem and v.components.inventoryitem.owner == nil then v:Remove() end end end And then this: c_cleanup"twigs"Both in Remote mode It doesn't work. Only twigs around the character were removed Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.