moveCursor failing

Post Reply
Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

moveCursor failing

Post by Nyyrazzilyss »

I'm having some problems with moveCursor - It's failing. What am I missing?
Code: [show] | [select all] lua
local WindowWidth, WindowHeight = getMainWindowSize()

createMiniConsole("sys", 0,WindowHeight-80,WindowWidth,80)
setBorderBottom(80)

setBackgroundColor("sys",5,5,5,255)

setMiniConsoleFontSize("sys", 11)
setWindowWrap("sys", 80)
 
display(moveCursor("sys", 1,1))

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

Re: moveCursor failing

Post by Vadi »

moveCursor() moves the cursor (which you can't see) within the buffer/miniconsole, display() on it won't do anything as the function doesn't return anything.

Try using http://wiki.mudlet.org/w/Manual:Technic ... urrentLine to select the entire line the cursor is on now, copy() and paste() what you've selected.

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: moveCursor failing

Post by Nyyrazzilyss »

I understand that display won't do anything about the cursor, the problem i'm running into is the results coming back from the display are false.

Adjusting it slightly to

moveCursor("sys", 1,1)

cinsertText("sys", "<white>This is a test")

moveCursor("sys", 2,2)

cinsertText("sys", "<white>This is a test")

Is just displaying "This is a testThis is a test" in the top left hand corner of the window.

User avatar
SlySven
Posts: 1023
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: moveCursor failing

Post by SlySven »

How many lines are already present in the "sys" console. I'm guessing zero (or possibly one) and it is not inserting (whether it should is a different question) an additional line to enable you to move the cursor to line 2...

Are the results the same if you include a "\n" at the end of your strings - that won't solve every usage case but it might make a difference in this one, if I have read the situation right?

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: moveCursor failing

Post by Nyyrazzilyss »

SlySven wrote:How many lines are already present in the "sys" console. I'm guessing zero
You caught it right there: Thanks. And yes, there were 0 lines present (I hadn`t written anything to that window)

Neither cinsertText or insertText support newline characters. I used echo to get a newline to print out to the window. After printing a series of newlines, movecursor functioned properly on all lines that had been written to.

Post Reply