Corroder Grandmaster Cheater Supreme
Reputation: 75 Joined: 10 Apr 2015 Posts: 1668
|
Posted: Sat Mar 03, 2018 2:17 am Post subject: Implementing Lua Scripting To Creating CE Mp3 Player |
|
|
In connection to these topics :
http://forum.cheatengine.org/viewtopic.php?t=584021
http://forum.cheatengine.org/viewtopic.php?t=606901
which already answerd by the 'play MP3 sound in CE function' creator : mgr.inz.Player
as also knew as ones most respected Cheat Engine / CEF users.
So, the fisrt thing I want to do is to thank so much to mgr.inz.Player and also Dark Byte as
Cheat Engine creator.
Form those topics above, I have created a 'Simple MP3 Player' by followed 'play MP3 sound in CE function'
including added and modified some functions and use pure Cheat Engine Lua scripting.
My goal by doing this project is for learning purpose and more than it is to prove and show if CE not only use
for memory hacking, it also can use for other purpose, specially for Lua scripting.
The project as below :
--================================================================--
-- Project name : CRDR-MP3Player-Ver.4.0
-- Creator : Corroder a.k.a VCLBro
-- Created date : 28-02-2018
-- Scripting Language : Lua 5.3 compatible Lua 5.1, Lua 5.2
-- Scripting IDE : CE 6.7 Lua Engine
-- Special thanks to : mgr.inz.Player, Dark Byte, CEF Members
-- Purpose : Learning, show CE not only use for hack
--================================================================--
-- Note :
-- 1.All Form GUI on this project made use Lua Scripting
-- 2.GUI Images and Icons, has store as stream files
-- 3.Some notes has added inside script code for references
-- 4.NOT FOR COMMERCIAL USE
--================================================================--
What inside this project ? :
A. Work with Lua Table
1.Function to save and load lua table to a file
Code: | do
local function exportstring( s )
s = string.format( "%q",s )
s = string.gsub( s,"\\\n","\\n" )
s = string.gsub( s,"\r","\\r" )
s = string.gsub( s,string.char(26),"\"..string.char(26)..\"" )
return s
end
function table.save( tbl,filename )
local charS,charE = " ","\n"
local file,err
if not filename then
file = { write = function( self,newstr ) self.str = self.str..newstr end, str = "" }
charS,charE = "",""
elseif filename == true or filename == 1 then
charS,charE,file = "","",io.tmpfile()
else
file,err = io.open( filename, "w" )
if err then return _,err end
end
local tables,lookup = { tbl },{ [tbl] = 1 }
file:write( "return {"..charE )
for idx,t in ipairs( tables ) do
if filename and filename ~= true and filename ~= 1 then
file:write( "-- Table: {"..idx.."}"..charE )
end
file:write( "{"..charE )
local thandled = {}
for i,v in ipairs( t ) do
thandled[i] = true
if type( v ) ~= "userdata" then
if type( v ) == "table" then
if not lookup[v] then
table.insert( tables, v )
lookup[v] = #tables
end
file:write( charS.."{"..lookup[v].."},"..charE )
elseif type( v ) == "function" then
file:write( charS.."loadstring("..exportstring(string.dump( v )).."),"..charE )
else
local value = ( type( v ) == "string" and exportstring( v ) ) or tostring( v )
file:write( charS..value..","..charE )
end
end
end
for i,v in pairs( t ) do
if (not thandled[i]) and type( v ) ~= "userdata" then
if type( i ) == "table" then
if not lookup[i] then
table.insert( tables,i )
lookup[i] = #tables
end
file:write( charS.."[{"..lookup[i].."}]=" )
else
local index = ( type( i ) == "string" and "["..exportstring( i ).."]" ) or string.format( "[%d]",i )
file:write( charS..index.."=" )
end
if type( v ) == "table" then
if not lookup[v] then
table.insert( tables,v )
lookup[v] = #tables
end
file:write( "{"..lookup[v].."},"..charE )
elseif type( v ) == "function" then
file:write( "loadstring("..exportstring(string.dump( v )).."),"..charE )
else
local value = ( type( v ) == "string" and exportstring( v ) ) or tostring( v )
file:write( value..","..charE )
end
end
end
file:write( "},"..charE )
end
file:write( "}" )
if not filename then
return file.str.."--|"
elseif filename == true or filename == 1 then
file:seek ( "set" )
return file:read( "*a" ).."--|"
else
file:close()
return 1
end
end
function table.load( sfile )
local tables, err, _
if string.sub( sfile,-3,-1 ) == "--|" then
tables,err = loadstring( sfile )
else
tables,err = loadfile( sfile )
end
if err then return _,err
end
tables = tables()
for idx = 1,#tables do
local tolinkv,tolinki = {},{}
for i,v in pairs( tables[idx] ) do
if type( v ) == "table" and tables[v[1]] then
table.insert( tolinkv,{ i,tables[v[1]] } )
end
if type( i ) == "table" and tables[i[1]] then
table.insert( tolinki,{ i,tables[i[1]] } )
end
end
for _,v in ipairs( tolinkv ) do
tables[idx][v[1]] = v[2]
end
for _,v in ipairs( tolinki ) do
tables[idx][v[2]],tables[idx][v[1]] = tables[idx][v[1]],nil
end
end
return tables[1]
end
end |
2.Get a table length
Code: | function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end |
3.Clearing / empty a table
Code: | function clearTable(tb)
for i, v in pairs(tb) do
tb[i] = nil
end
end
-- [table] = {} also use to clear a table, but in fact with this function but in fact the table still store a nil value
|
B. Function to convert seconds to time format HH:MM:SS or 00:00:00
Code: | function SecondsToClock(seconds)
local seconds = tonumber(seconds)
if seconds <= 0 then
return "00:00:00";
else
hours = string.format("%02.f", math.floor(seconds/3600));
mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)));
secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60));
return hours..":"..mins..":"..secs
end
end |
C. Other functions or and logics to create custom GUI, etc
What about this CRDR-MP3Player-Ver.4.0 player ?
1. Common mp3 player functions : Play, Stop, Resume, Pause
2. Added : Mute / Un-mute volume
3. Added : Filtering mp3 files when browsing on PC/Extrnal storage
4. Added : Created mp3 songs playlist which editable and save
5. Added : Automatic load last saved songs playlist
6. Added : Option to play single song or play songs shuffle
7. Added : Song info when playing -> Title, Path, Duration, File Size
8. Added : Song play elapsed time with custom progress bar
9. Added : MP3 player skin theme selector
10. Added : Loud speaker control -> Balance, Left/Right Volume, Bass/Treble Volume
On future update (plan) :
- Added 'media seek = fast forward / back'
- Added 'sound visualization'
Download Source Code (CT file) :
https://mega.nz/#!Xw8FVZAB!cUOGWWogAvdB5Xxv8XzgSCZcfJDiYVV7Y6JZUPHqQSs
NOTE 2 :
This project is not perfect, it's possible contain some error (I hope not). Anyhow, if you think you can create better then goes on,
then use this project as your motivation.
Even I can do same thing like this using other programming language such as VB, C++ and others but
the main purpose from this project is to prove and show if CE is not iuse for hacking only.
It's more than it if on right hands...
EDIT : 18/03/2018
CRDR-MP3 Player V.5
https://youtu.be/pwBsDrFQEic
Download source code / CT file CRDR-MP3-Player-V5:
https://mega.nz/#!jtkjmQ7Z!_DC-ri1R_CEMQN-mkTBgzH1celOtwBf97GMrxZ_Nc8c
Also if you want play MIDI file format, add this :
Code: | function playMID(path)
if not initializeMP3Player() then return end
MP3PlayerSendCommand('close midifile')
MP3PlayerSendCommand(string.format('open "%s" type sequencer alias midifile',path))
MP3PlayerSendCommand('play midifile')
end |
To play WMA file format (example with openDialog to locate wma file)
Code: | function playWMA() -- work
if not initializeMP3Player() then return end
load_dialog = createOpenDialog(self)
load_dialog.InitalDir = os.getenv('%USERPROFILE%')
-- load_dialog.Filter = 'MP3 files|*.mp3|*'
load_dialog.Filter = 'Audio files|*.mp3;*.mid;*.wav;*.wma|Mp3 files (*.mp3)|*.MP3|Mid files (*.mid)|*.MID|Wav files (*.wav)|*.WAV|Wma files (*.wma)|*.WMA|*'
load_dialog.execute()
local file = load_dialog.FileName
s_file = string.sub(file, -4)
print(s_file)
if s_file == '.wma' then
MP3PlayerSendCommand('play '..file)
else
print('not WMA file...')
end
end |
Cheers...
Corroder _________________ Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Last edited by Corroder on Thu Mar 15, 2018 4:01 am; edited 3 times in total
|
|