PDA

View Full Version : Free: Group Action Plugin


Centauri Soldier
07-16-2009, 08:12 PM
I compiled the Group code written by RizlaUK in a plugin for ease of use. So here it is.

JDog37
07-16-2009, 08:29 PM
Thanks guys. :yes:yes:yes

Y'know allot of times, people should take the time out and say thank you. You guys really do kick some major a**! Without you, Non-coders would be really, really lost.

I just thought I'd say that,

Peace,
Joe

RizlaUK
07-17-2009, 04:51 AM
Wrong version!

i was going to release this myself, but as you have already done it you might as well add the extra functions, no need for the same plugin twice, also the code (original group action code) is not really plugin compatible

heres my version
--################################################## ################################################## #####
-- IRLUA PLUGIN HELPER FUNCTIONS
--################################################## ################################################## #####
_ShowErrorEventContext=false-- set this to false to disable 'EventContext' display
--################################################## ################################################## #####
-- Sets a Global error message in the runtime engine.
local IRLUA_PLUGIN_SetGlobalErrorMessage = function(nCode, sMessage)
if _tblErrorMessages[nCode] then
if _ShowErrorEventContext then
local sEventContext=Debug.GetEventContext()
error("Error code "..nCode.." already in use, please use another.\r\n\r\nEventContext: "..sEventContext,2)
else
error("Error code "..nCode.." already in use, please use another.",2)
end
else
_tblErrorMessages[nCode]=sMessage
end
end
--################################################## ################################################## #####
-- Checks the number of arguments in the table nd throws a syntax error If there are Not enough.
-- This is useful For checking the number of arguments available To your aciton.
local IRLUA_PLUGIN_CheckNumArgs = function(tbArgs,nArgs)
local nCount=table.getn(tbArgs)
if nCount < nArgs then
if _ShowErrorEventContext then
local sEventContext=Debug.GetEventContext()
error(nArgs.." Arguments expected, "..nCount.." Arguments passed.\r\n\r\nEventContext: "..sEventContext,3)
else
error(nArgs.." Arguments expected, "..nCount.." Arguments passed.",3)
end
end
end
--################################################## ################################################## #####
-- Checks the value at a given argument table position To see If it is a string.
-- If Not it throws a syntax error.
local IRLUA_PLUGIN_CheckString = function(tbArgs,nArg)
local sType=type(tbArgs[nArg])
if sType ~= "string" then
if _ShowErrorEventContext then
local sEventContext=Debug.GetEventContext()
error("bad argument #" .. nArg .. ", must be a string, you passed a "..type(tbArgs[nArg])..".\r\n\r\nEventContext: "..sEventContext,3)
else
error("bad argument #" .. nArg .. ", must be a string, you passed a "..type(tbArgs[nArg])..".",3)
end
else
return tbArgs[nArg]
end
end
--################################################## ################################################## #####
-- Checks the value at a given argument table position To see If it is a number.
-- If Not, it tries To convert it To a number. this is to save use of "tonumber" and "String.ToNumber" while retriveing your functions arguments.
-- If it can't convert it To a number it throws a syntax error.
local IRLUA_PLUGIN_CheckNumber = function(tbArgs,nArg)
local sType=type(tbArgs[nArg])
if sType ~= "number" then
if tonumber(tbArgs[nArg]) then
return tonumber(tbArgs[nArg]);
else
if _ShowErrorEventContext then
local sEventContext=Debug.GetEventContext()
error("bad argument #" .. nArg .. ", must be a number, you passed a "..type(tbArgs[nArg])..".\r\n\r\nEventContext: "..sEventContext,3)
else
error("bad argument #" .. nArg .. ", must be a number, you passed a "..type(tbArgs[nArg])..".",3)
end
end
else
return tbArgs[nArg]
end
end
--################################################## ################################################## #####
-- Checks the value at a given argument table position To see If it is a boolean,.
-- If not it throws a syntax error and exits the function.
local IRLUA_PLUGIN_CheckBoolean = function(tbArgs,nArg)
local sType=type(tbArgs[nArg])
if sType ~= "boolean" then
if _ShowErrorEventContext then
local sEventContext=Debug.GetEventContext()
error("bad argument #" .. nArg .. ", must be a boolean, you passed a "..type(tbArgs[nArg])..".\r\n\r\nEventContext: "..sEventContext,3)
else
error("bad argument #" .. nArg .. ", must be a boolean, you passed a "..type(tbArgs[nArg])..".",3)
end
else
return tbArgs[nArg]
end
end
--################################################## ################################################## #####
-- Checks the value at a given argument table position To see If it is a function.
-- If not it throws a syntax error and exits the function.
local IRLUA_PLUGIN_CheckFunction = function(tbArgs,nArg)
local sType=type(tbArgs[nArg])
if sType ~= "function" then
if _ShowErrorEventContext then
local sEventContext=Debug.GetEventContext()
error("bad argument #" .. nArg .. ", must be a function, you passed a "..type(tbArgs[nArg])..".\r\n\r\nEventContext: "..sEventContext,3)
else
error("bad argument #" .. nArg .. ", must be a function, you passed a "..type(tbArgs[nArg])..".",3)
end
else
return tbArgs[nArg]
end
end
--################################################## ################################################## #####
-- Checks the value at a given argument table position To see If it is a thread.
-- If not it throws a syntax error and exits the function.
local IRLUA_PLUGIN_CheckThread = function(tbArgs,nArg)
local sType=type(tbArgs[nArg])
if sType ~= "thread" then
if _ShowErrorEventContext then
local sEventContext=Debug.GetEventContext()
error("bad argument #" .. nArg .. ", must be a thread, you passed a "..type(tbArgs[nArg])..".\r\n\r\nEventContext: "..sEventContext,3)
else
error("bad argument #" .. nArg .. ", must be a thread, you passed a "..type(tbArgs[nArg])..".",3)
end
else
return tbArgs[nArg]
end
end
--################################################## ################################################## #####
-- Checks the value at a given argument table position To see If it is a userdata.
-- If not it throws a syntax error and exits the function.
local IRLUA_PLUGIN_CheckUserData = function(tbArgs,nArg)
local sType=type(tbArgs[nArg])
if sType ~= "userdata" then
if _ShowErrorEventContext then
local sEventContext=Debug.GetEventContext()
error("bad argument #" .. nArg .. ", must be a userdata, you passed a "..type(tbArgs[nArg])..".\r\n\r\nEventContext: "..sEventContext,3)
else
error("bad argument #" .. nArg .. ", must be a userdata, you passed a "..type(tbArgs[nArg])..".",3)
end
else
return tbArgs[nArg]
end
end
--################################################## ################################################## #####
-- END IRLUA PLUGIN HELPER FUNCTIONS
--################################################## ################################################## #####
--[[************************************************** ******]]--
--[[ Set up a table to reference the objects in AMS ]]--
--[[************************************************** ******]]--
local tbObjectType = {}
tbObjectType[OBJECT_BUTTON] = Button;
tbObjectType[OBJECT_LABEL] = Label;
tbObjectType[OBJECT_PARAGRAPH] = Paragraph;
tbObjectType[OBJECT_IMAGE] = Image;
tbObjectType[OBJECT_FLASH] = Flash;
tbObjectType[OBJECT_VIDEO] = Video;
tbObjectType[OBJECT_WEB] = Web;
tbObjectType[OBJECT_INPUT] = Input;
tbObjectType[OBJECT_HOTSPOT] = Hotspot;
tbObjectType[OBJECT_LISTBOX] = ListBox;
tbObjectType[OBJECT_COMBOBOX] = ComboBox;
tbObjectType[OBJECT_PROGRESS] = Progress;
tbObjectType[OBJECT_TREE] = Tree;
tbObjectType[OBJECT_RADIOBUTTON] = RadioButton;
tbObjectType[OBJECT_RICHTEXT] = RichText;
tbObjectType[OBJECT_CHECKBOX] = CheckBox;
tbObjectType[OBJECT_SLIDESHOW] = SlideShow;
tbObjectType[OBJECT_GRID] = Grid;
tbObjectType[OBJECT_PLUGIN] = Plugin;
--[[************************************************** ******]]--
--[[ Group Actions ]]--
--[[************************************************** ******]]--
local m_tblGroup = {};
Group = {};
--################################################## #################################################
Group.AddItem = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,2)
local sObjectName=IRLUA_PLUGIN_CheckString(arg,1)
local sGroupName=IRLUA_PLUGIN_CheckString(arg,2)

local nIndex = Table.Count(m_tblGroup) + 1;
Table.Insert(m_tblGroup, nIndex, {})
m_tblGroup[nIndex].Group = sGroupName;
m_tblGroup[nIndex].Object = sObjectName;
m_tblGroup[nIndex].ObjectType = Page.GetObjectType(sObjectName);

end
--################################################## #################################################
Group.RemoveItem = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,2)
local sObjectName=IRLUA_PLUGIN_CheckString(arg,1)
local sGroupName=IRLUA_PLUGIN_CheckString(arg,2)

for i in m_tblGroup do
if m_tblGroup[i].Group == sGroupName and m_tblGroup[i].Object == sObjectName then
Table.Remove(m_tblGroup, i);
break;
end
end
end
--################################################## #################################################
Group.SetVisible = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,2)
local sGroupName=IRLUA_PLUGIN_CheckString(arg,1);
local bVisible=IRLUA_PLUGIN_CheckBoolean(arg,2);

local bRedraw=false
if arg[3] then
bRedraw=true
end

Application.SetRedraw(bRedraw)
for i in m_tblGroup do
if m_tblGroup[i].Group == sGroupName then
local Object = tbObjectType[m_tblGroup[i].ObjectType];
if Object.SetVisible then
local Name = m_tblGroup[i].Object
Object.SetVisible(Name, bVisible)
end
end
end
Application.SetRedraw(true)
end
--################################################## #################################################
Group.SetEnabled = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,2)
local sGroupName=IRLUA_PLUGIN_CheckString(arg,1);
local bEnable=IRLUA_PLUGIN_CheckBoolean(arg,2);

local bRedraw=false
if arg[3] then
bRedraw=true
end

Application.SetRedraw(bRedraw)
for i in m_tblGroup do
if m_tblGroup[i].Group == sGroupName then
local Object = tbObjectType[m_tblGroup[i].ObjectType];
if Object.SetEnabled then
local Name = m_tblGroup[i].Object
Object.SetEnabled(Name, bEnable)
end
end
end
Application.SetRedraw(true)
end
--################################################## #################################################
Group.Move = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,3)
local sGroupName=IRLUA_PLUGIN_CheckString(arg,1);
local xDiff=IRLUA_PLUGIN_CheckNumber(arg,2);
local yDiff=IRLUA_PLUGIN_CheckNumber(arg,3);

local bRedraw=false
if arg[4] then
bRedraw=true
end

Application.SetRedraw(bRedraw)
for i in m_tblGroup do
if m_tblGroup[i].Group == sGroupName then
local Object = tbObjectType[m_tblGroup[i].ObjectType];
local Name = m_tblGroup[i].Object
if Object.SetPos then
Object.SetPos(Name, Object.GetPos(Name).X + xDiff, Object.GetPos(Name).Y + yDiff)
end
end
end
Application.SetRedraw(true)
end
--################################################## #################################################
Group.GetVisible = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,1)
local sGroupName=IRLUA_PLUGIN_CheckString(arg,1);

for i in m_tblGroup do
if m_tblGroup[i].Group == sGroupName then
local Object = tbObjectType[m_tblGroup[i].ObjectType];
if Object.IsVisible then
local Name = m_tblGroup[i].Object
return Object.IsVisible(Name)
end
end
end
end
--################################################## #################################################
Group.GetEnabled = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,1)
local sGroupName=IRLUA_PLUGIN_CheckString(arg,1);

for i in m_tblGroup do
if m_tblGroup[i].Group == sGroupName then
local Object = tbObjectType[m_tblGroup[i].ObjectType];
if Object.IsEnabled then
local Name = m_tblGroup[i].Object
return Object.IsEnabled(Name)
end
end
end
end
--################################################## #################################################
Group.Count = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,1)
local sGroupName=IRLUA_PLUGIN_CheckString(arg,1);

local nCount=0
for i in m_tblGroup do
if m_tblGroup[i].Group == sGroupName then
nCount=nCount+1
end
end
return nCount
end
--################################################## #################################################
Group.CreateObject = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,4)
local sObjName=IRLUA_PLUGIN_CheckString(arg,1);
local cObjType=IRLUA_PLUGIN_CheckString(arg,2);
local tbObjProps=IRLUA_PLUGIN_CheckString(arg,3);
local sGroupName=IRLUA_PLUGIN_CheckString(arg,4);

Page.CreateObject(cObjType,sObjName,tbObjProps);
local error = Application.GetLastError();
if (error ~= 0) then
return error
else
Group.AddItem(sObjName, sGroupName);
return 0
end
end
--################################################## #################################################
Group.DeleteObject = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,2)
local sObjName=IRLUA_PLUGIN_CheckString(arg,1);
local sGroupName=IRLUA_PLUGIN_CheckString(arg,2);

Group.RemoveItem(sObjName, sGroupName);
Page.DeleteObject(sObjName);
local error = Application.GetLastError();
if (error ~= 0) then
return error
else
return 0
end
end
--################################################## #################################################
Group.IsObject = function (...)

IRLUA_PLUGIN_CheckNumArgs(arg,1)
local sObjName=IRLUA_PLUGIN_CheckString(arg,1);

local strReturn = ""
for i, sGroup in m_tblGroup do
local strObject = m_tblGroup[i].Object
if strObject == sObjName then
strReturn = m_tblGroup[i].Group
break
end
end
return strReturn
end
--################################################## #################################################

Centauri Soldier
07-17-2009, 02:22 PM
I think this is all correct. I have replaced all existing code with the code you provided, Rizla and have added the new actions as well.

Version 1.1.0.0
Updated code to comply with RizlaUk's new version and format.
Added new actions:
Group.CreateObject
Group.DeleteObject
Group.IsObject

nrgyzer
08-12-2009, 10:47 AM
Great job :yes

But... when I use the following code:

Group.AddItem("Image1", "MyGroup");
Group.AddItem("Label1", "MyGroup");
Group.AddItem("Label2", "MyGroup");
Group.AddItem("HotSpot1", "MyGroup");

... and try to change the visibility or position of "MyGroup", then I get the following error:

http://ipics.biz/img/error_73g.png

nrgyzer
08-12-2009, 11:29 AM
I solved the error :lol - I renamed the label and the group-action used the old name of the labels... - sorry^^... no panic ;)

kjh
08-26-2009, 08:46 AM
Hi RizlaUK/Centauri Soldier

The following code causes errors, because the function handles all parameters as strings, - should be handled string,number, table, string

Code:
Group.CreateObject("ButCreate", OBJECT_BUTTON,tblBtnProps, "MyGroup");


Group.CreateObject = function (...)

-- Group.CreateObject("ButCreate", OBJECT_BUTTON,tblBtnProps, "MyGroup");

IRLUA_PLUGIN_CheckNumArgs(arg,4)
local sObjName=IRLUA_PLUGIN_CheckString(arg,1);
local cObjType=IRLUA_PLUGIN__CheckString(arg,2);
local tbObjProps=IRLUA_PLUGIN_CheckString(arg,3);
local sGroupName=IRLUA_PLUGIN_CheckString(arg,4);

Page.CreateObject(cObjType,sObjName,tbObjProps);
local error = Application.GetLastError();
if (error ~= 0) then
return error
else
Group.AddItem(sObjName, sGroupName);
return 0
end
end

The plugin is really usefull, so I hope you will find the time to correct the problem.

:yes Thanks anyway

Centauri Soldier
08-26-2009, 02:01 PM
Thanks for bringing that bug to my attention.

Version 1.2.0.0
Fixed an error in the Group.CreateObject() function that caused the function to not work.
Added the Group.Enum() function that returns all objects and their types from a specific group.

kjh
08-26-2009, 03:16 PM
Thanks for your fast reply and the update.:yes

I'm sorry but it seems that there is still a bug in the Group.CreateObject() function

the error message is:

line 317: attempt to call global 'IRLUA_PLUGIN_CheckTable' (a nil value)

Centauri Soldier
08-26-2009, 04:57 PM
Oops, this was using the old version of the LUA_HELPER_FUNCTIONs.

I had done the update in a hurry ten minutes before my appointment so I got sloppy. All should be well now.

kjh
08-26-2009, 10:25 PM
Thank you :yes

Centauri Soldier
09-07-2009, 05:09 PM
Version 1.3.0.0
Reorganized XML readout.
Added Group.AdjustHeight() function.
Added Group.AdjustWidth() function.
Added Group.SetHeight() function.
Added Group.SetPos() function.
Added Group.SetWidth() function.

rexzooly
09-17-2009, 09:10 AM
Has this plugin been pulled? cos the there is no download for it? also thanks to you both cos i used this before it became a plugin and it was very useful
i was hoping to use the plugin but download link at the mo.:p

Imagine Programming
09-17-2009, 11:09 AM
Has this plugin been pulled? cos the there is no download for it? also thanks to you both cos i used this before it became a plugin and it was very useful
i was hoping to use the plugin but download link at the mo.:p

The link in his name provides a website where all his stuff is hosted :)

Group Action Plugin (http://www.amspublic.com/downloads/plugins/action/group/Group%20v1.3.0.0.zip)

rexzooly
09-17-2009, 12:30 PM
The link in his name provides a website where all his stuff is hosted :)

Group Action Plugin (http://www.amspublic.com/downloads/plugins/action/group/Group%20v1.3.0.0.zip)

thanks for the link :yes when u say in his name do u mean is profile or is sig
as i don't view sigs when i am loged in.

Worm
09-17-2009, 01:06 PM
The irony of it all. You don't view them, but you have one. :eek:

rexzooly
09-17-2009, 01:08 PM
The irony of it all. You don't view them, but you have one. :eek:

I have one yes but i not sure how to turn then back on there was on day then another day they was gone soon as i login lol guess i been lazy and not looked in the CP to turn them back on. ;)

Worm
09-17-2009, 01:11 PM
I'm just messing with ya, ya know :D

rexzooly
09-17-2009, 01:12 PM
I'm just messing with ya, ya know :D

:D, :yes Are well u got me then lol hehe

Imagine Programming
09-17-2009, 01:33 PM
thanks for the link :yes when u say in his name do u mean is profile or is sig
as i don't view sigs when i am loged in.

In his signature :) The website is www.amspublic.com

Click resources > Plugins to view all CS's plugins :)