file.Find
Örnek
data klasöründeki ilk dosyayı ve ilk dizini yazdırır.
local files, directories = file.Find( "*", "DATA" )
print( "Dosya: " .. files[1], "Klasör: " .. directories[1] )
Çıktı:
Dosya: helloworld.txt
Klasör: ctp
Örnek
Belirli bir eklentinin veya tüm eklentilerin içine doğrudan bakabilen, ilkel bir whereis file komutu. Belirli dosyaları bulmak için engine.GetAddons+eklenti başlıklarında özyinelemeli olarak arama yapar.
local function recurseListContents(path, addon, direct, pattern)
local files, dirs = file.Find(path.."*", addon)
local matchedFiles = {}
for _, v in ipairs(files) do
local fullPath = path..v
if not pattern or string.match(fullPath, pattern) then
table.insert(matchedFiles, fullPath)
end
end
if direct then return matchedFiles end
for _, dir in ipairs(dirs) do
local subFiles = recurseListContents(path..dir.."/", addon, false, pattern)
for _, file in ipairs(subFiles) do
table.insert(matchedFiles, file)
end
end
return matchedFiles
end
function FindContentInAddon(the_special_content, in_a_specific_addon)
local addons = engine.GetAddons()
if not the_special_content then
for _, addon in ipairs(addons) do
local title = addon.title
print("\nİçerik listeleniyor:", title)
recurseListContents("", title, false)
end
return
end
local found = {}
for _, addon in ipairs(addons) do
local title = in_a_specific_addon or addon.title
local path = addon.file
local pattern = the_special_content:gsub("%*", ".*")
local files = recurseListContents("", title, false, pattern)
if #files > 0 then
table.insert(found, {title, files, path})
end
if in_a_specific_addon then break end
end
if #found > 0 then
for _, v in ipairs(found) do
local matches = #v[2]
print(matches.." adet eşleşme \""..v[1].."\" eklentisinde bulundu, bağlama noktası: "..v[3])
for _, filePath in ipairs(v[2]) do
print(" - "..filePath)
end
end
else
if in_a_specific_addon then
print(the_special_content.." şurada bulunamadı: "..in_a_specific_addon.."!")
else
print(" - "..the_special_content.." bulunamadı!")
end
end
end
concommand.Add("find_content", function(ply, cmd, args) FindContentInAddon(args[1], args[2]) end)
Çıktı:
] find_content *
- tüm eklentilerdeki tüm içeriği listeler, joker karakterler desteklenir :)
] find_content *.lua
2 adet eşleşme "Extended Spawnmenu" eklentisinde bulundu, bağlama noktası: content/4000/104603291/104603291.gma
- lua/autorun/rb655_extended_spawnmenu.lua
- lua/autorun/rb655_legacy_addon_props.lua
9 adet eşleşme "Seamless Portals" eklentisinde bulundu, bağlama noktası: content/4000/2773737445/gmpublisher.gma
- lua/autorun/sh_detours.lua
- lua/autorun/sh_portal_movement.lua
- lua/autorun/client/cl_render_core.lua
- lua/autorun/server/sv_portals_pvs.lua
- lua/autorun/server/sv_prop_teleport.lua
- lua/entities/seamless_portal.lua
- lua/weapons/portal_gun.lua
- lua/weapons/gmod_tool/stools/portal_creator_tool.lua
- lua/weapons/gmod_tool/stools/portal_resizer_tool.lua
7 adet eşleşme "Track Assembly Tool" eklentisinde bulundu, bağlama noktası: content/4000/287012681/TrackAssemblyTool.gma
- lua/autorun/trackassembly_init.lua
- lua/autorun/z_autorun_[shinji85_s_rails].lua
- lua/entities/gmod_wire_expression2/core/custom/cl_trackasmlib_wire.lua
- lua/entities/gmod_wire_expression2/core/custom/trackasmlib_wire.lua
- lua/trackassembly/trackasmlib.lua
- lua/vgui/dasminsliderbutton.lua
- lua/weapons/gmod_tool/stools/trackassembly.lua
1 adet eşleşme "Collision Resizer (ENHANCED)" eklentisinde bulundu, bağlama noktası: cache/workshop/217376234.gma
- lua/weapons/gmod_tool/stools/advresizer.lua
4 adet eşleşme "Advanced Material | REBORN" eklentisinde bulundu, bağlama noktası: content/4000/3118788923/gmpublisher.gma
- lua/autorun/sh_mateditor_loader.lua
- lua/mateditor/sh_advmat_footsteps.lua
- lua/mateditor/sh_mateditor.lua
- lua/weapons/gmod_tool/stools/advmat.lua
] find_content m_anm.mdl
1 adet eşleşme "[wOS] Animation Extension - Base (Full Version)" eklentisinde bulundu, bağlama noktası: content/4000/757604550/wiltos_animation_base.gma
- models/m_anm.mdl
Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord