cecho() to a miniConsole

Post Reply
Phoenix
Posts: 92
Joined: Tue Feb 15, 2011 3:23 am

cecho() to a miniConsole

Post by Phoenix »

Code: [show] | [select all] lua
cecho("This <green:red>text<light_gray:black> is sent to the says miniConsole.", nil, nil, false, "chatSays")
Why does this not go to the chatSays miniconsole? This code clears that console just fine:
Code: [show] | [select all] lua
clearUserWindow("chatSays")

Phoenix
Posts: 92
Joined: Tue Feb 15, 2011 3:23 am

Re: cecho() to a miniConsole

Post by Phoenix »

Nevermind, I got it.

cecho([windowname, ] text)

Not sure about the rest of the arguments the manual claims it has, but this is how to send it to a window.

Denarii
Posts: 111
Joined: Thu Dec 03, 2009 10:54 pm

Re: cecho() to a miniConsole

Post by Denarii »

The manual is really out of date. Cecho used to use all those arguments, but I changed it to make it simpler and use the same pattern of arguments as echo.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: cecho() to a miniConsole

Post by tsuujin »

Denarii wrote:The manual is really out of date. Cecho used to use all those arguments, but I changed it to make it simpler and use the same pattern of arguments as echo.
To this end, I propose that we look for a lua implementation of javadoc and ... implement it. This way we can at least maintain a fully up-to-date API, and we can do it on the client side.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: cecho() to a miniConsole

Post by Vadi »

I'll see about replacing the API section of the manual with the luadoc one that lex did. Doesn't help it if heiko is too busy to update it and I don't have access, though. (but I did forget to update cecho - will get to that today)

Yetzederixx
Posts: 186
Joined: Sun Nov 14, 2010 5:57 am

Re: cecho() to a miniConsole

Post by Yetzederixx »

Code: [show] | [select all] lua
function setupGPrompt()
	WindowWidth = 0;
	WindowHeight = 0;
	WindowWidth, WindowHeight = getMainWindowSize();

	setBorderBottom(50)

	createMiniConsole("promptWindow", 0,0,0,0)
	setConsoleBufferSize("promptWindow", 100, 98)
	setBackgroundColor("promptWindow",0,0,0,255)
	setMiniConsoleFontSize("promptWindow", 18)
	--setWindowWrap("promptWindow", 150)
	setTextFormat("promptWindow",0,0,0,255,255,255,0,0,0)
	
	displayGPrompt()
end

function displayGPrompt()
	resizeWindow("promptWindow", WindowWidth - 15, 30)
	moveWindow("promptWindow", 0, WindowHeight - 50)
	showWindow("promptWindow")
end

function colorNum(curr, max)
	if (math.floor(curr / max * 100) >= 75) then return "<green>" .. curr
	elseif (math.floor(curr / max * 100) >= 50) then return "<yellow>" .. curr
	elseif (math.floor(curr / max * 100) >= 25) then return "<red>" .. curr
	else return "<white:red>" .. curr .. "<:black>"
	end
end

function colorNumPcnt(num)
	local toComp = math.floor(num)
	if toComp >= 75 then return "<green>" .. round(num, 1)
	elseif toComp >= 50 then return "<yellow>" .. round(num, 1)
	elseif toComp >= 25 then return "<red>" .. round(num, 1)
	else return "<white:red>" .. round(num, 1) .. "<:black>"
	end
end


function sysWindowResizeEvent()
	displayGPrompt()
end

function updatePrompt()
	local prompt = "\n"

	prompt = prompt .. "<red>(<white>" .. colorNumPcnt(currentHP/maxHP*100) .. "<red>%)"
	prompt = prompt .. "<cyan>(<white>" .. colorNumPcnt(currentMana/maxMana*100) .. "<cyan>%)"
	prompt = prompt .. "<yellow>(<white>" .. colorNumPcnt(currentMove/maxMove*100) .. "<yellow>%)"
	prompt = prompt .. "<gray>(<white>" .. exits .. "<gray>)"
	prompt = prompt .. "<gray>(<white>" .. rooms .. "<gray>)"

	if (qTimer and qTimer > 0) then 
		prompt = prompt .. "<gray>(<white>" .. qTimer .. "<gray>)"
	else 
		prompt = prompt .. "<gray>(<red>NQ<gray>)"
	end
	
	if (tnl and tnl ~= " ") then
		prompt = prompt .. "<gray>(<blue>" .. tnl .. "<gray>) \n"
	end

	if (isQuiet) then
		prompt = "<:DarkSlateBlue>" .. prompt
		--prompt = prompt .. "<gray>(<steel_blue>QUIET<gray>)"
	end
	--cecho(prompt)
	cecho("promptWindow", prompt)
end

function round(num, idp)
  local mult = 10^(idp or 0)
  return math.floor(num * mult + 0.5) / mult
end
I have no issues with this, and never did even with only 512MB of RAM.

Post Reply