Yakuzashi Posted October 22, 2020 Share Posted October 22, 2020 Hi. I have got something like this and I am wondering how to spawn prefabs in amounts larger than 1. My line looks like this: SpawnPrefab("...").Transform:SetPosition(...) Thanks in advance. Link to comment Share on other sites More sharing options...
Maxposting Posted October 22, 2020 Share Posted October 22, 2020 (edited) c_spawn("lecodename",amount).Transform:SetPosition(...) Edited October 22, 2020 by __IvoCZE__ 1 Link to comment Share on other sites More sharing options...
Yakuzashi Posted October 22, 2020 Author Share Posted October 22, 2020 @__IvoCZE__ Thanks. I thought "c_spawn" is used only through the in-game console. Link to comment Share on other sites More sharing options...
Thomas Die Posted October 22, 2020 Share Posted October 22, 2020 wait you can use it like that? does it work? Link to comment Share on other sites More sharing options...
Yakuzashi Posted October 22, 2020 Author Share Posted October 22, 2020 Yep. I am surprised Link to comment Share on other sites More sharing options...
Hornete Posted October 22, 2020 Share Posted October 22, 2020 7 hours ago, Yakuzashi said: Yep. I am surprised That line Ivo posted will only make the first entity spawned set its position, all other entities will go to 0, 0 Something like this would be better for i = 1, count do --replace count with number of entities you want SpawnPrefab("").Transform:SetPosition(...) end 1 1 1 Link to comment Share on other sites More sharing options...
Yakuzashi Posted October 23, 2020 Author Share Posted October 23, 2020 (edited) I am trying to replace logs with living logs upon spell cast, but my Frankenstein function turns every log in area into just 1 living log. local function detransformer(inst) local owner = inst.components.inventoryitem.owner local livinglog = SpawnPrefab("livinglog") local pt = inst:GetPosition() local range = 10 local ents = TheSim:FindEntities(pt.x,pt.y,pt.z,range) for _,ent in ipairs(ents) do if ent.prefab == "log" and ent.components.stackable and ent.components.stackable.stacksize == 20 and not owner.components.inventory:Has("log", 1) then local x,y,z = ent.Transform:GetWorldPosition() for i = 1, 20 do livinglog.Transform:SetPosition(x, y, z) end ent:Remove() end end end The: Quote for i = 1, count do --replace count with number of entities you want SpawnPrefab("").Transform:SetPosition(...) end part doesn't work and I don't know what I did wrong. Sorry for my lack of knowledge Edit: c_spawn() works good, but it spawns prefabs at the mouse pointer location Edit2: I am an idiot I shouldn't use local livinglog = SpawnPrefab("livinglog") Edited October 23, 2020 by Yakuzashi edit Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now