• util.TableToKeyValues broken?
    4 replies, posted
Alright, so i have an entity. I want to save its position, and angle when someone presses 'e' on it. Here is my code [lua] function ENT:Use() MOTD_Data = {} MOTD_Data.Pos = self.Entity:GetPos() MOTD_Data.Ang = self.Entity:GetAngles() MOTD_String = util.TableToKeyValues( MOD_Data ) file.Write( "MOTD3D/Mapdata/"..game.GetMap()..".txt", MOTD_String ) print( "MOTD Savedata:" ) print( " Map: "..game.GetMap() ) print( " Pos: "..tostring( self:GetPos() ) ) print( " Ang: "..tostring( self:GetAngles() ) ) end [/lua] Now, i get <mapename>.txt in MOTD3D/Mapdata/. BUT, this is what ends up inside it [code] "Out" { } [/code] I know util.TableToKeyValues IS working somewhat, otherwise i wouldn't have got that in the file. Perhaps it doesn't like my table? Maybe util.TableToKeyValues is broken? Maybe i am missing a stupidly obvious error? What do you guys think?
[code]] lua_run print(util.TableToKeyValues{Vector(),Angle(),"Test",1234}) > print(util.TableToKeyValues{Vector(),Angle(),"Test",1234})... "Out" { "3" "Test" "4" "1234" }[/code] util.TableToKeyValues() can't encode userdata. Use GLON.
[QUOTE=Lexic;19087927][code]] lua_run print(util.TableToKeyValues{Vector(),Angle(),"Test",1234}) > print(util.TableToKeyValues{Vector(),Angle(),"Test",1234})... "Out" { "3" "Test" "4" "1234" }[/code] util.TableToKeyValues() can't encode userdata. Use GLON.[/QUOTE] Oh, duh. GLON is a bit of an overkill in this situation. I just need something simple. Thanks anyway, i have an idea.
[url]http://wiki.garrysmod.com/?title=Table.DeSanitise[/url] [url]http://wiki.garrysmod.com/?title=Table.Sanitise[/url] Descriptions on the wiki.
[QUOTE=cyber_cam34;19087996][url]http://wiki.garrysmod.com/?title=Table.DeSanitise[/url] [url]http://wiki.garrysmod.com/?title=Table.Sanitise[/url] Descriptions on the wiki.[/QUOTE] Works a charm. Thanks guys :)
Sorry, you need to Log In to post a reply to this thread.