1715 posts
Location
ACDC Town
Posted 20 March 2017 - 02:50 AM
I've added color formatting into the latest BETA version of Enchat, but for some reason, entering some commands crashes Enchat! I've been looking all over the code, and I cannot find the cause.
I've even tried looking at debugging programs, but they've been of little help.
I know that "/nick dude" will crash it, even going so far as to yield a "Errror resuming bios.lua" error!! But, it was on KrakenCraft. On CCEmuRedux, it didn't crash.
Help!!
Pastebin link to relevant code:
http://pastebin.com/4a6NZaMZ
218 posts
Location
tmpim
Posted 20 March 2017 - 03:19 AM
Probably not relavent, but I did notice that `explode` is defined twice, once on line 102 and once on line 221. Also the fact that some functions are local and others aren't other just bothers me. A bunch of functions aren't even being used, although that may just be a side-effect of in-dev process. Also, when you do string gsubs, if you're splicing out whitespace use the %s pattern instead of " ". Not sure about the crashing though, will look into it further. Also if you have any more descriptive error messages they would be much appreciated.
1715 posts
Location
ACDC Town
Posted 20 March 2017 - 03:40 AM
Probably not relavent, but I did notice that `explode` is defined twice, once on line 102 and once on line 221. Also the fact that some functions are local and others aren't other just bothers me. A bunch of functions aren't even being used, although that may just be a side-effect of in-dev process. Also, when you do string gsubs, if you're splicing out whitespace use the %s pattern instead of " ". Not sure about the crashing though, will look into it further. Also if you have any more descriptive error messages they would be much appreciated.
Thanks. I'll get rid of any unused functions after I'm done making it, and same goes for localizing everything. Also, I guess I will use %s from now on.
Once I get some more time (it's 11:42 PM on a school night…!), I'll look into adding more comments and describing my problems a bit more.
218 posts
Location
tmpim
Posted 20 March 2017 - 03:46 AM
Found your (an) issue, it was the %s thing i was talking about, change line 571 to
local comm = explode("%s",tostring(msg):sub(2))
And then it works! :ack:
Edit: 200 posts, woo
Edit 2: Jk, it doesn't crash but it doesn't work, either way its the explode function causing the hang
Final Edit: OK, I've got it to work now, you've gotta remove the `true` from your lambda function in `explode` to get rid of the crashing as well as the change mentioned previously, also in the `nick` function, your if statement is wrong.
if not argument == yourName then
if #argument:gsub(" ","") > 0 then
-- The first once evaluates as (not argument) == yourName so change it to
if argument ~= yourName then
-- And the second needs the %s so
if #argument:gsub("%s","") > 0 then
Edited on 20 March 2017 - 03:14 AM
1715 posts
Location
ACDC Town
Posted 20 March 2017 - 11:10 AM
Found your (an) issue, it was the %s thing i was talking about, change line 571 to
local comm = explode("%s",tostring(msg):sub(2))
And then it works! :ack:
Edit: 200 posts, woo
Edit 2: Jk, it doesn't crash but it doesn't work, either way its the explode function causing the hang
Final Edit: OK, I've got it to work now, you've gotta remove the `true` from your lambda function in `explode` to get rid of the crashing as well as the change mentioned previously, also in the `nick` function, your if statement is wrong.
if not argument == yourName then
if #argument:gsub(" ","") > 0 then
-- The first once evaluates as (not argument) == yourName so change it to
if argument ~= yourName then
-- And the second needs the %s so
if #argument:gsub("%s","") > 0 then
Thank you so much! The advice worked. And I found out why /cry locks the keyboard. '_getTears()' was locally defined after handleCommand()! What silliness!
Although, I must ask. What's the advantage of "%s" over simply " "?
1426 posts
Location
Does anyone put something serious here?
Posted 20 March 2017 - 07:00 PM
Although, I must ask. What's the advantage of "%s" over simply " "?
%s simply matches all whitespace characters: so newlines, tabs, spaces and a couple others.
Worth noting that it may not always be ideal as some "whitespace" characters such as
"\11" and
"\12" have fancy graphics, but in this case it doesn't really matter.