util.encode /util.decode

Things that already exist in the current mod API
Post Reply
User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jul 08, 2014 10:06 am
Contact:

util.encode /util.decode

Post 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
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: util.encode /util.decode

Post by Klonan »

Can you post an example Lua table that doesn't work with the functions?

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: util.encode /util.decode

Post 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.
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: util.encode /util.decode

Post 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

User avatar
LuziferSenpai
Filter Inserter
Filter Inserter
Posts: 333
Joined: Tue Jul 08, 2014 10:06 am
Contact:

Re: util.encode /util.decode

Post by LuziferSenpai »

Okay, sry! Was just reading throw it.
Can be closed.
Coding is awesome!
Animes are love!
Factorio is life!

My MODs:
Click

Greetz,

Senpai

Post Reply

Return to “Already exists”