Log In  

PICO-8 0.1.11b

The new editor tabs are really handy for keeping code organized, but currently there's no way to rearrange the tabs to influence how a cart's source code is assembled.

Currently, the code is assembled with [TAB0] first, then [TAB1], etc.

For example, if i have . . .


[TAB0]

function fn0()
  --
end

[TAB1]

function fn1()
  --
end

. . . that seems to get assembled as . . .


function fn0()
  --
end

function fn1()
  --
end

That means something like this won't work


[TAB0]

my_update=start_screen_update
my_draw=start_screen_draw

function _update()
  my_update()
end

function _draw()
  my_draw()
end

[TAB1]

function start_screen_update()
  --
end

function start_screen_draw()
  cls()
  print("start_screen_draw")
end

(my_update is nil because start_screen_update is not yet defined on [TAB0] LINE 1)

But if i swap the contents of [TAB0] and [TAB1] it works.

P#45733 2017-10-31 21:08 ( Edited 2017-11-01 01:08)

:: Felice

Are you saying you want tab order independent from compile order?

If so, how do you propose showing/setting those things up? Tab order is obviously a gui thing, but how do suggest zep could allow us to reorder compilation?

Seems it would require a separate control structure/file/section.

P#45743 2017-10-31 22:35 ( Edited 2017-11-01 02:36)

Why use function pointers like that though? If you just call the functions directly, you would not have that problem, right?

P#45749 2017-11-01 00:17 ( Edited 2017-11-01 04:17)

You want to initialize your state globals in _init(). All top-level definitions (in all tabs) will be executed before _init() is called. That's why there is _init().

A direct answer to your question: you can edit the .p8 file in a text editor and re-order the code regions. Each tab's worth of code is delimited by a comment that looks like this:

-->8
P#45751 2017-11-01 01:17 ( Edited 2017-11-01 05:17)

derp! _init() function works. that's a much better solution.

thanks dddaaannn

P#45752 2017-11-01 01:46 ( Edited 2017-11-01 05:48)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-02-23 20:31 | 0.011s | 2097k | Q:18