New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
textutils.serializeJSON keys are in qoutes #39
Comments
|
Side Note: I used 0.0001 because it need to be a double and would not work with an integer |
|
ok, so here's the issue: The JSON specification (http://www.json.org/) defines that object keys must be quoted strings. So textutils.serializeJSON() is correct here. Many Minecraft commands (ie. /tellraw), obey this specification, and expect and accept objects in this format. However, some older commands (such as /setblock), expect their data in a bastardised, incorrect JSON format. I could provide an option for serializeJSON to emit strings in this format, but when autoconverting tables, commands.blah() wouldn't know which one to use. Unsure what to do here. |
|
More info on the differences here: |
|
what are the options? |
|
Ok, decided on a solution: The signature of serialiseJSON is now: When the autogenerated commands.blah() methods encounter tables, they serialise by passing in true, except for the methods "tellraw" and "title", as the wiki incates that those are the only two methods which use proper, non-bastardised JSON. These changes will be in 1.76pr4. |
|
that is a great solution |
|
Could the affected functions in the commands table - eg commands.setblock - be rigged to set this flag to true if they find themselves calling textutils.serializeJSON? They don't seem to do so under pr6, meaning the coder has to pre-convert their tables to strings before passing them to the affected "command" functions. |
|
Unless theres's a bug in my code, that's exactly what happens in pr6. Can On 18 December 2015 at 11:34, Bomb Bloke notifications@github.com wrote:
|
|
(by command here i mean "line of lua code that calls commands.blah()") On 18 December 2015 at 11:38, Daniel Ratcliffe dratcliffe@gmail.com wrote:
|
|
Apologies, I can no longer reproduce. Either the issue is intermittent, or more likely, there was something else wrong with my table; having restarted the game since I can no longer check my command history, so we'll go with "I'm crazy". |
|
Could you provide a test case anyway? I'd like to confirm/double check for On 18 December 2015 at 12:04, Bomb Bloke notifications@github.com wrote:
|
|
Sure: commands.setblock("~ ~1 ~ minecraft:standing_sign 0 replace", {["Text2"] = "\1671Hello", ["Text3"] = "\1674World"}) |
Reproduce:
-Summon a cow
-run commands.entitydata("@e[r=10]",{Motion={0.0001,1.8,1.8}})
Expected result:
-cow flying into the distance
Real result:
NBT of cow: {"Motion":[0.00001,1.8,1.8],Motion:[0,0,0]}
The text was updated successfully, but these errors were encountered: