That's why im posting it here!

So, this should copy one file, and put it in another, right?
Code: Select all
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
function widget:GetInfo()
return {
name = "Music Switcher",
desc = "Switches the music playlist of AF's Music AI",
author = "url_00",
date = "04 Aug 2007",
license = "GNU GPL, v2 or later",
layer = 1,
enabled = false -- loaded by default?
}
end
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
function widget:Initialize()
if io.open("../music/music.tdf", "w") == nil
print("Error loading music.tdf! Check your paths!")
else
local music = assert(io.open("../music/music.tdf", "w"))
end
if io.open("../music/gutar/music.tdf", "r") == nil
print("Error loading gutar's music.tdf! Check your paths!")
else
local gutar = assert(io.open("../music/gutar/music.tdf", "r"))
end
if io.open("../music/def/music.tdf", "r") == nil
print("Error loading default music! Check your paths!")
else
local def = assert(io.open("../music/def/music.tdf", "r")
end
end
-------------------------------
function Say(msg)
Spring.SendCommands({'say ' .. msg})
end
function echo(msg)
Spring.SendCommands({"echo " .. msg})
end
-------------------------------
local choice = ''
function widget:TextCommand(cmd)
if cmd == 'gutar' then
choice = cmd
Refresh(choice)
echo("Gutar music loaded.")
else
choice = def
Refesh(choice)
echo("Error loading music! Check your paths!")
end
end
function Refresh(file)
local count = 1 -- reads the file, line by line
while true do
local line = file:io.read()
if line == nil then break end
music:io.write(line,"\n") -- writes the file, line by line
count = count + 1
end
end
-------------------------------------------------------------------------------------
Will it work?