Jump to content




Enchat 2.1 - It keeps crashing, and I don't know why!


  • You cannot reply to this topic
5 replies to this topic

#1 LDDestroier

  • Members
  • 1,095 posts
  • LocationACDC 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

#2 Emma

  • Members
  • 216 posts
  • Locationtmpim

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.

#3 LDDestroier

  • Members
  • 1,095 posts
  • LocationACDC Town

Posted 20 March 2017 - 03:40 AM

View PostIncinirate, on 20 March 2017 - 03:19 AM, said:

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.

#4 Emma

  • Members
  • 216 posts
  • Locationtmpim

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 by Incinirate, 20 March 2017 - 04:14 AM.


#5 LDDestroier

  • Members
  • 1,095 posts
  • LocationACDC Town

Posted 20 March 2017 - 11:10 AM

View PostIncinirate, on 20 March 2017 - 03:46 AM, said:

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 " "?

#6 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 20 March 2017 - 07:00 PM

View PostEldidiStroyrr, on 20 March 2017 - 11:10 AM, said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users