Creating a Redirect Object
#1
Posted 23 March 2016 - 04:36 PM
Currently, I'm trying to debug my blit function, which is weirdly erroring on line 51 with 'attempt to index ? (a nil value)'. I've proven that internalText exists, and that internalY is always 1. Strangely enough, it errors on the 5th call, not the first.
#2
Posted 23 March 2016 - 05:38 PM
local internalX, internalY, internalText = 5, 1, {}
internalText[ internalY ] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
text = "blabla"
print( internalText[ internalY ] )
internalText[ internalY ] = internalText[ internalY ]:sub( 1, internalX ) .. text .. internalText[ internalY ]:sub( internalX + #text )
print( internalText[ internalY ] )
Edited by moTechPlz, 23 March 2016 - 05:40 PM.
#3
Posted 23 March 2016 - 05:59 PM
Edited by KingofGamesYami, 23 March 2016 - 05:59 PM.
#4
Posted 23 March 2016 - 06:56 PM
#5
Posted 23 March 2016 - 07:33 PM
#6
Posted 23 March 2016 - 07:33 PM
Dog, on 23 March 2016 - 07:33 PM, said:
Thanks for pointing that out, fixed. Not intentional, as I said before I need to do a lot of testing - once this runs without outright erroring.
Edited by KingofGamesYami, 23 March 2016 - 07:34 PM.
#7
Posted 23 March 2016 - 07:47 PM
I noticed in your update function (specifically lines 30 and 34) that you have two loops (one nested inside the other), both using y as a variable. How does the code within the nested loop know which y value to use?
#8
Posted 23 March 2016 - 07:49 PM
Edit: Wait, wait, why is tMonitors a nested table? Shouldn't it just be a table full of wrapped monitors?
Edited by Dragon53535, 23 March 2016 - 07:52 PM.
#9
Posted 23 March 2016 - 07:55 PM
I *think* tMonitors tracks the stitched monitors, so each tMonitor entry has a table of multiple monitors within it.
Edited by Dog, 23 March 2016 - 07:58 PM.
#10
Posted 23 March 2016 - 08:05 PM
local tMonitors = {
{ <1,1>, <2,1>, <3, 1> },
{ <2,1>, <2,2>, <3, 2> },
}
Yeah I don't care about the y value in the upper loop, it's not used. I could change it, but I'm using it to remember how the layout of my table structure is.
Edit: actually, I'm messing with the update() code in game right now, it's rendering everything 1 character to the right at the moment (or maybe that's the buffer?)
Edit #2: I think the above is related to that
Edit #3: Fixied!
[b]Note: I am editing the paste I posted in the OP frequently.
Edited by KingofGamesYami, 23 March 2016 - 08:12 PM.
#11
Posted 23 March 2016 - 08:09 PM
term.native().write(internalText[internalY])That way we can check if it's erroring on internalText being nil, or that specific spot.
Edited by Dragon53535, 23 March 2016 - 08:09 PM.
#12
Posted 23 March 2016 - 08:17 PM

Dafuq?
#13
Posted 23 March 2016 - 08:40 PM
#14
Posted 23 March 2016 - 09:01 PM
#15
Posted 23 March 2016 - 09:50 PM
#16
Posted 23 March 2016 - 11:21 PM
Edit: Guess I got ninja'd by you confirming lol
Edited by Dragon53535, 23 March 2016 - 11:22 PM.
#17
Posted 23 March 2016 - 11:21 PM
Update: Now getting to second row before too long without yielding error. Progress!
Edited by KingofGamesYami, 23 March 2016 - 11:36 PM.
#18
Posted 23 March 2016 - 11:41 PM
Shouldn't clearLine() / scroll() call update()?
stitch.blit() needs to ensure the text is in bounds. It'll need to crop it if one of the ends will poke off the left / right of the display, or entirely ignore it if it won't be visible at all.
#19
Posted 23 March 2016 - 11:48 PM
Yes they do, fixed.
That's going to hurt performance. *smashes head against wall*. What would be the most efficient way to do this? I'm not entirely certain I need to do that at all, won't mon.blit cut it for me?
#20
Posted 24 March 2016 - 12:09 AM
KingofGamesYami, on 23 March 2016 - 11:48 PM, said:
Hah, no, mon.blit() isn't going to help you. When you only want to add part of the incoming text to your buffer, you're going to have to specify that.
The window API has an example of how you might go about doing it, and is about as efficient as you'll get.
https://github.com/a...pis/window#L103
In terms of optimising the rest of your code, cache table lookups - if you're going to index into the same position multiple times, do it once, assign the value to a new local, and then refer to that from then on.
Also cache table lengths and rep'd strings, and avoid select().
Edited by Bomb Bloke, 24 March 2016 - 12:12 AM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











