.mcl too large...?

Posted by Meredin on Wed 10 May 2006 06:34 PM — 2 posts, 11,335 views.

#0
So I was attempting to make a dynamic stack by using a few triggers and scripts, using a trigger to add to a variable and another to remove from the same variable. Well apparently I forgot to enable the remove trigger, so my variable become rather large. I didn't notice this, and when I clicked save, it locked up my whole computer. Now, when I attempt to open the world, I get this error:

Line 1: XML file "D:\RoD\Brew\Brew-Xardas.MCL"too large - maximum permitted is 1024000 bytes (problem in this file)

I noticed that all the other worlds are around 12-20kb in size, but this one is over 1.3Mb, so I can only imagine what happened. The easy fix is just to recreate the world, but unfortunately he has around 30 triggers, none of which I've ever saved, and I was wondering if there was a way to clear the variables without opening the world, or any other way to get around this? Thanks!
Australia Forum Administrator #1
Hopefully the file is simply too large, and not actually corrupted. In that case, simply use a text editor that can handle large files, open the .mcl file, and scroll down until you see the line "<variables" and delete it and everything until the line "</variables>". Save under a different name, just in case, and try the new one.

If you don't have such an editor, this small Lua script will do that for the file you specify in the first couple of lines.


oldworld = assert (io.open ("C:\\Smaug.mcl", "r"))  -- open old file for reading
newworld = assert (io.open ("C:\\Smaug_fixed.mcl", "w")) -- open new file for writing
have_vars = false
for line in oldworld:lines () do
  if line == "<variables" then
    have_vars = true
  elseif line == "</variables>" then
    have_vars = false
  else
    if not have_vars then
      newworld:write (line .. "\r\n")
    end -- not inside <variable ... </variables>
  end -- if
end -- for
oldworld:close ()
newworld:close ()
print "done!"



This script reads the entire world line-by-line and drops the stuff between "<variables" and "</variables>".

To make the script work you may have to edit the Lua Sandbox preferences (global preferences) and comment out the line:


io = nil -- no disk IO


by making it:


-- io = nil -- no disk IO


You can run this script in the Immediate scripting window, once you have made Lua your script language in scripting preferences.

If the file is corrupted, that is it stopped saving before reaching the end, edit it in a word processor and rescue the stuff you want (like your triggers), make a new world, and do File -> Import to paste the triggers from the clipboard into your new world.