User:CosmicSRB2wiki/Cosmetal

From SRB2 Wiki
Jump to navigation Jump to search

This page is related to Cosmetal mod support in the form of adding new variables and Chaos Emerald Hud types.


Custom Variables

Cosmetal's variable system as of 2.0 supports adding custom variables, with the table containing them being CMS.Variables. So, to access an entry, you can do CMS.Variables["varname"], which returns a table of filename and value. To add a custom variable, you can use the function CMS.AddVar(string name, string filename, number or boolean value). This creates a new variable entry under the name name, which can then be accessed, e.g. CMS.Variables["custom"].value. To set a variable within the variables table, you can use CMS.Set(string name, number or boolean value), to set a variable's value from a file, use CMS.Get(string name) and to simply check one's value, use CMS.Check(string name).

Custom Chaos Emerald HUD types

Cosmetal's Emerald HUD system allows for custom graphics mods to use their own Emerald HUD graphics, which can use Cosmetal's base graphics as a base, in order to have different emerald shapes. You just need to name the hud graphics CMSEMERALDS3 for just Chaos Emeralds, and CMSEMERALDS4 for Sol Emeralds. Then, you need to make a lua script that contains this bit of code:

addHook("ThinkFrame", function()
    if CMS
       CMS.AddHudType("name", {3,4})
    end
end)

Theoretically, 3 and 4 could be replaced with any other number, but 3 and 4 are preferred.