GTA Közösség - A magyar GTA fórum

Multi Theft Auto (MTA) => MTA: Szerverfejlesztés => Archívum => A témát indította: Rod - 2015. április 03. - 10:56:22

Cím: HUD components in table
Írta: Rod - 2015. április 03. - 10:56:22
Hali, hogy lehetne azt megvalósítani, hogy van nekem egy táblám amiben a HUD elemek neveit tárolom és azt, hogy látható-e avagy sem.
 

local components = {
   [\"hud\"] = true,
   [\"radar\"] = true,
   [\"actionbar\"] = false
}

 
..és ezt valahogy így használnám:
 
showHudComponent({\"hud\", \"actionbar\"})

 
Ezzel megjelenítené a Hud-ot és az Akcióbárt.
Elkezdtem tovább így, de elakadtam:
 

function showHudComponent(component)
if (components[component] == true) then return end
if (component == \"chat\") then
showChat(true)
end
if (component == \"all\") then
for i, v in pairs(components) do
   components = true
end
showChat(true)
end
components[component] = true
end

 
Tehát az a lényeg, hogy így kelljen használni:
 
showHudComponent({\"hud\", \"actionbar\"})

 
és nem pedig így:
 

showHudComponent(\"hud\")
showHudComponent(\"actionbar\")
Cím: HUD components in table
Írta: lackos888 - 2015. április 03. - 17:29:06
Helló. Egy tipp: (rég óta nem csináltam ilyet)(táblásítva)
 

function showHudComponent(tbl)
       for t, component in pairs(tbl) do
       -- ide tolhatsz majd 1 kis indentet
       if (components[component] == true) then return end
       
        if (component == \"chat\") then
                showChat(true)
        end
       
        if (component == \"all\") then
                for i, v in pairs(components) do
                        components = true
                end
                showChat(true)
        end
       
        components[component] = true
end--a ciklusé
end
Cím: HUD components in table
Írta: Rod - 2015. április 03. - 18:00:40
-- ide tolhatsz majd 1 kis indentet

 
 
Ez mit takar? Nem értem mi az az Indent, nem használtam (szerintem) még.
E: Megoldva, köszi a segítséget, működik!