Jump to content

Welcome to the Forum!

The best place to exchange builds and ideas! Vote for the best ideas and suggestions here.

Join the Avorion Discord!

Connect with other passionate players and talk about the latest news.
Discord

DLC Avorion Into the Rift Out Now!

Now available on Steam!
Steam

Adding notes to a sector


imeryak
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...