Captain_Man [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=50425 picomon <p>Super duper early WIP monster fighting game. Literally only a menu that does nothing. Up and down to move the cursor.</p> <p>I am mostly uploading right now to ask for help. If you open the game you'll see I have a little border drawn and am putting text inside of it. Is there any way to draw text in here more easily? The naive approach of printing each time leaves leftover text. My thought was to us <code>rectfill</code> but then the text doesn't print over it (despite calling <code>print</code> afterwards). I've put the relevant code below of what I'm using. My thought it to just use solid background (<code>\#0 control code</code>) but this would still mean I need to print over the full area each time (by padding).</p> <p>This just seems like it would be something more textual games have run into before and I was wondering what the approach is.</p> <p>Thanks!</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>function _draw() -- ...snip... draw_menu() end menu={&quot;fight&quot;, &quot;item&quot;, &quot;run&quot;} selection=0 function draw_menu() local text=&quot;&quot; for k,v in pairs(menu) do if selection==k-1 then text..=&quot;➡️&quot; else text..=&quot; &quot; end text..=v..&quot;\n&quot; end textbox(8, 72, 112, 48, text) end -- 8, 72, 112, 48 for full area function textbox(x, y, w, h, text) --rectfill(x, y, x+w-1, y+h-1, 0) --[[rhs wrap based on absolute x, not offset from print call]] local num_chars = to_fake_hex_str(flr((x+w)/4)) print(&quot;\#0\^r&quot;..num_chars..text, x, y) end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p> <table><tr><td> <a href="/bbs/?pid=116332#p"> <img src="/bbs/thumbs/pico8_picomon-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=116332#p"> picomon</a><br><br> by <a href="/bbs/?uid=50425"> Captain_Man</a> <br><br><br> <a href="/bbs/?pid=116332#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=49064 https://www.lexaloffle.com/bbs/?tid=49064 Fri, 26 Aug 2022 18:59:21 UTC