Bunnyash Posted October 10, 2018 Author Share Posted October 10, 2018 15 minutes ago, Ultroman said: You're missing an "end" at the end. If you fixed the indentation it'd be staring you right in the face. I'm still getting a crash, though I'm not sure I'm getting it <X( Link to comment Share on other sites More sharing options...
Ultroman Posted October 10, 2018 Share Posted October 10, 2018 I forgot to make it GLOBAL.SpawnPrefab again. Just add GLOBAL. before all the SpawnPrefab calls. Please fix the indentation anyway. It's seriously confusing, and it hurts my heart knowing that code with this indentation exists Link to comment Share on other sites More sharing options...
Bunnyash Posted October 10, 2018 Author Share Posted October 10, 2018 26 minutes ago, Ultroman said: I forgot to make it GLOBAL.SpawnPrefab again. Just add GLOBAL. before all the SpawnPrefab calls. Please fix the indentation anyway. It's seriously confusing, and it hurts my heart knowing that code with this indentation exists It works great! Thank you so much!! I honestly appreciate your time spent helping me do this code even though I'm a bit dumb sometimes (Must've been a lil infuriating I'm sorry o_o) You've been one of the best people about it, so thank you for that too! Can I just ask one more thing? This only applies to rock1, what would I need to do to make it imply with rock2 and rock_flintless? Link to comment Share on other sites More sharing options...
Ultroman Posted October 10, 2018 Share Posted October 10, 2018 (edited) You're welcome And I appreciate your appreciation. Duplicate the AddPrefabPostInit line, and change "rock1" to the names of the other rock prefabs you want to affect.Their names are: "rock1" "rock2" "rock_flintless" "rock_flintless_med" "rock_flintless_low" "rock_moon" "rock_petrified_tree" "rock_petrified_tree_med" "rock_petrified_tree_tall" "rock_petrified_tree_short" "rock_petrified_tree_old" "rock_ice" Edited October 10, 2018 by Ultroman Link to comment Share on other sites More sharing options...
Bunnyash Posted October 10, 2018 Author Share Posted October 10, 2018 4 minutes ago, Ultroman said: Duplicate the AddPrefabPostInit line, and change "rock1" to the names of the other rock prefabs you want to affect.Their names are: "rock1" "rock2" "rock_flintless" "rock_flintless_med" "rock_flintless_low" "rock_moon" "rock_petrified_tree" "rock_petrified_tree_med" "rock_petrified_tree_tall" "rock_petrified_tree_short" "rock_petrified_tree_old" "rock_ice" I thought so, thought I'd check just to be sure! Works great Really though, thanks again, you have been super helpful! Link to comment Share on other sites More sharing options...
Ultroman Posted October 10, 2018 Share Posted October 10, 2018 You're welcome Link to comment Share on other sites More sharing options...
Lumina Posted October 10, 2018 Share Posted October 10, 2018 Also, you could want to add the different stalagmites too. Link to comment Share on other sites More sharing options...
Bunnyash Posted October 12, 2018 Author Share Posted October 12, 2018 On 10/10/2018 at 11:19 AM, Lumina said: Also, you could want to add the different stalagmites too. I was thinking that, but they already drop gems very rarely. So there's much stalagmites too! Link to comment Share on other sites More sharing options...
Bunnyash Posted October 12, 2018 Author Share Posted October 12, 2018 On 10/10/2018 at 4:52 AM, Ultroman said: You're welcome I've having troubles again with part of this code when I enable caves Link to comment Share on other sites More sharing options...
Lumina Posted October 12, 2018 Share Posted October 12, 2018 Maybe you need a check somewhere to ensure that the code is only done server side and not client side ? Link to comment Share on other sites More sharing options...
IronHunter Posted October 12, 2018 Share Posted October 12, 2018 What lumina said is pretty much correct, unless a component is a replicable one. They are server side only. You need to add a if statement to check if theworld is mastersim. I can't grab any code atm. Away from pc. Link to comment Share on other sites More sharing options...
Bunnyash Posted October 13, 2018 Author Share Posted October 13, 2018 2 hours ago, IronHunter said: What lumina said is pretty much correct, unless a component is a replicable one. They are server side only. You need to add a if statement to check if theworld is mastersim. I can't grab any code atm. Away from pc. 3 hours ago, Lumina said: Maybe you need a check somewhere to ensure that the code is only done server side and not client side ? Ah? I'm not sure how to do that tbh >_< an example code will help alot, thank you! Link to comment Share on other sites More sharing options...
IronHunter Posted October 13, 2018 Share Posted October 13, 2018 There are quite a few examples when I searched. Including a relatively recent one: Just look at the Global.TheWorld.ismastersim That checks to make sure the code is run only on the server. Link to comment Share on other sites More sharing options...
Bunnyash Posted October 13, 2018 Author Share Posted October 13, 2018 14 hours ago, IronHunter said: There are quite a few examples when I searched. Including a relatively recent one: Just look at the Global.TheWorld.ismastersim That checks to make sure the code is run only on the server. Is this right? (I can't currently test it rn >_< away from pc) Link to comment Share on other sites More sharing options...
Lumina Posted October 13, 2018 Share Posted October 13, 2018 It seems right. I can miss something, but the logic seems to be here. Link to comment Share on other sites More sharing options...
Bunnyash Posted October 13, 2018 Author Share Posted October 13, 2018 1 hour ago, Lumina said: It seems right. I can miss something, but the logic seems to be here. No, this code doesn't work Link to comment Share on other sites More sharing options...
Ultroman Posted October 13, 2018 Share Posted October 13, 2018 As always, it's hard to help without the server logs of the crash and the full mod code. Link to comment Share on other sites More sharing options...
IronHunter Posted October 13, 2018 Share Posted October 13, 2018 (edited) That code doesn't make sense: AddPrefabPostInit("gemini", function(inst) if GLOBAL.TheWorld.ismastersim then cached_onwork = inst.components.workable.onwork inst.components.workable:SetOnWorkCallback(MyOnWork) end end) --all you really needed to do was wrap your postinit function with the if statement if GLOBAL.TheWorld.ismastersim if statements don't use equals = they use absolute equals == or other relational operators like >= <= ~= etc. = on its own means assigning/changing the variable pointer to a new point. if you want to make sure inst.components.workable.onwork ~= nil then you can do that still. In your MyOnWork function, take note the component workable already checks to make sure .onwork is assigned data. Also onwork is probably activating when you hit the rock, which is what ice does. But if you wanted it to drop when destroying it, the onfinished might make more sense. Edited October 13, 2018 by IronHunter Posted too early, when trying to type my post. Link to comment Share on other sites More sharing options...
Bunnyash Posted October 13, 2018 Author Share Posted October 13, 2018 2 hours ago, Ultroman said: As always, it's hard to help without the server logs of the crash and the full mod code. It doesn't crash, or pop up any errors it just disconnects me when I pick the character. 19 minutes ago, IronHunter said: That code doesn't make sense: AddPrefabPostInit("gemini", function(inst) if GLOBAL.TheWorld.ismastersim then inst.cached_onwork = inst.components.workable.onwork inst.components.workable:SetOnWorkCallback(MyOnWork) end end) if statements don't use equals = they use absolute equals == or other relational operators like >= <= ~= etc. = on its own means assigning/changing the variable pointer to a new point. if you want to make sure inst.components.workable.onwork ~= nil then you can do that still. In your MyOnWork function, take note the component workable already checks to make sure .onwork is assigned data. Also onwork is probably activating when you hit the rock, which is what ice does. But if you wanted it to drop when destroying it, the onfinished might make more sense. I put this code in and It only disconnected me when I select the character (this only happens when I enabled caves, when I host without caves, I get an error message) Gems drop during the mining process randomly, they don't drop after the rock has been destroyed. Link to comment Share on other sites More sharing options...
Ultroman Posted October 13, 2018 Share Posted October 13, 2018 What is "Gemini" and are you sure that it has a workable-component? Because this error says it doesn't. Link to comment Share on other sites More sharing options...
Bunnyash Posted October 13, 2018 Author Share Posted October 13, 2018 2 minutes ago, Ultroman said: What is "Gemini" and are you sure that it has a workable-component? Because this error says it doesn't. That's the Character mod's name Link to comment Share on other sites More sharing options...
Ultroman Posted October 13, 2018 Share Posted October 13, 2018 (edited) Characters don't have a workable component. You shouldn't do this to the player character. This code is for rocks, trees and other things with a workable-component. Also, if you want to make changes to your player character, you should use AddPlayerPostInit() instead. What are you trying to do to the player? Edited October 13, 2018 by Ultroman Link to comment Share on other sites More sharing options...
Bunnyash Posted October 13, 2018 Author Share Posted October 13, 2018 1 minute ago, Ultroman said: Characters don't have a workable component. You shouldn't do this to the player character. This code is for rocks, trees and things with a workable-component. Do you mean I have placed it in the wrong place? I'm honestly confused at this point Link to comment Share on other sites More sharing options...
Ultroman Posted October 13, 2018 Share Posted October 13, 2018 The initial code I wrote was for changing the rocks. AddPrefabPostInit("rock1", MyPostInit) Rocks have a "workable" component, which is why the code works on them. Why would you try to do the same to your player character? He's not a rock. Link to comment Share on other sites More sharing options...
Bunnyash Posted October 13, 2018 Author Share Posted October 13, 2018 3 minutes ago, Ultroman said: The initial code I wrote was for changing the rocks. AddPrefabPostInit("rock1", MyPostInit) Rocks have a "workable" component, which is why the code works on them. Why would you try to do the same to your player character? He's not a rock. I think I must've confused myself somewhere, or misread something -_- I'm sorry, I didn't expect it to be so hard... 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