johan.win [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=89610 [Feature req] Subfolders relative paths are off <p>Imagine this folder structure</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>├── libs │&nbsp;&nbsp; ├── b.p8 │&nbsp;&nbsp; └── c.p8 └── main.p8</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>If <code>main.p8</code> calls <code>./libs/b.p8</code> which in turns wants to call <code>c.p8</code>, it has to use use the relative path from the main cart, i.e. <code>./libs/c.p8</code> even if <code>b.p8</code> and <code>c.p8</code> is in the same folder.</p> <p>Usually programming languages have relative paths starting from the file that is doing the import. Could we get the same behaviour for pico-8 please?</p> <p>Right now most multi-cart games have everything in single dir which makes things looking pretty messy, and if I want to have a multi cart game on my rgb30 where I hide the extra files in <code>.hidden</code> I have to edit all files making <code>load</code> calls to make things work which is not optimal.</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="/media/89610/Screenshot 2024-02-06 at 18.17.50.png" alt="" /> <p>Here is full code to replicate (files created with vs code, hence the extra stuff at the top):</p> <h2>What works:</h2> <p>Filename: main-absolute.p8</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>pico-8 cartridge // http://www.pico-8.com version 41 __lua__ print(&quot;In main-absolute.p8&quot;) load(&quot;libs/sub-load-with-absolute-path.p8&quot;)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Filename: libs/sub-load-with-absolute-path.p8</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>pico-8 cartridge // http://www.pico-8.com version 41 __lua__ print(&quot;In sub-load-with-absolute-path.p8&quot;) load(&quot;libs/final-destination.p8&quot;)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Filename: libs/final-destination.p8</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>pico-8 cartridge // http://www.pico-8.com version 41 __lua__ print(&quot;In final-destination.p8&quot;)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <h2>What I would like to work</h2> <p>Filename: main-relative.p8</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>pico-8 cartridge // http://www.pico-8.com version 41 __lua__ print(&quot;In main-relative.p8&quot;) load(&quot;libs/sub-load-with-relative-path.p8&quot;)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Filename: libs/sub-load-with-relative-path.p8</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>pico-8 cartridge // http://www.pico-8.com version 41 __lua__ print(&quot;In sub-load-with-relative-path.p8&quot;) load(&quot;final-destination.p8&quot;)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Note the missing <code>libs/</code> in the <code>load</code> 👆</p> <p>Filename: libs/final-destination.p8</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>pico-8 cartridge // http://www.pico-8.com version 41 __lua__ print(&quot;In final-destination.p8&quot;)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Ive yet to see any multi cart games using any type of folder structure, so in theory should be safe to implement.</p> <p>Thoughts?</p> https://www.lexaloffle.com/bbs/?tid=140118 https://www.lexaloffle.com/bbs/?tid=140118 Tue, 06 Feb 2024 17:16:38 UTC