this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement "resume reload" command. (#2609)

* Implement "resume reload" command.

When resuming, you can pass "reload" as the argument, which causes the
cart's code to be reloaded before resuming the game.

This allows for a much smoother iterative development style where you
can pause the game, make changes, and see the effect of those changes
without restarting the game. It does require some special handling in
the cart to support saving state to a global and avoiding that state
being reinitialized if it's already set; for instance:

state = state or {x=25, y=100, shots={}}

This implements it in a way that will be supported by any script that
already supports eval.

* Don't try to eval in fennel if the VM hasn't been initialized.

authored by

Phil Hagelberg and committed by
GitHub
921d5e6e 43a03178

+21
+4
src/api/fennel.c
··· 165 165 tic_core* core = (tic_core*)tic; 166 166 lua_State* fennel = core->currentVM; 167 167 168 + /* if we proceed with an uninitialized VM it will segfault; however */ 169 + /* it could be better just to initialize here when needed instead! */ 170 + if (!fennel) return; 171 + 168 172 lua_settop(fennel, 0); 169 173 170 174 if (luaL_loadbuffer(fennel, execute_fennel_src, strlen(execute_fennel_src), "execute_fennel") != LUA_OK)
+17
src/studio/screens/console.c
··· 2667 2667 2668 2668 static void onResumeCommand(Console* console) 2669 2669 { 2670 + if(console->desc->count) 2671 + { 2672 + const char* param = console->desc->params->key; 2673 + 2674 + if(strcmp(param, "reload") == 0) 2675 + { 2676 + const tic_script* script_config = tic_get_script(console->tic); 2677 + if (script_config->eval) 2678 + { 2679 + script_config->eval(console->tic, console->tic->cart.code.data); 2680 + } 2681 + else 2682 + { 2683 + printError(console, "eval not implemented for the script"); 2684 + } 2685 + } 2686 + } 2670 2687 commandDone(console); 2671 2688 2672 2689 resumeGame(console->studio);