Szerző Téma: HUD components in table  (Megtekintve 732 alkalommal)

Nem elérhető Rod

HUD components in table
« Dátum: 2015. április 03. - 10:56:22 »
0 Show voters
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\")

HUD components in table
« Válasz #1 Dátum: 2015. április 03. - 17:29:06 »
0 Show voters
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

Nem elérhető Rod

HUD components in table
« Válasz #2 Dátum: 2015. április 03. - 18:00:40 »
0 Show voters
-- 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!
« Utoljára szerkesztve: 2015. április 03. - 18:20:27 írta Rod »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal