Single Line Tables/String Issue

My question is simple, how do I convert a string in to a single lined table.

“string.ToTable(arg…“Dealer”)” returns as “M-I-S-C-D-E-A-L-E-R”, this is one table but with 10 seperate lines, one for each letter. But apparently table.ConCat changes the 10 lined table back to a single lined string. So I’ve tried multiple methods as to turning it in to a single lined table but with no success.

[lua]
MiscDealer = {}
MiscDealer[1] = {Name = “Pistol”, Model = “models/weapons/W_pistol.mdl”, Cost = 50, Sell = 40}

function DealerMenu(client)

local client = LocalPlayer()
local frame = vgui.Create("DFrame")
local IconList = vgui.Create( "DPanelList", frame ) 
local arg = client:GetNWString("DealerType") -- In this case it is "Misc".

frame:SetSize(w / 2 + 40, h / 2)
frame:SetTitle(arg)
frame:MakePopup()
frame:Center()

IconList:EnableVerticalScrollbar( true ) 
IconList:EnableHorizontal( true ) 
IconList:SetPadding( 4 ) 
IconList:SetPos(10,30)
IconList:SetSize(frame:GetWide() - 20, frame:GetTall() - 20)

local tab = table.concat(string.ToTable(arg.."Dealer")) --This returns "MiscDealer", Which is not a table, but a single lined string rather then table.

for k,v in pairs(tab) do
	local icon = vgui.Create( "SpawnIcon", IconList ) 
	icon:SetModel( v.Model )
	IconList:AddItem( icon )
	icon:SetToolTip( v.Name.." - $"..v.Cost )
	icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) frame:Close() BuyItem(client,v.Name,v.Cost) end
end

end
usermessage.Hook(“DealerMenu”, DealerMenu)
[/lua]

I’m not entirely sure what you’re asking. You want a table with one value of “MISCDEALER”? Why not just do


local tab = {}
tab[1] = arg.."dealer"

Well, see how my tables name is “MiscDealer” that means the table should only be active if the arg “Misc” is sent through the command. In this case it is but I’m having trouble changing “MiscDealer” from a string in to the assigned table needed in the k’v loop which in this case would be the “MiscDealer” table.

I’m still confused. Start over, explain clearly exactly what you’re trying to do.

However, if I’m understanding you right you are trying to use the table, MiscDealer, by using the string “MiscDealer”. In that case, it won’t work as you can’t use strings as variable names.

_G[arg…“Dealer”]

[editline]11:39PM[/editline]

That will work as long as you don’t use locals for the tables.

This is the process of it.

NameOfNPC = Misc

Player A “Talks” to NPC,
NPC sends player Anti-Exploit + NameOfNPC,
Anti-Exploit Sends DealerMenuUserMessage + NameOfNPC,
DealerMenu gets table with NameOfNPC…“Dealer” name,
DealerMenu fills menu with all items that are in the table.

I would just do this:

[lua]local Dealers = {
[“Misc”] = {
[1] = {Name = “Pistol”, Model = “models/weapons/W_pistol.mdl”, Cost = 50, Sell = 40},
},
}

local tab = Dealers[ arg ][/lua]

Wow, you don’t know how hard I just face palmed. Thanks for the help, can’t believe I didn’t know about that structure of tables.

Also, the following Lua is called on Ent:Use of the Npc. But why does it play so fast you can’t seem him wave? The player can only see his arm twitch/flail around for about 10ms.

[lua]
local sequence = self.Entity:LookupSequence(“Wave”)
self.Entity:SetSequence(sequence)
self.Entity:SetPlaybackRate(0.2) – I’ve tried changing this with no effect.
[/lua]