weirdness with cecho

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

weirdness with cecho

Post by tarrant »

Hi, i created a miniconsole, and i capture my health bar and cecho it to that miniconsole with:

Code: Select all

cecho("StatusBar", "<green>""Hp:["..hpCur.."("..hpDelta..")/"..hpMax.."] <purple>Sp:["..spCur.."("..spDelta..")/"..spMax.."] <maroon>E:["..essCur.."("..essDelta..")/"..essMax.."]")
In the miniconsole, wherever there's a color code, like <green> and <purple> from above, there's a gap.

So for example, my miniconsole is supposed to look like this:
Hp:[100/100] Sp:[100/100] E:[100/100]

but instead, it looks like:
Hp:[100/100] - big chunk of space - Sp:[100/100] - big chunk of space - E:[100/100]

Is this a known issue? Or am i doing something wrong?
Please advice,
Thanks.

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: weirdness with cecho

Post by demonnic »

tarrant wrote:Hi, i created a miniconsole, and i capture my health bar and cecho it to that miniconsole with:

Code: Select all

cecho("StatusBar", "<green>""Hp:["..hpCur.."("..hpDelta..")/"..hpMax.."] <purple>Sp:["..spCur.."("..spDelta..")/"..spMax.."] <maroon>E:["..essCur.."("..essDelta..")/"..essMax.."]")
not sure about the spaces, but I'm pretty sure
Code: [show] | [select all] lua
cecho("StatusBar", "<green>HP:["..hpCur.."("..hpDelta..")/"..hpMax..?]<purplle> SP:["..spCur.."("..spDelta..")/"..spMax.."]<maroon> E:["..essCur.."("..essDelta..")/"..essMax.."]")
will work better than the above. The above seems to have extra " marks.

Jeisis
Posts: 11
Joined: Tue Mar 09, 2010 10:43 pm

Re: weirdness with cecho

Post by Jeisis »

Actually, I noticed with cecho, it'll color whatever text you want it to color, but then it'll also change the color of the last line to be echoed/displayed.

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

Re: weirdness with cecho

Post by tarrant »

@demon: thanks

@jeisis: yeah, it colours until the next colour tag i think.

still doesn't explain the weird spaces though.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: weirdness with cecho

Post by Heiko »

There's no known issues with cmake that I'm aware of, but cmake() is a new function so it's likely that there are some unknown issues left if used in an unusual context. cmake() is a wrapper function written in Lua on top of the low level API: setFgColor(), setBgColor(), echo(), insertText() and resetFormat().
If you suspect a bug in cecho, please try to solve your problem with the low level API first. Chances are that your script has a bug. Please note: If you are using moveCursor() in your script you must use insertText() instead of echo(). Echo() does not respect the current cursor position and always appends to the end of the line.

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

Re: weirdness with cecho

Post by tarrant »

Hmm, I simply trigger off my health bar with this:

Code: Select all

clearWindow("StatusBar")
hpCur = matches[2]
hpDelta = hpCur - hpLast
hpLast = matches[2]
hpMax = matches[3]
spCur = matches[4]
spDelta = spCur - spLast
spLast = matches[4]
spMax = matches[5]
essCur = matches[6]
essDelta = essCur - essLast
essLast = matches[6]
essMax = matches[7]
poss = matches[8]
cecho("StatusBar", "<green>""Hp:["..hpCur.."("..hpDelta..")/"..hpMax.."] <purple>Sp:["..spCur.."("..spDelta..")/"..spMax.."] <maroon>E:["..essCur.."("..essDelta..")/"..essMax.."]")
deleteLine()
Also, if i remove the colour tags e.g. <green> <purple> etc, the weird spaces disappear, still using cecho.

The same thing happens if i use:

Code: Select all

cecho("StatusBar", "<green>HP:["..hpCur.."("..hpDelta..")/"..hpMax.."]")
cecho("StatusBar", "<purple>SP:["..spCur.."("..spDelta..")/"..spMax.."]") 
cecho("StatusBar", "<maroon>E:["..essCur.."("..essDelta..")/"..essMax.."]")
However, if i do:

Code: Select all

cecho("StatusBar", "<green>HP:["..hpCur.."("..hpDelta..")/"..hpMax.."]")
cecho("StatusBar", "<green>SP:["..spCur.."("..spDelta..")/"..spMax.."]") 
cecho("StatusBar", "<green>E:["..essCur.."("..essDelta..")/"..essMax.."]")
with the same colour tag for all, the weird spaces disappear.

I have scrutinized these commands(?) and i don't see anything wrong with them, which is why i thought it could be an error from cecho itself.

Any thoughts?
Also, if there's a better way of doing what i want, feel free to correct me.
I literally just started learning how to do this a couple days back. Except for zmud/cmud's method, i have no prior knowledge of any sort of coding language, if you can even call zmud/cmud's way a coding language.
Thanks

P.s. The main reason i thought of trying this client out is because of the mapper, which is also the main reason i'm using zmud/cmud. How's the mapper coming along?

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

Re: weirdness with cecho

Post by Denarii »

For some reason the spaces are causing problems, I'm going to have to do some testing and try to figure out what's going on, I haven't seen this problem before. In the meantime, if you remove the spaces it should work. It appears to only happen when echoing text containing spaces to a miniconsole. Which is.. odd.

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

Re: weirdness with cecho

Post by Denarii »

Heiko, this is happening with normal echo() too. Echoing text containing a space or spaces to a miniconsole causes everything up to the last space in the string to be stripped.

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

Re: weirdness with cecho

Post by tarrant »

Denarii wrote:For some reason the spaces are causing problems
Sorry, I don't get what you mean. What spaces, where?

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

Re: weirdness with cecho

Post by Vadi »


Post Reply