4.99 breaks require "json"

Posted by Fiendish on Wed 28 Oct 2015 12:40 PM — 7 posts, 25,235 views.

USA Global Moderator #0
This seems important.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="TEST"
   author="Fiendish"
   id="111111111111111111111111"
   language="Lua"
   purpose="Load json"
   save_state="y"
   date_written="2015-10-28 14:16:26"
   requires="4.99"
   version="1.0"
>
<description trim="y">
Test description
</description>
</plugin>

<script>
<![CDATA[

require "json"

]]>
</script>
</muclient>



[WARNING] C:\Program Files (x86)\MUSHclient\worlds\plugins\test.xml
Line   20: Error parsing script (Cannot load)
Run-time error
Plugin: TEST (called from world: test)
Immediate execution
...m Files (x86)\MUSHclient\lua\json\decode\strings.lua:90: loop body may accept empty string
stack traceback:
        [C]: ?
        ...m Files (x86)\MUSHclient\lua\json\decode\strings.lua:90: in function 'buildCaptureString'
        ...m Files (x86)\MUSHclient\lua\json\decode\strings.lua:111: in function 'buildCapture'
        ...m Files (x86)\MUSHclient\lua\json\decode\strings.lua:126: in function 'load_types'
        ...:\Program Files (x86)\MUSHclient\lua\json\decode.lua:84: in function 'buildDecoder'
        ...:\Program Files (x86)\MUSHclient\lua\json\decode.lua:97: in main chunk
        [C]: in function 'require'
        C:\Program Files (x86)\MUSHclient\lua\json.lua:5: in main chunk
        [C]: in function 'require'
        [string "Plugin"]:1: in main chunk
[WARNING] C:\Program Files (x86)\MUSHclient\worlds\plugins\test.xml
Line   20: Error parsing script (Cannot load)
Amended on Wed 28 Oct 2015 01:13 PM by Fiendish
Australia Forum Administrator #1
You didn't need a plugin to prove that. Doing the "require" in an Immediate window triggers it.

It looks like the improvements to LPEG are not compatible with the shipped JSON (luajson).

As a workaround, go to:

https://github.com/harningt/luajson/tree/master

Click the "Download ZIP" button. Unzip and move the files from the "lua" folder into the MUSHclient "lua" directory, overwriting the existing files. In particular you should be replacing these files:


json.lua

Folder: json
  json/encode.lua
  json/util.lua
  json/decode.lua

  Folder: json/decode
    json/decode/composite.lua
    json/decode/number.lua
    json/decode/others.lua
    json/decode/state.lua
    json/decode/strings.lua
    json/decode/util.lua

  Folder: json/encode
    json/encode/array.lua
    json/encode/calls.lua

  Folder: json/encode/number.lua
    json/encode/object.lua
    json/encode/others.lua
    json/encode/output.lua
    json/encode/output_utility.lua
    json/encode/strings.lua


Note that these files are additions, not replacements:


    json/decode/composite.lua
    json/decode/state.lua


A quick test appears to indicate that JSON works now. Please advise if you have issues with it.
USA Global Moderator #2
Seems to work.
Question: Did the editor always launch on plugin failure to load? It's a bit disruptive, and I don't remember it always happening.
Australia Forum Administrator #3
For quite a while.

http://www.gammon.com.au/scripts/showrelnote.php?version=3.78&productid=0

See point 7.

Quote:

Released on 09 Aug 2006

...


7. In the plugins dialog, if a plugin raises an error when you try to install it (eg. syntax error in a script) then the plugin is automatically opened in the inbuilt notepad, or your designated text editor. This is designed to assist plugin authors fix problems in their plugins.

USA Global Moderator #4
Huh. I wonder why it feels new. Anyway, the new json seems to work. Probably warrants a 4.100
Australia Forum Administrator #5
I was going up in 100ths, so I thought the next one would be 5.00. Calling it 4.100 might be confused with 4.10.
USA Global Moderator #6
I guess.

Maybe it's time to adopt semantic versioning with the new 5.0.0? :)
http://semver.org/