I am building a cPanel for my tool. I am adding a tree with nodes from a table if definitions and I have:
[code]
local pTree = vgui.Create("DTree")
pTree:SetPos(2, 2)
pTree:SetSize(Header:GetWide() - 4, 250)
pTree:SetIndentSize(0)
local pFolder
local pNode
for k,v in pairs(RailTypes) do
if(v.isFolder) then
print("RAILASSEMBLY: Adding Folder : "..v.Name)
-- Make a Folder Node
pFolder = pTree:AddNode(v.Name)
pFolder:SetName(v.Name)
pFolder.Icon:SetImage("icon16/disconnect.png")
function pFolder:InternalDoClick() end
pFolder.DoClick = function()
return false
end
local FolderLabel = pFolder.Label
function FolderLabel:UpdateColours(skin)
return self:SetTextStyleColor(Color(161, 161, 161))
end
print("RAILASSEMBLY: Adding Folder: "..pFolder:GetName().." SUCCESS")
elseif(v.isFolderend) then
print("RAILASSEMBLY: Nilng Folder : "..pFolder:GetName())
pFolder = nil
else
print("RAILASSEMBLY MODEL: Doing "..v.Model)
if(pFolder) then -- and util.IsValidModel(v.Model) ??
print("RAILASSEMBLY TRUE ?: "..tostring(util.IsValidModel(v.Model))) --- Alyaws FALSE ( IsValidModel )
print("RAILASSEMBLY TRUE ?: "..tostring(file.Exists("sw_rerailer_3.mdl", "models/props_phx/trains/"))) --- Alyaws FALSE ( Existant )
print("RAILASSEMBLY TRUE ?: "..tostring(file.Exists("ASD.mdl", "models/props_phx/trains/"))) --- Alyaws FALSE ( NoN Existant )
print("RAILASSEMBLY MODEL: Adding Node: "..v.Name.." to Folder: "..pFolder:GetName())
-- Adding Current AVAILABLE MODEL to the tree using the pFolder reference
pNode = pFolder:AddNode(v.Name)
pNode.Icon:SetImage("icon16/control_play_blue.png")
pNode.DoClick = function()
RunConsoleCommand("railassembly_model", v.Model)
RunConsoleCommand("railassembly_pointid", 0)
end
print("RAILASSEMBLY MODEL: Adding Node: "..v.Name.." to Folder: "..pFolder:GetName().." SUCCESS")
end
end
end
CPanel:AddItem(pTree)
[/code]
Can you tell me guys how can I see that my model is valid while building my cPanel
Thanks!
What is v.Model defined as? util.IsValidModel requires a full path to the model. As for your file.Exists, the second argument has to be either GAME, LUA (or lsv), DATA, or MOD. Check the documentation here: [url]http://wiki.garrysmod.com/page/file/Exists[/url]
Actual path to to the model for example:
[code]
v.Model = "models/props_phx/trains/tracks/track_turn90.mdl" -- TRUE
v.Model = "models/props_phx/trains/tracks/track_asdfnq.mdl" -- FAKE
[/code]
And it should return false for both of them :/
Some of them are located in the GCF's though, so I thin file.Exists is out of option ....
GCF's are just packaged files; they are still part of the directories.
You mean like this:
[code]
-- Full path is : --models/props_phx/trains/monorail_curve2.mdl
print("Exists: "..tostring(file.Exists("monorail_curve2","GAME")))
print("Exists: "..tostring(file.Exists("monorail_curve234","GAME")))
[/code]
Still returns FALSE though....
I will be sure to try that a.s.a.i.g.h. :)
[QUOTE=Robotboy655;45032957]You are misusing file.Exists:
[code]print("RAILASSEMBLY TRUE ?: "..tostring(file.Exists("sw_rerailer_3.mdl", "models/props_phx/trains/"))) --- Alyaws FALSE ( Existant )
print("RAILASSEMBLY TRUE ?: "..tostring(file.Exists("ASD.mdl", "models/props_phx/trains/"))) [/code]
should be
[code]
print("RAILASSEMBLY TRUE ?: "..tostring(file.Exists("models/props_phx/trains/sw_rerailer_3.mdl", "GAME"))) --- Alyaws FALSE ( Existant )
print("RAILASSEMBLY TRUE ?: "..tostring(file.Exists("models/props_phx/trains/ASD.mdl", "GAME"))) [/code][/QUOTE]
[code]
if(file.Exists(v.Model, "GAME")) then
-- Add it to the cPanel
else
-- Don't add it to the cPanel xD
end
[/code]
Exactly as i wanted 10x again guys a video with the full functionality is comming soon on my youtube channel !
Marking as solved !
Sorry, you need to Log In to post a reply to this thread.