gbrain Posted August 27, 2019 Share Posted August 27, 2019 Hi, new to modding and read a lot but still trying to figure out the following. There is a nice little mod to show the resource on the main page but it relies on an existing script called MusicCoordinator. https://github.com/rinart73/Resource-Display/blob/master/data/scripts/player/client/musiccoordinator.lua So I am trying to work out how to make this type of mod not reliant on MusicCoordinator put a personal function/namespace. Any guidance would be appreciated. G. Link to comment Share on other sites More sharing options...
Rinart73 Posted August 28, 2019 Share Posted August 28, 2019 Keep in mind that this mod will not be 100% clientside anymore. data/scripts/player/init.lua if onServer() then Player():addScriptOnce("data/scripts/player/ui/mymodname.lua") end data/scripts/player/ui/mymodname.lua -- namespace MyModName MyModName = {} if onClient() then function MyModName.initialize() if not GameSettings().infiniteResources then Player():registerCallback("onPreRenderHud", "onPreRenderHud") end end function MyModName.onPreRenderHud() local player = Player() if player.infiniteResources then return end local resources = {player:getResources()} local y = 10 local material, rect for i = 1, #resources do material = Material(i-1) y = y + 18 rect = Rect(5, y, 295, y + 16) drawTextRect(material.name, rect, -1, -1, material.color, 15, 0, 0, 2) drawTextRect(createMonetaryString(resources[i]), rect, 1, -1, material.color, 15, 0, 0, 2) end y = y + 18 rect = Rect(5, y, 295, y + 16) local color = ColorRGB(1, 1, 1) drawTextRect("Credits"%_t, rect, -1, -1, color, 15, 0, 0, 2) drawTextRect(createMonetaryString(player.money), rect, 1, -1, color, 15, 0, 0, 2) end end Link to comment Share on other sites More sharing options...
gbrain Posted August 28, 2019 Author Share Posted August 28, 2019 Hi, many thanks for the reply. That makes perfect sense and gives me an understanding on the structure going forward. G. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now