evn [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=13932 DELI(V,I) only works on int indexes <p>According to the <a href="https://www.lexaloffle.com/pico-8.php?page=manual">PICO-8 0.2.2c manual</a>, &quot;To remove an item at a particular index, use deli&quot;<br /> <div><div><input type="button" value=" Show " onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = ' Hide '; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = ' Show '; }"></div><div><div style="display: none;"></p> <pre><code>del t v Delete the first instance of value v in table t The remaining entries are shifted left one index to avoid holes. Note that v is the value of the item to be deleted, not the index into the table. (To remove an item at a particular index, use deli instead) del returns the deleted item, or returns no value when nothing was deleted. A={1,10,2,11,3,12} FOR ITEM IN ALL(A) DO IF (ITEM &lt; 10) THEN DEL(A, ITEM) END END FOREACH(A, PRINT) -- 10,11,12 PRINT(A[3]) -- 12 deli t [i] Like del(), but remove the item from table t at index i. When i is not given, the last element of the table is removed and returned.</code></pre> <p></div></div></div><br /> However, this does not seem to work with string or float indices. (Only tested on macOS Mojave)<br /> The desired result can be achieved using</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>t[i] = nil</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>which <a href="https://stackoverflow.com/a/1759017/">seems to be the accepted way</a> in lua.<br /> Possible resolutions:</p> <ul> <li>Update deli(t,i) to work with all index types</li> <li>Update PICO-8 manual to specify deli only works with integer indices, and include t[i]=nil workaround.</li> </ul> <p>thank you :)</p> https://www.lexaloffle.com/bbs/?tid=42109 https://www.lexaloffle.com/bbs/?tid=42109 Sun, 21 Mar 2021 03:16:52 UTC