Luis95R Posted September 20, 2016 Share Posted September 20, 2016 Hi, I was curious if there is a difference in putting "inst.entity:SetPristine()" either before or after "TheWorld.ismastersim"? Some mods have SetPristine() before TheWorld.ismastersim and some do SetPristine() after. Also what is the difference between "local function fn(Sim)" and "local function()". Does putting Sim in between () make a difference too? Some examples of what I mean are down below. Thank you for reading. inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end or if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() Also local function fn(Sim) and local function fn() Link to comment https://forums.kleientertainment.com/forums/topic/70281-question-about-setpristine-and-fnsim/ Share on other sites More sharing options...
CarlZalph Posted September 20, 2016 Share Posted September 20, 2016 "inst.entity:SetPristine()" should be before "if not TheWorld.ismastersim then return inst end" This tells the client and server that whatever follows should not affect the client's state in any way and that only components should really exist beyond the point. It's an optimization for networking, I believe. The text between the parenthesis is called an argument. So you can call "fn" with the argument of anything, and in the scope of the function "Sim" will be the variable passed. "local function()" cannot exist as it does not define the function name which is a requirement in LUA. Link to comment https://forums.kleientertainment.com/forums/topic/70281-question-about-setpristine-and-fnsim/#findComment-815941 Share on other sites More sharing options...
Luis95R Posted September 22, 2016 Author Share Posted September 22, 2016 On 9/20/2016 at 3:49 AM, CarlZalph said: "inst.entity:SetPristine()" should be before "if not TheWorld.ismastersim then return inst end" This tells the client and server that whatever follows should not affect the client's state in any way and that only components should really exist beyond the point. It's an optimization for networking, I believe. The text between the parenthesis is called an argument. So you can call "fn" with the argument of anything, and in the scope of the function "Sim" will be the variable passed. "local function()" cannot exist as it does not define the function name which is a requirement in LUA. Thank you for explaining. Also I just recently viewed the thread "Getting started with modding DST..." by Rezecib and I noticed he mentioned this: inst.entity:SetPristine() "This basically says "everything above this was done on both the client on the server, so don't bother networking any of that". This reduces a bit of the bandwidth used by creating entities. I can't think of a case where you wouldn't want this immediately after the "if not TheWorld.ismastersim then return inst end" part, which is where you'll see it in the game's code." I'm now confused again where SetPristine() goes before or after. Is he wrong? Link to comment https://forums.kleientertainment.com/forums/topic/70281-question-about-setpristine-and-fnsim/#findComment-816645 Share on other sites More sharing options...
CarlZalph Posted September 22, 2016 Share Posted September 22, 2016 9 hours ago, Luis95R said: I'm now confused again where SetPristine() goes before or after. Is he wrong? It should always go before the ismastersim return check so that it runs for both the client and server. Check out any prefab provided by Klei and it is done this way. inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end Link to comment https://forums.kleientertainment.com/forums/topic/70281-question-about-setpristine-and-fnsim/#findComment-816731 Share on other sites More sharing options...
Luis95R Posted September 23, 2016 Author Share Posted September 23, 2016 Thank you, I checked and you are correct. Link to comment https://forums.kleientertainment.com/forums/topic/70281-question-about-setpristine-and-fnsim/#findComment-817065 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