imeryak Posted December 3, 2022 Share Posted December 3, 2022 I'm trying to make a mod, which will add trader post most expensive goods to a galaxy map, so i can find them later through a search box. Ended up with following code, attached to a server Player(): function sectorEntered(palyerIndex, x, y) local sector = Sector() --get current sector local tradePosts = {sector:getEntitiesByScript("entity/merchants/tradingpost.lua")} --get all trade posts in sector --if there are none skip if #tradePosts > 0 then local view = Galaxy():findPlayer(palyerIndex):getKnownSector(x, y) local noteText for _, tradePost in pairs(tradePosts) do -- local sellable = {} local buyable = {} --get all goods sold by station TradingUtility.getBuyableAndSellableGoods(tradePost, sellable, buyable) --full station name noteText = string.format("%s - %s", tradePost.title, tradePost.name) --sorting by price, most expensive first table.sort(buyable, function(a, b) return a.price > b.price end) --get NUM first for i = 1, NUM do noteText = string.format("%s\n%s",noteText,buyable[i].good.name); end view.note = NamedFormat(noteText, {}) --not working, sector notes are empty print(view.note.text) --working, print what i want in console end end print("OK!") end The problem is notes won't show on a map, but show in console just fine. Not sure where is issue here, can someone explain? Link to comment Share on other sites More sharing options...
imeryak Posted December 3, 2022 Author Share Posted December 3, 2022 Found a solution - a Player():updateKnownSector() function is needed to update the client. Link to comment Share on other sites More sharing options...
Valck Posted December 8, 2022 Share Posted December 8, 2022 Glad you found a solution, and thank you for sharing it. Just a side note, s/palyerIndex/playerIndex/ Things like these are are going to bite you in the back when you've long forgotten about them. 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