Page 1 of 1

util.encode /util.decode

Posted: Sat Sep 14, 2019 1:47 pm
by LuziferSenpai
Hey,

it would be awesome if the two utils in the title would work perfectly with table_to_json and json_to_table!
Currently they dont support ":{

Greetz,

Luzifer

Re: util.encode /util.decode

Posted: Sat Sep 14, 2019 1:51 pm
by Klonan
Can you post an example Lua table that doesn't work with the functions?

Re: util.encode /util.decode

Posted: Sat Sep 14, 2019 1:56 pm
by LuziferSenpai
Sry my Fail, I looked into the character table string and didnt saw these three, but it encodes this:

Code: Select all

local Types =
{
	["01"] = 
	{
		["01"] = "item",
		["02"] = "entity",
		["03"] = "technology",
		["04"] = "recipe",
		["05"] = "item-group",
		["06"] = "fluid",
		["07"] = "tile",
		["08"] = "signal",
		["09"] = "achievement"
	},
	["02"] = "entity",
	["03"] = "technology",
	["04"] = "recipe",
	["05"] = "item-group",
	["06"] = "fluid",
	["07"] = "tile",
	["08"] = "signal",
	["09"] = "achievement"
}
into this:

Code: Select all

eyIwMSI6eyIwMSI6Iml0ZW0iLCIwMiI6ImVudGl0eSIsIjAzIjoidGVjaG5vbG9neSIsIjA0IjoicmVjaXBlIiwiMDUiOiJpdGVtLWdyb3VwIiwiMDYiOiJmbHVpZCIsIjA3IjoidGlsZSIsIjA4Ijoic2lnbmFsIiwiMDkiOiJhY2hpZXZlbWVudCJ9LCIwMiI6ImVudGl0eSIsIjAzIjoidGVjaG5vbG9neSIsIjA0IjoicmVjaXBlIiwiMDUiOiJpdGVtLWdyb3VwIiwiMDYiOiJmbHVpZCIsIjA3IjoidGlsZSIsIjA4Ijoic2lnbmFsIiwiMDkiOiJhY2hpZXZlbWVudCJ9
and back, so I was thinking without testing. Well you can come to that point too, when you just read the string.

Re: util.encode /util.decode

Posted: Sat Sep 14, 2019 3:16 pm
by Klonan
I think you are just not understanding the function, it can encode any string

Using encode with json to table is used in the PvP scenario and there have been 0 issues reported with it

Re: util.encode /util.decode

Posted: Sat Sep 14, 2019 3:37 pm
by LuziferSenpai
Okay, sry! Was just reading throw it.
Can be closed.