1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  1. Valkaaire

    Valkaaire Naked Wanderer

    Currently decompiling rust to look at how items are placed (like lanterns, etc.) As i need this concept as a part of a plug-in i wish to create.

    Was wondering if anyone has already discovered this? it'd mean a lot if someone was able to save me this time and let me know where to find it.
     
  2. CombatTag

    CombatTag Scavenger

    This is kind of a hacky way to do it, I'm sure there are better ways, but here is how I normally spawn deployables.

    Code (Text):
    Item item = ItemManager.CreateByName("wall.external.high.stone", 1);
    var deployable = item.info.GetComponent<ItemModDeployable>().entityPrefab.resourcePath;
    var entity = GameManager.server.CreateEntity(deployable, position, rotation, true);
    entity.Spawn();
     
    Valkaaire likes this.
  3. Valkaaire

    Valkaaire Naked Wanderer

    Thank you so much! I was just going through the files and really wasn't having a good time (I know i have all the files that contain the whole procedure but having to find the relevant code i need is time consuming going through loads of .cs files)

    From having read it it seems like it'd be good, i'll have a look.

    Thank you buddy!
     
  4. Shady757

    Shady757 Plugin Developer

    Unless you have a reason to keep the item, you don't need to create a new one. You can make that code a bit better by changing it from creating an item to simply finding the ItemDefinition:
    Code (C#):

                var def = ItemManager.FindItemDefinition("wall.external.high.stone");
                var deployable = def.GetComponent<ItemModDeployable>().entityPrefab.resourcePath;
                var entity = GameManager.server.CreateEntity(deployable, position, rotation, true);
                entity.Spawn();
     
     
  5. Valkaaire

    Valkaaire Naked Wanderer

    I'm planning on trying to deploy the item in the same way that items do in the game (With the blue gizmo) for the item i want to make placeable, i just needed a contingency solution incase i am unable.

    The items i want to spawn are permanent, but thank you for trying to help me out! :)