PDA

View Full Version : Object LOOP Plugin



Imagine Programming
03-07-2010, 12:38 AM
Hi all, I'm releasing a new plugin, this plugin allows you to
use the AMS Object functions in a L-OOP (Lua Object Oriented Programming)
syntax.

Plugin Name: Object

Description:

This is a plugin for Autoplay Media Studio

This plugin allows you to preform actions on the AMS objects in a more
pure-lua and object oriented form. The plugin contains all AMS functions for
object ins OOP form. A few extra functions are added, these are
only listed in the helpfile, because the Action Dialog displays the functions
incorrectly. Only Object:Create is listed in the Action dialog.

Make sure to read the helpfile about the extra functions and their usage,
the usage for all native functions can be found in the AMS helpfile, for that
object.

Additional Information:

The extra functions are not the only extra functions
future versions of this plugin may contain a quite expanded
list of extra functions. If you wish to suggest a function, mail
to Imagine Programming using the contact form. Make sure, when
you want to suggest a function, to suffix the message with:
Suggestion for Imagine Object Plugin.

You could also reply to this thread.


Credits:
Centauri Soldier, for reminding me to check if an object exists! :p :yes

Extra information, download link and full function list:
Imagine Object Plugin (http://www.imagine-programming.com/Product/14/)


I must say, it was a load of work lol! 220 functions...

Please report bugs and suggestions, thanks!


*Edit, lol I just noticed 1990 lines of code went into this project, how ironic, that's my birthyear!

Centauri Soldier
03-07-2010, 01:27 AM
Man, that's a lot of functions! I'm gonna be in that help file for a few hours I guess. Well, I've been looking forward to trying this out since you first mentioned it. I can't wait to see what it can do. Thanks for sharing with the rest of us, IP. :yes:D

Imagine Programming
03-07-2010, 02:14 AM
Man, that's a lot of functions! I'm gonna be in that help file for a few hours I guess. Well, I've been looking forward to trying this out since you first mentioned it. I can't wait to see what it can do. Thanks for sharing with the rest of us, IP. :yes:D

No problem mate! I intended to to this ages ago but stuff kept getting between me and this :p I finally started and finished it!

By the way, the helpfile only tells you about none-AMS functions, if you need help for a certain AMS object function, use the AMS helpfile :)

One function is not documented in the helpfile, Object:RestoreOriginalRect, this function restores the size and position of the object which is the size and position the object had from the moment you created the Object handle :)

Got any suggestions for functions? I'll work FadeOut, FadeIn in for the Imageobject later.

Sakuya
03-07-2010, 02:58 AM
It's about time people started releasing free plugins again, and it's also about time people started using Object Orientated Programming in Lua!

Nice.

EDIT: Just looked over this and, wow. These append functions and ToggleEnabled/ToggleVisible are great.

Imagine Programming
03-07-2010, 03:06 AM
It's about time people started releasing free plugins again, and it's also about time people started using Object Orientated Programming in Lua!

Nice.

EDIT: Just looked over this and, wow. These append functions and ToggleEnabled/ToggleVisible are great.

Thank you, yes indeed, I'd love to see more L-OOP over here, that's why I will release the plugin's source eventually. First I want to see how popular L-OOP is on these forums, and I want to update the plugin a couple of times to add new functions.

I should add a note about Object:Append, it does work on the RichText object,
but only without formatting. So, when you use Object:Append on the RichText, formatting will be ignored.

Object:SetText and Object:GetText do work with formatting for RichText, same as RichText.Set/GetText.

Sakuya
03-07-2010, 03:12 AM
Thank you, yes indeed, I'd love to see more L-OOP over here, that's why I will release the plugin's source eventually. First I want to see how popular L-OOP is on these forums, and I want to update the plugin a couple of times to add new functions.

I should add a note about Object:Append, it does work on the RichText object,
but only without formatting. So, when you use Object:Append on the RichText, formatting will be ignored.

Object:SetText and Object:GetText do work with formatting for RichText, same as RichText.Set/GetText.

Now we only need stuff like this..


local Image1 = Object:Create("Image1");

Image1.ImageFile = _SourceFolder.."\\Images\\Background.png";
Image1.Opacity = 50;
Image1.TooltipText = "Your background.";
Image1.Visible = true;
Image1.Enabled = false;

-- maybe because lua can't detect these changes straight away..
Image1:SaveChanges();

Then AutoPlay Media Studio can take over the world!

Imagine Programming
03-07-2010, 03:23 AM
Now we only need stuff like this..


local Image1 = Object:Create("Image1");

Image1.ImageFile = _SourceFolder.."\\Images\\Background.png";
Image1.Opacity = 50;
Image1.TooltipText = "Your background.";
Image1.Visible = true;
Image1.Enabled = false;

-- maybe because lua can't detect these changes straight away..
Image1:SaveChanges();

Then AutoPlay Media Studio can take over the world!

That's actually possible, try:


tImage1 = {};
tImage1.ImageFile = _SourceFolder.."\\Images\\Background.png";
tImage1.Opacity = 50;
tImage1.TooltipText = "Your background.";
tImage1.Visible = true;
tImage1.Enabled = false;

Image1 = Object:Create("Image1", tImage1, OBJECT_IMAGE);



And don't forget about Object:SetProperties ^^

But I'll probably be able to work that in somehow, perhaps using a subtable
like:

local Image1 = Object:Create("Image1");

Image1.PropsOnTheFly.ImageFile = _SourceFolder.."\\Images\\Background.png";
Image1.PropsOnTheFly.Opacity = 50;
Image1.PropsOnTheFly.TooltipText = "Your background.";
Image1.PropsOnTheFly.Visible = true;
Image1.PropsOnTheFly.Enabled = false;

Image1:SaveChanges();

and here comes the interesting part, I could even set the subtable's index to a function that automatically updates the properties when the table is modified! But that'll require some work though, rather much I'm affraid.

Imagine Programming
03-07-2010, 10:15 AM
Support for Grid.GetCellState (thanks riz) added and helpfile updated.
See first post for link.

Imagine Programming
03-08-2010, 03:03 PM
34 Downloads and 148 views, so, tell me what you think about L-OOP programming, wishes for future AMS plugins in L-OOP and something about this plugin...

RizlaUK
03-08-2010, 03:19 PM
wishes for future AMS plugins in L-OOP

i want a plugin that freezes time so i can get some D.A.M work done :p

i havent looked at this yet, i will do tho, just when i find time, im trying to get my plugins back out there but things keep happening, phone rings, door knocks, kids cry, misses talks!!, just cant get any peace!! and cant concentrate with no NICOTINE AGRRRRRR :D

(iv done 2 packets of gum today.....my jaw hurts, but im smoke free lol)

Imagine Programming
03-08-2010, 03:54 PM
i want a plugin that freezes time so i can get some D.A.M work done :p

i havent looked at this yet, i will do tho, just when i find time, im trying to get my plugins back out there but things keep happening, phone rings, door knocks, kids cry, misses talks!!, just cant get any peace!! and cant concentrate with no NICOTINE AGRRRRRR :D

(iv done 2 packets of gum today.....my jaw hurts, but im smoke free lol)



local RizlaUK = NewPersonHandler("D.H.");
local hTime = TimeHandler();
hTime:Freeze();
while(RizlaUK:Busy())do
hTime:EnsureFrozen();
RizlaUK:GetWorkDone(WORK_PLENTY);
end


hehe

Wow, kudos for not smoking mate! I envy that mental strength XD
Well, get some work done! No hehe just kidding, can you even concentrate with kids around you? :p

RizlaUK
03-08-2010, 04:38 PM
can you even concentrate with kids around you?

NO, why you think my plugins have so many bugs :D

lol, its the not smoking is why i cant concentrate, if i had a ciggy id be ok, but, im not giving in now, i'll just have to get used to it!!

Does this feeling ever go away, anxiety i think, but cant work out why!!

Imagine Programming
03-08-2010, 05:02 PM
NO, why you think my plugins have so many bugs :D

lol, its the not smoking is why i cant concentrate, if i had a ciggy id be ok, but, im not giving in now, i'll just have to get used to it!!

Does this feeling ever go away, anxiety i think, but cant work out why!!

It will go away, eventually it'll all turn into frustration on a level you would love to pull off your nails, and pull out your hair (as described by a few)... But then, when you make it through those stages, you won't ever need a cigarette again ^^

I don't think this was a motivational message, but it should have been :p

Imagine Programming
03-08-2010, 09:41 PM
UPDATE

As in, information about the next update.

As Sakuya suggested, in the next version there will be a On the fly properties
modification system. After hours of research and coding, I have put together
a system in this plugin, where SetProperties could be discarded!

Code sample, tested and it works:


Input1 = Object:Create("Input1"); -- this object is already existing on current page/dialog
Input1.Props.Width = 200;
Input1.Props.Text = "New text, this actually works!";
Input1.Props.Height = 22;


That's it, you can edit seperate keys in the properties table just like that!
These changes will be affected right from the moment lua parses that line!

Still some testing is required, but an update will be posted on the 9th,
thanks sakuya for suggesting this!

Imagine Programming
03-08-2010, 10:19 PM
Update Online!
version 1.1, 223 functions!

Sooner as expected, but the update is online!

This system is fully working, and please do know this is only for setting
some properties. Obtaining properties is possible, but they may differ after a
function call to SetProperties.
See previous post what this new system can do.

Also 2 functions were added:

Object:FadeIn(MaxOpacity,Timeout=10) -- Fades in an imageobject
Object:FadeOut(MinOpacity, Timeout=10) -- Fades out an imageobject


Downloadlinks updated. See first post for links. An updated example is included!

__________________
Bas,
Imagine Programming (http://www.imagine-programming.com/)
iEnc Action Plugin (http://www.imagine-programming.com/Product/9/)
Object Action Plugin (http://www.imagine-programming.com/Product/14/)

RizlaUK
03-09-2010, 04:09 AM
eventually it'll all turn into frustration on a level you would love to pull off your nails, and pull out your hair

No, that REALLY dident help, Thanks for that :rolleyes

ok, today i got some time, took the day off work because the misses is ill (shes not, but my boss thinks she is :D) so hopefully i can get my bits done and look at all the new plugins

BTW, this looks really useful :yes

Imagine Programming
03-09-2010, 07:33 AM
No, that REALLY dident help, Thanks for that :rolleyes

Hehe sorry about that XD



ok, today i got some time, took the day off work because the misses is ill (shes not, but my boss thinks she is :D) so hopefully i can get my bits done and look at all the new plugins
Cool, I have 4 days off too, I should be on a 'field trip' school tried to obligate me to, but they failed. I now get to stay at home and eventually do a replacing task :p


BTW, this looks really useful :yes

Thanks, I'm really happy about the on the fly system lol :yes

Sakuya
03-10-2010, 04:08 AM
Thanks, I'm really happy about the on the fly system lol :yes

All my objects are going in my Global Functions from now on so I can call them anywhere in my script. :p

RizlaUK
03-10-2010, 04:18 AM
dose that mean you can set the text of "Input1" on "Page1" from "Button2" on "Page2" or from a dialog ???

if so that could really cut down my variable use

Sakuya
03-10-2010, 04:26 AM
dose that mean you can set the text of "Input1" on "Page1" from "Button2" on "Page2" or from a dialog ???

if so that could really cut down my variable use

Hmm, don't think so as it still uses Input.SetText which only works on one page, however if Imagine really has the patience he could append stuff to the On Preload of that page to set it when you go back to that page which is possible if you use Application.SetPageScript.

Sakuya
03-10-2010, 04:41 AM
Here's a function that'll help set Script of an object on another page, it won't set the text but I still find it quite useful.

Function:

Page.ObjectScriptBuffer = {};

function Page.SetObjectScriptEx(szPage, szObject, szEvent, szScript)
assert(type(szPage) == "string", "Argument 1 must be of type string.");
assert(type(szObject) == "string", "Argument 2 must be of type string.");
assert(type(szEvent) == "string", "Argument 3 must be of type string.");
assert(type(szScript) == "string", "Argument 4 must be of type string.");

if (Application.GetCurrentPage() == szPage) then
Page.SetObjectScript(szObject, szEvent, szScript);

return (Application.GetLastError() == 0);
else
local Index = Table.Count(Page.ObjectScriptBuffer) + 1;
Page.ObjectScriptBuffer[Index] = szScript;

Application.SetPageScript(szPage, "On Preload", Application.GetPageScript(szPage, "On Preload").."\r\n\r\n-- Shadiku was here. ^_^\r\nPage.SetObjectScript(\""..szObject.."\", \""..szEvent.."\", Page.ObjectScriptBuffer["..Index.."]);\r\n");

return (Application.GetLastError() == 0);
end
end

Example usage:

Page.SetObjectScriptEx("Page2", "Input1", "On Key", [[if (e_Key == 13) then
Dialog.Message("", "Why hello there.");
end]]);

Example attached.

Imagine Programming
03-10-2010, 10:22 AM
@Dean. I don't know actually, I havn't tested that yet, but, the properties on
the fly system does not use SetText, it uses SetProperties. So it'll try to
attempt to set the properties of the object on that page.

Maybe I'll work Sakuya's script in ^^ I havn't had time yesterday, so I'll work
on it tonight. Sakuya (Can I please use your real name, easier to type XD) also
requested I rename the .Props field to .Properties...

RizlaUK
03-10-2010, 03:12 PM
what is his real name ? (Bob) << easy to type!

Hey bas, looks like you got your return key working :p


Maybe I'll work Sakuya's script in ^^ I havn't had time yesterday, so I'll work
on it tonight.

HaHa, do you know how many times iv said that......still havent had time, lol

it would be nice if the aforementioned props thing would work, i could stop using dialog variables

Imagine Programming
03-10-2010, 05:40 PM
what is his real name ? (Bob) << easy to type!

Hey bas, looks like you got your return key working :p



HaHa, do you know how many times iv said that......still havent had time, lol

it would be nice if the aforementioned props thing would work, i could stop using dialog variables

Haha well, I'm still using the return-knob but I'm getting used to it, not strange
after 3000 lines of code just in this plugin haha :p

The props thing works, but only for objects on current page/dialogex.
The way you wish to see it is possible, but first I gotta do some other
stuff on this plugin, I still need to check if it's possible. Because, working
this onto all objectfunctions is going to be a PAIN :p

RizlaUK
03-10-2010, 05:52 PM
i kind of see the point of what IR did there, im working on a little app in PB that has 5 windows and 50+ objects on each window, the enumeration's list is huge

i love the new AC system tho, makes life soooo much less "what did i call that object!!!" if you get what i mean

Imagine Programming
03-10-2010, 05:59 PM
i kind of see the point of what IR did there, im working on a little app in PB that has 5 windows and 50+ objects on each window, the enumeration's list is huge

i love the new AC system tho, makes life soooo much less "what did i call that object!!!" if you get what i mean

Oh in PB I don't mind the number of objects, the objectID's increase, so I tend to use linked lists for objects ^^

For example the mainwindow I use


NewList MainWindow.GadgetList() ; defined structure
AddElement(MainWindow())
MainWindow()\Identifier = "CloseButton"
MainWindow()\GadgetID = ButtonGadget(#PB_Any,.....
MainWindow()\EventProc = @MainButton1()

andsoforth, I don't know, but this makes event and control handling easier for me :yes

Imagine Programming
03-10-2010, 07:42 PM
Could somebody try me the next code and tell me how
the Input object behaves?

If possible, please create a multiline input object and name it Input1
Put the next code On Show:


Input1 = Object:Create("Input1");
Input1.Props.FontColor = Math.HexColorToNumber("FFFFFF");
Input1.Props.BackgroundColor = 0;
Input1:SetAppendDelimiter("\r\n");
Input1:SetText("The Object Action Plugin, oh lord, SOME L-OOP FINALLY!");
Input1:Append("No seriously, this is pretty neet, because every");
Input1:Append("AMS objects can now be approached through a L-OOPy script!");
Input1:Append("");
Input1:Append("Oh and don't forget about the POTF system!");

please tell me how the content looks afterwards, and how
the input object behaves. Over here the exclamationmarks
show up at the beginning of the sentences and the object
turns into a right-to-left oriented object, but on some moments
it's back in left-to-right again :wow

This happened only on Input objects so far, but this is so strange...
because when I use Input1:SetProperties it doesn't do funny stuff...
while the property on the fly system also uses Input1:SetProperties!

Imagine Programming
03-10-2010, 10:12 PM
Okay, a recreation of the problem, make an object named "Input1",
make it multiline and paste the next code in the On Show event of
the page.


local function cp(s,v)
local p = Input.GetProperties("Input1");
for i, nv in p do
if(tostring(i)==tostring(s))then
p[i]=v;
end
end
Input.SetProperties("Input1", p);
end
Input1 = Object:Create("Input1");
cp("FontColor", Val("FFFFFF"));
cp("BackgroundColor", 0);
cp("X", 10);
cp("Y", 10);
cp("Width", Input1:GetSize().Width-20);
cp("Height", Input1:GetSize().Height-20);
Input1:SetAppendDelimiter("\r\n");
Input1:SetText("What the ****!");
Input1:Append("is wrong,");
Input1:Append("with me!");
Input1:Append("");
Input1:Append("http://test.com/backslash_not_behind_this_but_first_character/");


This is what I see: (See attached)

Oh, and change **** to h.e.l.l without dots in above code :p

I even tested other ways, like modifying each key seperately by statements like

if(tostring(i)=="FontColor")then
p.FontColor = v;
end
but it still failed... what the, did I find an unfindable bug or is it me?

nico210
03-10-2010, 11:14 PM
Hello everyone ! This action plugin looks pretty awesome ! But is everyone have tutorials about Object LOOP ?

Thank you in advance ! :D

Imagine Programming
03-10-2010, 11:18 PM
Hello everyone ! This action plugin looks pretty awesome ! But is everyone have tutorials about Object LOOP ?

Thank you in advance ! :D

Read the helpfile and the information from this thread.
This plugin basicly puts all AMS object related acitons
in a object oriented model. So you can now set an input's
text like this:



Input1 = Object:Create("Input1") --this object already exists on the current page/dialog.
--See the helpfile for more information about previous action.

Input1:SetText("New text!");
Input1:SetAppendDelimiter("\r\n");
Input1:Append("Each time you do this, a new rule will be added!");

Image1 = Object:Create("Image1"); --this object also exists!
Image1:FadeOut(20,10);
Image1.Props.Opacity = 50 --changes the opacity from 20 to 50


This kinda stuff, don't use the properties on the fly system for input objects just yet, it bugs out alot!

Oh by the way, there actually is an example included, check it out!
__________________
Bas,
Imagine Programming (http://www.imagine-programming.com/)
iEnc Action Plugin (http://www.imagine-programming.com/Product/9/)
Object Action Plugin (http://www.imagine-programming.com/Product/14/)

Sakuya
03-11-2010, 03:44 AM
Okay, a recreation of the problem, make an object named "Input1",
make it multiline and paste the next code in the On Show event of
the page.


local function cp(s,v)
local p = Input.GetProperties("Input1");
for i, nv in p do
if(tostring(i)==tostring(s))then
p[i]=v;
end
end
Input.SetProperties("Input1", p);
end
Input1 = Object:Create("Input1");
cp("FontColor", Val("FFFFFF"));
cp("BackgroundColor", 0);
cp("X", 10);
cp("Y", 10);
cp("Width", Input1:GetSize().Width-20);
cp("Height", Input1:GetSize().Height-20);
Input1:SetAppendDelimiter("\r\n");
Input1:SetText("What the ****!");
Input1:Append("is wrong,");
Input1:Append("with me!");
Input1:Append("");
Input1:Append("http://test.com/backslash_not_behind_this_but_first_character/");


This is what I see: (See attached)

Oh, and change **** to h.e.l.l without dots in above code :p

I even tested other ways, like modifying each key seperately by statements like

if(tostring(i)=="FontColor")then
p.FontColor = v;
end
but it still failed... what the, did I find an unfindable bug or is it me?

http://img.loldepot.com/435991f3483e8b2d8984.png

Not happening here.

Imagine Programming
03-11-2010, 09:57 AM
Thanks for testing Sakuya, I guess I'm off reinstalling AMS then :yes
I don't know wth this is, I tested this again and again, just like you
just have, and tried to get the ReadOrder from the properties... after the
first on the fly change, it changed to 1... which is strange, because it doesn't
over there.

Imagine Programming
03-11-2010, 07:55 PM
Update Online!
version 1.2, 231 functions!

I changed a few things, and Updated alot! A few functions
were added and support for POTF (Properties on the fly) is now
also active for DialogEx/Page. Check out the helpfile for a short
howto on POTF.

Changelog:

12-03-2010 Version 1,2,0,0

* Renamed: Object:Create to Object.Create
* Renamed: Properties on the fly field 'Props' to 'Properties'
* Added : Object.GetPageHandle and Object.GetDialogHandle
See helpfile on what these do!
* Added : Support for DialogEx/Page functions using Dialog/Page handle:FunctionName
* Added : Object:ClearContents, Object:SetScript, Object:GetScript
* Added : Object:Click, Object:Focus, Object:SetZOrder


Downloadlinks updated. See first post for links. An updated example is included!

__________________
Bas,
Imagine Programming (http://www.imagine-programming.com/)
iEnc Action Plugin (http://www.imagine-programming.com/Product/9/)
Object Action Plugin (http://www.imagine-programming.com/Product/14/)

RizlaUK
03-12-2010, 04:15 AM
Object.GetPageHandle

if thats doing what i think its doing, this will really help!

guess i'll go read the help file, lol

Centauri Soldier
03-12-2010, 09:48 AM
Hey IP, why not combine those two new functions into one?

Object.GetPageOrDialogHandle()
or
Object.GetWindowHandle()

Here's the code for getting the page or dialog.


if Application.GetCurrentDialog() ~= "" then
YOUR CODE FOR DIALOG
else
YOUR CODE FOR PAGE
end

Imagine Programming
03-12-2010, 03:55 PM
Hey IP, why not combine those two new functions into one?

Object.GetPageOrDialogHandle()
or
Object.GetWindowHandle()

Here's the code for getting the page or dialog.


if Application.GetCurrentDialog() ~= "" then
YOUR CODE FOR DIALOG
else
YOUR CODE FOR PAGE
end

Thanks, yes I know, Object:Create checks wether it's called from a page
or a dialog. I could add a function which does the same :)

Imagine Programming
03-12-2010, 09:50 PM
Hey IP, why not combine those two new functions into one?

Object.GetPageOrDialogHandle()
or
Object.GetWindowHandle()

Here's the code for getting the page or dialog.


if Application.GetCurrentDialog() ~= "" then
YOUR CODE FOR DIALOG
else
YOUR CODE FOR PAGE
end

By the way, this does not get a Windowhandle, it get's a new L-OOP object
for a page/dialog to change properties for that page/dialog on the fly.

Also, functions like hPage:SetObjectScript and stuff can be called like that,
but those work exactly the same as Page.SetObjectScript does. (Only from
the current page/dialog)

Anyhow, I'm going to work sakuya's script in eventually and Object:Create
will be without objectnames in later versions (it'll work with incremental
names, you don't worry about the names, they'll all be unique. This, because
then Object:SetText etc will work from other pages.)

This will take a while though, because I'd have to change 231 functions haha :yes

A small comment on your script Sakuya, I shouldn't be using On Preload
should I? I should On Show because On Preload does not always edit object's.
And I'm probably leaving a marker in the line I add, like "--[[%iObjLine%]]FunctionCall()--%LineEnd%"
So I can replace the line every time, not a new line will be added every time.

Imagine Programming
03-14-2010, 09:05 AM
Oh, has someone found the easteregg already? Hehehe :p

Imagine Programming
06-20-2010, 07:55 AM
Version 1,3,0,0 for AMS8 available, more info here:
http://www.indigorose.com/forums/group.php?do=discuss&discussionid=9

It'll be available on the AMS Directory as well, once IR has approved it.
I'll make a seperate thread to announce that later.