As Mentioned i need a way to loop through all items that use the BoxStorage Class. so far i have managed to find:
but sadly the ItemModDeploable doesnt seem to have a reference to the original object. any pointers to where i need to look would be greatly apprechiated.Code:foreach (var item in ItemManager.GetItemDefinitions()) { var itemdeployable = item?.GetComponent<ItemModDeployable>(); if (itemdeployable == null) continue; if (item.category.ToString() != "Items" && !item.spawnAsBlueprint) continue; Puts(item.displayName.english + "\n" + item.shortname); }
[DOUBLEPOST=1525775690][/DOUBLEPOST]and before anyone sais it i have been browsing the Assembly-CSharp dll for the last 2 hours without progreess
Looping through all BoxStorage items?
Discussion in 'Rust Development' started by CEbbinghaus, May 8, 2018.
-
var containers = UnityEngine.Object.FindObjectsOfType<StorageContainer>();
foreach (StorageContainer container in containers)
{
} -
not what i was looking for. i want all the base items. not every instance of the class. i want to dynamically create a json file with every BoxStorage container item. so i want to loop every Box storage container and end up with this:
Small Wood Box
Large Box
Fridge
not:
Small Wood Box
Small Wood Box
Small Wood Box
Small Wood Box
Small Wood Box
Small Wood Box
Fridge
Fridge
Fridge
Fridge
Fridge
Fridge
Large Box
Large Box
Large Box
Large Box -
So you want all the prefabs that have container function? or are you looking for it in the world? An example of what you would use it for might help explain what your looking for
-
-
So I think I understand better now, so you want to blacklist an entity from spawning/crafting/using something? if that's the case than just dumping all assets, and setting up functions to make it uncraftable/unusable/unspawnable. is this more of what your trying to go for? if that is the case than I think it would be far easier to just to list out the assets, and not worry about every entity group than just use wild cards to find what you wants and filter it from there, than use maybe use a foreach try loop to verify that it has the functions that you want in the group on startup?
-
i have a plugin that teleports players between objects and i want admins to be able to disable any object they want to. this is to prevent players beeing able to use vending machines as teleports or some other thing that an admin might not want -
Then just create a list like
List<string> uniqueStorageContainerTypes
and my function above:
var containers = UnityEngine.Object.FindObjectsOfType<StorageContainer>();
foreach (StorageContainer container in containers)
{
if(!uniqueStorageContainerTypes.Contains(container.ShortPrefabName))
{
uniqueStorageContainerTypes.Add(container.ShortPrefabName);
}
}
at the end you get uniqueStorageContainerTypes with all available types of StorageContainer and work with them -