Skip to content

Commit

Permalink
Changed MelonPrint to print,
Browse files Browse the repository at this point in the history
Renamed "MelonPrint" to just "print",
TIL you can redefine pretty much any lua funct...
Also fixed the lua console not re-opening after closing it the first time.
  • Loading branch information
NPO-197 committed Oct 27, 2024
1 parent a6dd236 commit b16912a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/frontend/qt_sdl/LuaMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void LuaConsoleDialog::closeEvent(QCloseEvent *event)
{
onStop();
bundle->overlays->clear();
flagClosed = true;
event->accept();
}

Expand Down Expand Up @@ -248,7 +249,7 @@ int lua_MelonPrint(lua_State* L)
bundle->getEmuThread()->onLuaPrint((QString)string);
return 0;
}
AddLuaFunction(lua_MelonPrint,MelonPrint);
AddLuaFunction(lua_MelonPrint,print);

int lua_MelonClear(lua_State* L)
{
Expand Down
1 change: 1 addition & 0 deletions src/frontend/qt_sdl/LuaMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class LuaConsoleDialog: public QDialog
QPushButton* buttonStartStop;
QPushButton* buttonPausePlay;
QScrollBar* bar;
bool flagClosed;
protected:
void closeEvent(QCloseEvent *event) override;
LuaBundle* bundle;
Expand Down
11 changes: 8 additions & 3 deletions src/frontend/qt_sdl/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,10 +1680,15 @@ void MainWindow::onOpenPowerManagement()

void MainWindow::onOpenLuaScript()
{
if (this->luaDialog)
if (luaDialog && luaDialog->flagClosed)
{
delete luaDialog;
luaDialog = nullptr;
}
if (luaDialog)
return;
this->luaDialog = new LuaConsoleDialog(this);
this->luaDialog->show();
luaDialog = new LuaConsoleDialog(this);
luaDialog->show();
connect(emuThread,&EmuThread::signalLuaSaveState,this,&MainWindow::onLuaSaveState);
connect(emuThread,&EmuThread::signalLuaLoadState,this,&MainWindow::onLuaLoadState);
}
Expand Down
8 changes: 4 additions & 4 deletions tools/LuaScripts/LuaScriptTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
-- Written by NPO197

MelonClear()
MelonPrint("This text Should be cleared")
print("This text Should be cleared")
MelonClear()

MelonPrint("Running Test...")
print("Running Test...")

u32Data = Readu32(0x00000000)
MelonPrint(string.format("DataZero: %x",u32Data))
print(string.format("DataZero: %x",u32Data))

canvas = MakeCanvas(0,0,500,500)
SetCanvas(canvas)
Expand Down Expand Up @@ -109,7 +109,7 @@ function KeysText()
if pcall(string.char,i) then
str = str..string.char(i)
else
MelonPrint("NonAscii:"..i)
print("NonAscii:"..i)
typed = ""
end
end
Expand Down
5 changes: 2 additions & 3 deletions tools/LuaScripts/Lua_Docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ end

## Function List

`nil MelonPrint(sPrintText)`
`nil print(sPrintText)`
- Print `sPrintText` to the lua consol
- for now use this instead of `print()`

`nil MelonClear()`
- Clearse the lua consol
- Clearse the consol in the lua dialog window.

`n_u8Value Readu8(nAddress)`
- Read Data unisigned one Byte from u32 address `nAddress`
Expand Down

0 comments on commit b16912a

Please sign in to comment.