ShadowUK
03-27-2008, 03:46 PM
This is a remake of the Assert plugin I recently released, I've put it here for more popularity and because now it has all the code in the New Action wizard.
This is my first Action Plugin that actually works so please download it and use it in your applications.
To install the actions into AutoPlay Media Studio:
Open My Computer.
Navigate to Program Files in the drive you installed AutoPlay Media Studio in.
Open the folder called 'AutoPlay Media Studio'.
Go to the Data folder.
Open the Actions folder.
Copy this file (http://www.flameounch.com/ActionPlugins/_at_Assert.xml) into that folder.
You should now have this:
http://img132.imageshack.us/img132/528/assertkk8.png
But we're not done yet! Now to add the functions and core code.
Browse to AutoPlay Media Studio/Data/Includes and open the file: _notification_messages.lua
Add some lines for extra space at the bottom then copy the following code:
--[[
Plugin Name: Assert Function Set
Plugin Author: ShadowUK
Plugin Version: 1.0a
--]]
Assert = {};
function Assert.ToString(Value)
return assert(tostring(Value))
end
function Assert.RunString(String)
return assert(loadstring(String))()
end
function Assert.ToNumber(Value)
return assert(tonumber(Value))
end
function Assert.IsNumber(Value)
if (type(Value) == "number") then
return true
else
return false
end
end
function Assert.IsBoolean(Value)
if (type(Value) == "boolean") then
return true
else
return false
end
end
function Assert.IsString(Value)
if (type(Value) == "string") then
return true
else
return false
end
end
function Assert.IsTable(Value)
if (type(Value) == "table") then
return true
else
return false
end
end
function Assert.IsFunction(Value)
if (type(Value) == "function") then
return true
else
return false
end
end
function Assert.DoesExsist(Value)
if (type(Value) == "nil") then
return false
else
return true
end
end
function Assert.CopyTable(SourceTable)
return SourceTable
end
function Assert.PopulateTable(SourceTable, NumberValues, StringToPopulate)
for i = 1, NumberValues do
SourceTable[i] = StringToPopulate
end
end
function Assert.CycleTable(SourceTable, CallbackFunction)
for k, v in pairs(SourceTable) do
CallbackFunction(k, v)
end
end
function Assert.Count(From, To, Callback)
for count = From, To do
Callback(count, To)
end
end
function Assert.KillProcessTree(ProcessHost)
for j, file_path in (System.EnumerateProcesses()) do
if (String.Lower(String.SplitPath(file_path).Filename ..String.SplitPath(file_path).Extension) == ProcessHost) then
System.TerminateProcess(j);
end
end
end
function Assert.IsProcessRunning(Process)
local Instances = 0;
for j, file_path in Window.EnumerateProcesses() do
if (String.Lower(String.SplitPath(file_path).Filename ..String.SplitPath(file_path).Extension) == Process) then
local Instances = Instances + 1
end
end
return Instances
end
function Assert.GetOSDate()
return os.date("%x")
end
function Assert.GetLongTime()
return os.time()
end
function Assert.IncludeScriptFolder(FolderPath)
for k, v in pairs(File.Find(FolderPath, "*.lua", false, false, nil, nil)) do
Application.RunScriptFile(v)
end
end
function Assert.RecurseScriptFolders(FolderPath)
for k, v in pairs(File.Find(FolderPath, "*.lua", true, false, nil, nil)) do
Application.RunScriptFile(v)
end
end
Save the file and you're done! Ready to release!
I notice this is a very hacky way but if anyone else has an idea on how to automatically include the file without the user having to put files inside the scripts folder then use globals code, I'd like to hear it.
This is my first Action Plugin that actually works so please download it and use it in your applications.
To install the actions into AutoPlay Media Studio:
Open My Computer.
Navigate to Program Files in the drive you installed AutoPlay Media Studio in.
Open the folder called 'AutoPlay Media Studio'.
Go to the Data folder.
Open the Actions folder.
Copy this file (http://www.flameounch.com/ActionPlugins/_at_Assert.xml) into that folder.
You should now have this:
http://img132.imageshack.us/img132/528/assertkk8.png
But we're not done yet! Now to add the functions and core code.
Browse to AutoPlay Media Studio/Data/Includes and open the file: _notification_messages.lua
Add some lines for extra space at the bottom then copy the following code:
--[[
Plugin Name: Assert Function Set
Plugin Author: ShadowUK
Plugin Version: 1.0a
--]]
Assert = {};
function Assert.ToString(Value)
return assert(tostring(Value))
end
function Assert.RunString(String)
return assert(loadstring(String))()
end
function Assert.ToNumber(Value)
return assert(tonumber(Value))
end
function Assert.IsNumber(Value)
if (type(Value) == "number") then
return true
else
return false
end
end
function Assert.IsBoolean(Value)
if (type(Value) == "boolean") then
return true
else
return false
end
end
function Assert.IsString(Value)
if (type(Value) == "string") then
return true
else
return false
end
end
function Assert.IsTable(Value)
if (type(Value) == "table") then
return true
else
return false
end
end
function Assert.IsFunction(Value)
if (type(Value) == "function") then
return true
else
return false
end
end
function Assert.DoesExsist(Value)
if (type(Value) == "nil") then
return false
else
return true
end
end
function Assert.CopyTable(SourceTable)
return SourceTable
end
function Assert.PopulateTable(SourceTable, NumberValues, StringToPopulate)
for i = 1, NumberValues do
SourceTable[i] = StringToPopulate
end
end
function Assert.CycleTable(SourceTable, CallbackFunction)
for k, v in pairs(SourceTable) do
CallbackFunction(k, v)
end
end
function Assert.Count(From, To, Callback)
for count = From, To do
Callback(count, To)
end
end
function Assert.KillProcessTree(ProcessHost)
for j, file_path in (System.EnumerateProcesses()) do
if (String.Lower(String.SplitPath(file_path).Filename ..String.SplitPath(file_path).Extension) == ProcessHost) then
System.TerminateProcess(j);
end
end
end
function Assert.IsProcessRunning(Process)
local Instances = 0;
for j, file_path in Window.EnumerateProcesses() do
if (String.Lower(String.SplitPath(file_path).Filename ..String.SplitPath(file_path).Extension) == Process) then
local Instances = Instances + 1
end
end
return Instances
end
function Assert.GetOSDate()
return os.date("%x")
end
function Assert.GetLongTime()
return os.time()
end
function Assert.IncludeScriptFolder(FolderPath)
for k, v in pairs(File.Find(FolderPath, "*.lua", false, false, nil, nil)) do
Application.RunScriptFile(v)
end
end
function Assert.RecurseScriptFolders(FolderPath)
for k, v in pairs(File.Find(FolderPath, "*.lua", true, false, nil, nil)) do
Application.RunScriptFile(v)
end
end
Save the file and you're done! Ready to release!
I notice this is a very hacky way but if anyone else has an idea on how to automatically include the file without the user having to put files inside the scripts folder then use globals code, I'd like to hear it.