Starting to embed Lua based modules.
This commit is contained in:
parent
fd1a2951ff
commit
095835ec8c
3 changed files with 354 additions and 11 deletions
|
@ -21,7 +21,7 @@
|
|||
--]]
|
||||
|
||||
|
||||
-- Singe 2.xx Features
|
||||
-- Singe 2.xx Features -------------------------------------------------------
|
||||
|
||||
|
||||
function utilDeepCopy(orig)
|
||||
|
@ -59,14 +59,14 @@ end
|
|||
function utilGetTableSize(t)
|
||||
local count = 0
|
||||
for _, __ in pairs(t) do
|
||||
count = count + 1
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
|
||||
function utilTrim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
|
||||
|
@ -423,7 +423,7 @@ MOUSE_SINGLE = 100
|
|||
MOUSE_MANY = 200
|
||||
|
||||
|
||||
-- Singe 1.xx Features
|
||||
-- Singe 1.xx Features -------------------------------------------------------
|
||||
|
||||
|
||||
if discSetFPS ~= nil then discSetFPS(29.97) end
|
||||
|
|
332
patches/daitarn_3_singe/Script/toolbox.singe
Executable file
332
patches/daitarn_3_singe/Script/toolbox.singe
Executable file
|
@ -0,0 +1,332 @@
|
|||
--[[
|
||||
|
||||
PROGRAM NAME: LUA SINGE
|
||||
VERSION: 1.1
|
||||
AUTHOR: KARIS (2020)
|
||||
|
||||
This file is part of LUA SINGE.
|
||||
|
||||
LUA SINGE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation.
|
||||
|
||||
LUA SINGE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
Thanks to Scott Duensing, RDG.
|
||||
|
||||
]]--
|
||||
|
||||
iSecs = 0
|
||||
iLimit = 0
|
||||
lastSeconds = 0
|
||||
thisSeconds = 0
|
||||
|
||||
sprText = nil
|
||||
sprShadow = nil
|
||||
sLastText = nil
|
||||
iLastColor = -1
|
||||
iLastShadow = -1
|
||||
|
||||
tSecs = 0
|
||||
tLimit = 0
|
||||
tlastSeconds = 0
|
||||
tthisSeconds = 0
|
||||
bTommy = false
|
||||
|
||||
bGunMute = false
|
||||
iMuteFrames = 0
|
||||
MUTE_DELAY = 35
|
||||
|
||||
heartbeat = false
|
||||
blinkSecs = 0
|
||||
lastBlinkSecs = 0
|
||||
|
||||
iRevFrames = 0
|
||||
REV_DELAY = 10
|
||||
bReversePointer = false
|
||||
revsetx = 0; revsety = 0
|
||||
|
||||
iFrameStart = 0; iFrameEnd = 0
|
||||
|
||||
CHANNEL_LEFT = 1
|
||||
CHANNEL_RIGHT = 2
|
||||
ALL_CHANNELS = 3
|
||||
bMuteAttract = false
|
||||
|
||||
RED = 0
|
||||
BLUE = 1
|
||||
YELLOW = 2
|
||||
GREEN = 3
|
||||
ORANGE = 4
|
||||
WHITE = 5
|
||||
GREY = 6; GRAY = 6
|
||||
LIGHTBLUE = 7
|
||||
BLACK = 8
|
||||
|
||||
function singeRandomize()
|
||||
|
||||
math.randomseed(os.time()) -- random initialize
|
||||
math.random(); math.random(); math.random() -- warming up
|
||||
|
||||
end
|
||||
|
||||
function blinkTimer(thisMS)
|
||||
|
||||
-- Function blinks every second.
|
||||
|
||||
blinkSecs = os.clock()
|
||||
|
||||
if bPause then
|
||||
|
||||
lastBlinkSecs = blinkSecs
|
||||
|
||||
else
|
||||
|
||||
if (blinkSecs - lastBlinkSecs > thisMS) then
|
||||
heartbeat = not heartbeat
|
||||
lastBlinkSecs = blinkSecs
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function goTimer(thisMS)
|
||||
|
||||
blinkSecs = os.clock()
|
||||
|
||||
if bPause then
|
||||
|
||||
lastBlinkSecs = blinkSecs
|
||||
|
||||
else
|
||||
|
||||
if (blinkSecs - lastBlinkSecs > thisMS) then
|
||||
heartbeat = true
|
||||
lastBlinkSecs = blinkSecs
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function clockRnd()
|
||||
|
||||
local j = 0
|
||||
local q = 0
|
||||
local w = 0
|
||||
local r = 0
|
||||
local b1 = true
|
||||
|
||||
j = os.clock()
|
||||
q, w = math.modf(j)
|
||||
|
||||
s2 = tostring(w)
|
||||
r = string.find(s2,".")
|
||||
|
||||
if (r == nil) then
|
||||
|
||||
s2 = tostring(q)
|
||||
s2 = string.sub(s2,string.len(s2), string.len(s2))
|
||||
|
||||
else
|
||||
|
||||
s2 = string.sub(s2, r + 1)
|
||||
r = string.len(s2)
|
||||
|
||||
if r == 0 then
|
||||
|
||||
s2 = tostring(q)
|
||||
s2 = string.sub(s2,string.len(s2), string.len(s2))
|
||||
|
||||
|
||||
elseif r == 2 then
|
||||
|
||||
s2 = string.sub(s2, 2, 2)
|
||||
|
||||
elseif r >= 3 then
|
||||
|
||||
s2 = string.sub(s2, 3, 3)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
w = tonumber(s2)
|
||||
return w
|
||||
|
||||
end
|
||||
|
||||
function timerOFF()
|
||||
|
||||
iSecs = 0
|
||||
iLimit = 0
|
||||
|
||||
end
|
||||
|
||||
function timerON(thisLong)
|
||||
|
||||
iSecs = 0
|
||||
iLimit = thisLong
|
||||
lastSeconds = os.clock()
|
||||
|
||||
end
|
||||
|
||||
function timerDue()
|
||||
|
||||
thisSeconds = os.clock()
|
||||
|
||||
if bPause then
|
||||
|
||||
lastSeconds = thisSeconds
|
||||
|
||||
else
|
||||
|
||||
if (thisSeconds ~= lastSeconds) then
|
||||
|
||||
iSecs = iSecs + thisSeconds - lastSeconds
|
||||
lastSeconds = thisSeconds
|
||||
|
||||
end
|
||||
|
||||
if (iSecs >= iLimit) then
|
||||
|
||||
timerOFF()
|
||||
return true
|
||||
|
||||
else
|
||||
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function muteSound()
|
||||
|
||||
iMuteFrames = 0
|
||||
bGunMute = true
|
||||
|
||||
end
|
||||
|
||||
function blinkRev()
|
||||
|
||||
iRevFrames = 0
|
||||
bReversePointer = true
|
||||
|
||||
end
|
||||
|
||||
function setupClip(thisA, thisB)
|
||||
|
||||
iFrameStart = thisA
|
||||
iFrameEnd = thisB
|
||||
|
||||
discSkipToFrame(thisA)
|
||||
|
||||
end
|
||||
|
||||
function monoAudio (thisChannel)
|
||||
|
||||
if thisChannel == CHANNEL_LEFT then
|
||||
|
||||
discAudio (2, false)
|
||||
discAudio (1, true)
|
||||
|
||||
elseif thisChannel == CHANNEL_RIGHT then
|
||||
|
||||
discAudio (1, false)
|
||||
discAudio (2, true)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function resetChannels()
|
||||
|
||||
discAudio(1, true)
|
||||
discAudio(2, true)
|
||||
|
||||
end
|
||||
|
||||
function muteAudio()
|
||||
|
||||
discAudio(1, false)
|
||||
discAudio(2, false)
|
||||
|
||||
end
|
||||
|
||||
function setFontColor(thisColor)
|
||||
|
||||
if thisColor == RED then
|
||||
|
||||
colorForeground(255, 0, 0)
|
||||
|
||||
elseif thisColor == BLUE then
|
||||
|
||||
colorForeground(0, 0, 255)
|
||||
|
||||
elseif thisColor == YELLOW then
|
||||
|
||||
colorForeground(255, 255, 0)
|
||||
|
||||
elseif thisColor == GREEN then
|
||||
|
||||
colorForeground(0, 255, 0)
|
||||
|
||||
elseif thisColor == ORANGE then
|
||||
|
||||
colorForeground(255, 150, 0)
|
||||
|
||||
elseif thisColor == WHITE then
|
||||
|
||||
colorForeground(255, 255, 255)
|
||||
|
||||
elseif thisColor == GREY or thisColor == GRAY then
|
||||
|
||||
colorForeground(128, 128, 128)
|
||||
|
||||
elseif thisColor == LIGHTBLUE then
|
||||
|
||||
colorForeground(30, 160, 250)
|
||||
|
||||
elseif thisColor == BLACK then
|
||||
|
||||
colorForeground(0,0,0)
|
||||
|
||||
elseif thisColor == PINK then
|
||||
|
||||
colorForeground(252,0,148)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function textPrint(thisMsg, thisx, thisy, thisFont, thisColor, thisShadow)
|
||||
|
||||
fontSelect(thisFont)
|
||||
setFontColor(thisColor)
|
||||
fontPrint(thisx,thisy,thisMsg)
|
||||
|
||||
end
|
||||
|
||||
function getMiddle(thisPhrase)
|
||||
|
||||
local x = 0
|
||||
local y = 0
|
||||
local sprite = fontToSprite(thisPhrase)
|
||||
|
||||
x = OVLW/2 - spriteGetWidth(sprite) * 0.5
|
||||
y = OVLH/2 - spriteGetHeight(sprite) * 0.5
|
||||
|
||||
spriteUnload(sprite)
|
||||
|
||||
return x
|
||||
|
||||
end
|
25
src/singe.c
25
src/singe.c
|
@ -4409,16 +4409,17 @@ void startLuaContext(lua_State *L) {
|
|||
***TODO*** Load these Lua modules:
|
||||
|
||||
Lua Socket:
|
||||
ftp.lua
|
||||
headers.lua
|
||||
http.lua
|
||||
ltn12.lua
|
||||
mbox.lua
|
||||
mime.lua
|
||||
smtp.lua
|
||||
socket.lua
|
||||
ltn12.lua
|
||||
tp.lua
|
||||
url.lua
|
||||
ftp.lua
|
||||
mime.lua
|
||||
headers.lua
|
||||
http.lua
|
||||
|
||||
mbox.lua
|
||||
smtp.lua
|
||||
|
||||
luasec:
|
||||
https.lua
|
||||
|
@ -4426,6 +4427,16 @@ void startLuaContext(lua_State *L) {
|
|||
|
||||
librs232:
|
||||
rs232.lua
|
||||
|
||||
|
||||
--[[
|
||||
http = require("socket.http")
|
||||
http.request{
|
||||
url = "http://www.columbia.edu/~fdc/sample.html",
|
||||
sink = ltn12.sink.file(io.stdout)
|
||||
}
|
||||
--]]
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue