commit e6b887bb9e80530109d3ac2e53372713c5c9801c
Author: jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Mon Nov 23 07:30:11 2020 -0700
Commit: jtothebell <j.to.the.bell@gmail.com>
CommitDate: Mon Nov 23 07:30:11 2020 -0700
WIP adding run api function (often used by tweetcarts)
---
source/picoluaapi.cpp | 6 ++++++
source/picoluaapi.h | 1 +
source/vm.cpp | 6 ++++++
source/vm.h | 1 +
4 files changed, 14 insertions(+)
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index 112c3a6..cc7679d 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -785,6 +785,12 @@ int _update_buttons(lua_State *L) {
return 0;
}
+int run(lua_State *L) {
+ _vmForLuaApi->vm_run();
+
+ return 0;
+}
+
int listcarts(lua_State *L) {
//get cart list from VM (who should get it from host)
vector<string> carts = _vmForLuaApi->GetCartList();
diff --git a/source/picoluaapi.h b/source/picoluaapi.h
index e5f906c..4c2c9e8 100644
--- a/source/picoluaapi.h
+++ b/source/picoluaapi.h
@@ -98,6 +98,7 @@ int loadbioscart(lua_State *L);
int rnd(lua_State *L);
int srand(lua_State *L);
int _update_buttons(lua_State *L);
+int run(lua_State *L);
//api.tonum(val)
diff --git a/source/vm.cpp b/source/vm.cpp
index c7ff2b6..9b59e5b 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -220,6 +220,7 @@ bool Vm::loadCart(Cart* cart) {
lua_register(_luaState, "printh", printh);
lua_register(_luaState, "stat", stat);
lua_register(_luaState, "_update_buttons", _update_buttons);
+ lua_register(_luaState, "run", run);
//rng
lua_register(_luaState, "rnd", rnd);
@@ -679,5 +680,10 @@ void Vm::vm_flip() {
//is this better at the end of the loop?
_host->waitForTargetFps();
}
+}
+void Vm::vm_run() {
+ if (_loadedCart) {
+ loadCart(_loadedCart);
+ }
}
diff --git a/source/vm.h b/source/vm.h
index 1b7b132..5346836 100644
--- a/source/vm.h
+++ b/source/vm.h
@@ -114,5 +114,6 @@ class Vm {
void update_buttons();
void vm_flip();
+ void vm_run();
};