Makishim Posted January 26, 2019 Share Posted January 26, 2019 inst.components.talker:Say(inst.level) My server's crashing when my char try to talk. But only when my server have caves; when they're disabled I don't have any trouble. Link to comment Share on other sites More sharing options...
Ultroman Posted January 26, 2019 Share Posted January 26, 2019 That's probably because the character only has the level-variable on the server and not on the clients. If you just declare the variable above your ismastersim check, the error will go away, but on the clients it'll always show you saying the initial value, even after you have changed the value on the server. What you're looking at, is a problem that requires you to sync a networked variable between the client and server, so both have an up-to-date level-variable at all times. I'm not entirely sure how to do that, as I have never done that before. I'm sure you can find a thread on this forum, if you search for keywords like: sync network variable Link to comment Share on other sites More sharing options...
YakumoYukari Posted January 27, 2019 Share Posted January 27, 2019 Talker:Say() method's script argument must be a string otherwise, crash. So If inst.level is nil or number value, will cause the crash. Link to comment Share on other sites More sharing options...
Ultroman Posted January 27, 2019 Share Posted January 27, 2019 (edited) 1 hour ago, YakumoYukari said: Talker:Say() method's script argument must be a string otherwise, crash. So If inst.level is nil or number value, will cause the crash. I'm pretty sure LUA has automatic tostring() for numbers, so that won't cause a crash. Otherwise this wouldn't work print("foo"..inst.components.health.current) but it does. Unless I'm missing something, in which case please enlighten me Also, it works without caves. Edited January 27, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Developer bizziboi Posted January 27, 2019 Developer Share Posted January 27, 2019 4 hours ago, Ultroman said: Unless I'm missing something, in which case please enlighten me It only does that if it can deduce it needs to be converted to string (or coerced as it's called in the lingo). Since your example allows Lua to deduce it has to be a string (because the number is concatenated to string, so it reasons it must be converted to string). However, the following code will crash, it surpasses Lua's level of type coercion. function test(s) print(s:sub(1,1)) end test(3) The more you know (well, okay, it would be very hard for Lua to know this is expected to be a string, but just to show that string coercion doesn't always work) Link to comment Share on other sites More sharing options...
Ultroman Posted January 28, 2019 Share Posted January 28, 2019 14 hours ago, bizziboi said: It only does that if it can deduce it needs to be converted to string (or coerced as it's called in the lingo). The more you know 2 Indeed! Thanks for the correction. Link to comment Share on other sites More sharing options...
Makishim Posted January 28, 2019 Author Share Posted January 28, 2019 21 hours ago, YakumoYukari said: Talker:Say() method's script argument must be a string otherwise, crash. So If inst.level is nil or number value, will cause the crash. But my Talker:Say() is fine when is a normal server. He just crash when caves are enabled. Link to comment Share on other sites More sharing options...
Ultroman Posted January 28, 2019 Share Posted January 28, 2019 (edited) Maybe the Say function does some work for you, in regards to coercing the variable to be a string. I don't know. Your problem is definitely that your server-instance has the level-variable, and the client-instance does not. Look into netvars or syncing variables between server and client. Edited January 28, 2019 by Ultroman 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