Jump to content

imeryak

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by imeryak

  1. 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?

×
×
  • Create New...