1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-02-15 02:20:05 +00:00

Make Lua's "exit" function a little prettier

"exit" now has a custom __tostring method, which prints an explanation
message. This is very similar to how Python achives the same
functionality:

    lua> exit
    Call exit() to exit
    lua> exit()
    > Actually leaves the REPL
This commit is contained in:
SquidDev 2019-12-29 18:49:35 +00:00
parent 041cfe91b4
commit 42f5389fb8

View File

@ -9,9 +9,10 @@ end
local bRunning = true local bRunning = true
local tCommandHistory = {} local tCommandHistory = {}
local tEnv = { local tEnv = {
["exit"] = function() ["exit"] = setmetatable({}, {
bRunning = false __tostring = function() return "Call exit() to exit" end,
end, __call = function() bRunning = false end,
}),
["_echo"] = function( ... ) ["_echo"] = function( ... )
return ... return ...
end, end,