tipforeveryone Posted January 12, 2019 Share Posted January 12, 2019 My goal is place some boxes at the position of some pre-placed pivots I have 3 pivots (pivot1, pivot2, pivot3) Scripts 1: which is attached to pivot1 and 2 function Script:Start() table.insert(global_table,self.entity) end (global_table was declared in main.lua, before the while loop) Script 2: which is attached to pivot3 function Script:Start() for key,value in ipairs(global_table) do local box = Model:Box() box:SetPosition(value:GetPosition(true)) end end Script 2 does not work, because there is nothing inside the global_table to execute, all Script:Start() function are started at the same time. How can I force the Start() function of script2 (attached to pivot3) to be executed after all others execution? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted January 12, 2019 Share Posted January 12, 2019 5 hours ago, tipforeveryone said: Script 2 does not work, because there is nothing inside the global_table to execute, all Script:Start() function are started at the same time. How can I force the Start() function of script2 (attached to pivot3) to be executed after all others execution? There is no build in way to force the pivot3 scripts from being exucted first. What you can do is wait a couple of frames before calling the for loop in your pivot 3 script. 1 Quote Link to comment Share on other sites More sharing options...
GorzenDev Posted January 12, 2019 Share Posted January 12, 2019 you could create your own pre-post processor function in your main.lua, and have that execute when you want. 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted January 12, 2019 Share Posted January 12, 2019 "My goal is place some boxes at the position of some pre-placed pivots" You stated a goal but I wonder if this is the entire goal really? Why do you want to great a global variable to store these in? To reach your goal just make a Box script and attach it to the pivots and inside it's Start() it makes a box at self.entity position. That would reach your goal. Quote Link to comment Share on other sites More sharing options...
tipforeveryone Posted January 13, 2019 Author Share Posted January 13, 2019 Yeah it is not actually my goal, I want to place my character spawn position by using pivots. I place pivots in editor and when I run the game, my characters will be placed with pivots's position. Anyway, I found the solution, I put Script2 into UpdateWorld(), not in Start(), with a variable which can help execute character create code only one time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.