PDA

View Full Version : FREE ACTION PLUGIN: Assert


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.

holtgrewe
03-28-2008, 07:42 AM
Hey Shadowman, a lot of work went into this, and it's very professional looking.
Your mind is obviously cranking at a much higher RPM level than mine; so I'm struggling with how I could use this assert plugin.
Do you have some examples of its use and benefits?

rexzooly
03-28-2008, 08:07 AM
Hey Shadowman, a lot of work went into this, and it's very professional looking.
Your mind is obviously cranking at a much higher RPM level than mine; so I'm struggling with how I could use this assert plugin.
Do you have some examples of its use and benefits?

I also would like to see a example will mirror this with all the details later tonight
or tomorrow.

ShadowUK
03-28-2008, 11:50 AM
Hey Shadowman, a lot of work went into this, and it's very professional looking.
Your mind is obviously cranking at a much higher RPM level than mine; so I'm struggling with how I could use this assert plugin.
Do you have some examples of its use and benefits?

Example Project attached to this post.

holtgrewe
03-28-2008, 12:22 PM
Thanks for taking the time to create the examples. Interesting concept.

ShadowUK
03-30-2008, 03:19 AM
No problem, I understand that most people would not understand what this plugin actually does, But now the example shows functions in progress so maybe more people will use it.

ShadowUK
03-30-2008, 04:39 AM
Ok, then. I've made an easy to use installer this time. All you need to do is give it your path to the AMS path, For example. C:/Program Files/AutoPlay Media Studio 7.0

Download:
http://www.flameounch.com/Install/Assert.exe

rexzooly
03-30-2008, 08:44 AM
Ok, then. I've made an easy to use installer this time. All you need to do is give it your path to the AMS path, For example. C:/Program Files/AutoPlay Media Studio 7.0

Download:
http://www.flameounch.com/Install/Assert.exe

I will give Screen Shot the installer and update your mirror profile later :)

:yes

rexzooly
03-30-2008, 08:55 AM
Dose the installer edit the lua file or do you still need edit this?

:yes

ShadowUK
03-30-2008, 09:21 AM
Dose the installer edit the lua file or do you still need edit this?

:yes

The installer edits the lua file automatically.

rexzooly
03-30-2008, 09:32 AM
The installer edits the lua file automatically.

Mirror:
http://jonny6.pap3rback.net/AMS/?page=ShadowUK#2

ShadowUK
03-30-2008, 10:05 AM
Thanks. Also, "The requested URL /AMS/push/ShadowUK/Assert.exe was not found on this server."

rexzooly
03-30-2008, 10:15 AM
Thanks. Also, "The requested URL /AMS/push/ShadowUK/Assert.exe was not found on this server."

oops i moved the link but not the files lol fixed in a sec or 2 :yes

//////////EDIT////////////////////

Fixed :)

lyrad
05-08-2008, 12:58 AM
I cannot download the Assert.exe file, it said file is not found.
:huh

rexzooly
05-08-2008, 03:05 PM
All downloads have been moved to Amsmirrors.co.nr

rexzooly
05-08-2008, 03:11 PM
Here is the main Page for the download.
http://amsmirrors.co.nr/download.php?view.11

thetford
06-01-2008, 09:52 AM
I take it this action plugin is for version 7 only? I downloaded your .apz & the .exe installer. AMS 6 won't open the .apz file & the installer doesn't copy any files. Is there a version for AMS 6 users?

Thanks
Mike

rexzooly
06-01-2008, 04:01 PM
I take it this action plugin is for version 7 only? I downloaded your .apz & the .exe installer. AMS 6 won't open the .apz file & the installer doesn't copy any files. Is there a version for AMS 6 users?

Thanks
Mike

i think its just the APZ that was made in 7 the plugin dose work in 6 well it did
when i had it installed.:yes

ShadowUK
06-02-2008, 12:41 AM
I take it this action plugin is for version 7 only? I downloaded your .apz & the .exe installer. AMS 6 won't open the .apz file & the installer doesn't copy any files. Is there a version for AMS 6 users?

Thanks
Mike

http://ams.luacom.net/assert.zip

Instructions included.

thetford
06-14-2008, 01:04 PM
Much thanks, now if I can figure out how to use it! ;) Anyone have any AMS 6 examples??

Thanks again,
Mike

qwerty
02-20-2009, 08:25 PM
http://ams.luacom.net/assert.zip

Instructions included.

i'm also looking to try this in AMS6, but cant tell from this reply if the zip file linked has anything different to the 1st post (non installer version) or if it is version 6 specific... but, the link is dead for me :(


does anyone have a copy of this they could upload please

bule
02-21-2009, 03:41 PM
A small hint for you Shadow:

This code:
function Assert.IsBoolean(Value)
if (type(Value) == "boolean") then
return true
else
return false
end
end

Can be written more efficiently like this:
function Assert.IsBoolean(Value)
return (type(Value) == "boolean")
end

Other functions that are similar can be modified as well.

bule
02-21-2009, 03:45 PM
Also, there is a bug in this function:
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

local Instances = Instances + 1 should be without local directive (the variable was already declared as a local variable in the function, what you do here is that you declare a new local variable which becomes void the moment you leave the if block).

Imagine Programming
02-21-2009, 04:27 PM
Also, there is a bug in this function:
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

local Instances = Instances + 1 should be without local directive (the variable was already declared as a local variable in the function, what you do here is that you declare a new local variable which becomes void the moment you leave the if block).
In other words, it always returns 0

ShadowUK
02-22-2009, 03:21 AM
I remember writing this when I was 12. Good times, Good times..

If noone wants to release it from their own copy I'll have to rewrite it.

qwerty
02-22-2009, 06:36 AM
I remember writing this when I was 12. Good times, Good times..

:rolleyes


If noone wants to release it from their own copy I'll have to rewrite it.
i hope someone still has it :)