[1.2] Algodoo Mod System Now has Network Plugin!

About programs, games and other things related to Algodoo and Phun.

[1.2] Algodoo Mod System Now has Network Plugin!

Postby ags131 » Sun Nov 06, 2011 11:29 pm

Algodoo Mod System
by ags131

This is a plugin system I have wrote in VB.NET. It is capable of receiving and sending commands to/from algodoo using thyme. It has been tested with and requires 2.0.2b15 and will NOT operate on older versions (Use 1.0 for older versions).

1.0 uses the same method used by all previous interfaces such as externet, reading the logfile. In fact, it would be simple to implement something like externet. Done! See AMSNetPlugin!

1.1 uses the new system.WriteToFile function in 2.0.2 b15 and later to avoid the difficult hooking that 1.0 is forced to use.

Download 1.0 (1.9.9 and up): http://dl.dropbox.com/u/10471884/Algodoo%20Mod%20System.zip
Download 1.2 (2.0.2b15 and up): http://db.tt/iqsjvt3u

NOTE: Some plugins are not included in 1.2 yet. I will add them once I get them updated. A few things changed in 1.1 that made it much easier to write plugins.
The only currently included plugins are AMS Net Plugin (Added in 1.2) and AMSSoundMod, play sound from within algodoo with the following functions:
Code: Select all
scene.AMS.musicplay("PATH\\TO\\MUSIC\\FILE");
scene.AMS.musicstop();
scene.AMS.sndplay("PATH\\TO\\SOUND\\FILE");
NOTE: The alias are only in the AMS Intro scene, the connecter by default does NOT add alias.
Use scene.AMS.send("musicplay","PATH\\TO\\MUSIC\\FILE") and similar for any other scenes.


Current Plugins:
Sound Mod (Included)
Spoiler: show
NOTE: This doesnt have a GUI like the other plugins.
It can play most common formats, (MP3,Wav,Ogg,etc)
Now supports music! See AMS Intro Scene in download for details.

Portex Programmer (Included)
Spoiler: show
You can write any Portex program in the Portex Programmer plugin.
Programs use same format as in Algodoo except without '[', ',' and ']'.
Ex: In algodoo: [["SET",0, "Hello World!"],["HALT"]]
In Portex Programmer:
set 0 "Hello World!"
halt
Portex Programmer can also import portex programs in thyme array format, simply paste into Portex Programmer and click the third toolstrip button.
The send via AMS button sets scene.AMS.portex variable in Algodoo to a thyme version of the program.
Note: Commands such as SET can be either lowercase or upper. AMS automatically adjusts it as needed.

Net Plugin (WIP) (Included)
Spoiler: show
A simple client/server system that I'm currently integrating with AMS as a plugin, Once complete, You will be able to easily send simple data between different PCs running Algodoo using thyme! It uses TCP so It will be possible to connect even over the internet.


Want to write your own plugin?
To write your own plugin, simply create a new class library, add a reference to AMSPluginSystem, and implement IPlugin. After compiling, copy the resulting DLL to the Plugins folder of AMS. (NOTE: Project must be compiled for .NET 2.0! (3.5 or lower for v1.1 and up) Otherwise your plugin will NOT be loaded!) Thats it! The console will show that your plugin has been loaded.

1.0 Info
Spoiler: show
I have included the source for Portex Programmer in the download.
Commands can be sent to AMS by using any undefined function in scene.AMS EX: scene.AMS.hello("world") to send the value of a variable, use scene.AMS.send(com,var) EX:
{
data="Hello World"
scene.AMS.send("test",data")
}
Would be the same as calling scene.AMS.test("Hello World")
See the AMS console to see how AMS sees the commands.

NOTE: AMS will not be able to receive information from Algodoo unless it starts Algodoo itself. To do that, Algodoo must be installed in one of the following folders: (They are the default installation folders.)
C:\Program Files\Algodoo
C:\Program Files (x86)\Algodoo (For 64bit OS)


1.1 Info
Spoiler: show
Commands can be sent to AMS by using the scene.AMS.send() function.
Usage is: scene.AMS.send("funtionName",["array","of","parameters"])
Example (For AMSSoundMod):
Try this in a ball's onCollide :)
(e)=>{
sound=@"C:\Windows\Media\Windows Default.wav";
scene.AMS.send("sndplay",sound")
}
Last edited by ags131 on Sat May 19, 2012 5:07 pm, edited 5 times in total.
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby Mystery » Mon Nov 07, 2011 2:00 pm

Neat, now someone make an external sound mod.
User avatar
Mystery
 
Posts: 2802
Joined: Thu Sep 03, 2009 1:16 pm
Location: Southern Australia

Re: Algodoo Mod System

Postby Chronos » Mon Nov 07, 2011 3:02 pm

Mystery wrote:Neat, now someone make an external sound mod.

ಠ_ಠ
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: Algodoo Mod System

Postby ags131 » Mon Nov 07, 2011 7:06 pm

Chronos wrote:
Mystery wrote:Neat, now someone make an external sound mod.

ಠ_ಠ

I thought you two were making one? :D

Ive got a working network system now, Trying to isolate a bug where the buffer isnt being cleared at the moment.
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby Sonic » Mon Nov 07, 2011 9:32 pm

This is awesome! Finally we have modding in Algodoo! Now I can add my long wanted feature of stickyness.
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: Algodoo Mod System

Postby ags131 » Mon Nov 07, 2011 10:04 pm

I now have a simple sound plugin for AMS. :D
It can play most common formats, (MP3,Wav,Ogg,etc)
Place this in the onCollide event of a ball. :)
Code: Select all
geval("scene.AMS.sndplay(\"C:\\\\Windows\\\\Media\\\\WIndows Default.wav\")")


(Sound Plugin is in the download now)
I also added the Net Plugin I'm working on, it currently works but has a bug where it doesnt clear the buffer of previous messages. :S
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby ags131 » Tue Nov 08, 2011 3:42 am

UPDATE: Added a AMS Intro scene to demonstrate sound in AMS and to give a quick Introduction to AMS usage.
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby ags131 » Wed Nov 09, 2011 4:04 am

Anyone tried it? Any bugs/suggestions? Ideas for future plugins? If anyone is interested in making a plugin in either C# or VB, I will help you In any way I can. :)
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby cdh473 » Sat Jan 21, 2012 6:22 am

Sonic wrote:This is awesome! Finally we have modding in Algodoo! Now I can add my long wanted feature of stickyness.

We've had modding in algodoo, even had it for Phun before algodoo came out. Remember that SmartSnap thing I wrote in Python? That wasn't built-in.

Anyways, I'm glad you guys have gotten back to working on this, I would help if I had more time.
Please excuse my posts. I am extremely stupid.
User avatar
cdh473
 
Posts: 816
Joined: Tue Sep 01, 2009 12:37 am
Location: Yes

Re: Algodoo Mod System

Postby ags131 » Sat Jan 21, 2012 7:05 am

I haven't done much since my last post, I'll work on this more if people are interested :)
IIRC, I had a working network plugin and a simple sound plugin
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby ags131 » Sat May 19, 2012 3:46 am

UPDATE!
I have updated AMS to version 1.1!
New Features:
Uses new system.WriteToFile() function in Algodoo 2.0.2b15 therefore removing the need for it to hook algodoo in any way. Thanks Emil! :clap:
Updated Interfaces to make coding plugins easier
Updated AMSSoundMod to work a little better. Sound is perfectly syncronized with Algodoo now :D

Please leave comments and let me know what you like, dislike, want added, or even plugin requests. :)
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby tatt61880 » Sat May 19, 2012 5:10 am

ags131 wrote:UPDATE!
I have updated AMS to version 1.1!
New Features:
Uses new system.WriteToFile() function in Algodoo 2.0.2b15 therefore removing the need for it to hook algodoo in any way. Thanks Emil! :clap:
Updated Interfaces to make coding plugins easier
Updated AMSSoundMod to work a little better. Sound is perfectly syncronized with Algodoo now :D

Please leave comments and let me know what you like, dislike, want added, or even plugin requests. :)


Great! :clap:

Is it possible to remove next error message?
Cannot find identifier "AMS" in ""

This message is shown when "AMS Intro.phz" is opened.

EDIT:
== How to reproduce ==
1. Open "AMS Intro.phz"
2. Sim.running = true
3. Close Algodoo.
4. Open "AMS Intro.phz" again.

Regards,
Tatt
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Algodoo Mod System

Postby ags131 » Sat May 19, 2012 5:13 am

Hmm... not sure where thats being triggered... All actual ams code should be in the laser. There may be remnents from previous partially operational versions though
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby tatt61880 » Sat May 19, 2012 5:19 am

ags131 wrote:Hmm... not sure where thats being triggered... All actual ams code should be in the laser. There may be remnents from previous partially operational versions though

I've added "How to reproduce" in previous post. ;)
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Algodoo Mod System

Postby ags131 » Sat May 19, 2012 5:21 am

Ahh thanks :)

Edit:
It looks like it may be an Algodoo bug, some reason, Scene and Scene.AMS is being serialized to the config.
I'm not sure how to prevent the error unless there is a way to create custom objects without using a laser or geom. (EX: not having to do scene.AMS=e.laser)
Then it should serialize without problem...

It's annoying when stuff thats not supposed to serialize serializes to config :/

I also went ahead and updated AMS Intro as I had forgotten to update the text. And I fixed the music stop which wasn't working. Ignore any warnings in AMS console saying "Cold not open sound file: C:\path\to\AMS\STOP"
Thats because using a blank string or non-existant file triggers a stop and since it now prepends the AMS directory to the audio file, if none is specified, my IF preventing the error fails :/
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby tatt61880 » Sat May 19, 2012 12:04 pm

Scene.newVariablename is not supported officially (Scene.my.newVariablename is OK, but Scene.my.foo.bar is not OK ), I think.

Btw, when I executed AlgodooModSystem.exe, it executed all files which existed task in Algodoo/AMS folder. These files are created by Algodoo when AMS was not working. I don't think it's good to execute them.
Is it possible to ignore them?
Regards,
Tatt
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: Algodoo Mod System

Postby ags131 » Sat May 19, 2012 3:55 pm

Yes, that should be an easy fix, I'll just have AMS clear the folder on startup.

If anyone can come up with a better and more versatile method of getting the data into Algodoo from AMS then please share!
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: Algodoo Mod System

Postby ags131 » Sat May 19, 2012 4:51 pm

Just updated AMS Net Plugin :) Will be uploading it shortly It is included in the 1.2 build :), here is a screenshot of it in action:
Image

There is a server built into the plugin, but I was also testing usage with an external server :)
I will be including both the standalone server and client with the plugin :)

New in 1.2:
Fixed bug where AMS would execute files created while AMS was closed. (Thanks tatt61880!)
Updated NetPlugin and fixed the bug where buffer wasn't clearing.
Added NetPlugin to main package
Added Standalone Net server and client (Both are fully compatible with NetPlugin
Added NetPlugin test scene
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: [1.2] Algodoo Mod System Now has Network Plugin!

Postby tatt61880 » Sun May 20, 2012 1:52 am

I don't think zDepth is needed.
(Current AMS) wrote:Scene.AMS.send
(com, data)=>{
l.zDepth = l.zDepth + 1;
file = "AMS\\" + sim.time + "" + l.zDepth + ".out";
system.writetofile(file, sim.time + "\n" + com + "\n" + data)
}


Next code has smaller overhead, in my opinion.
(My suggestion) wrote:Scene.AMS.send
(com, data)=>{
l.zDepth = l.zDepth + 1;
file = "AMS\\" + sim.time + ".out";
system.writetofile(file, sim.time + "\n" + com + "\n" + data + "\n")
}


Regards,
Tatt
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: [1.2] Algodoo Mod System Now has Network Plugin!

Postby ags131 » Sun May 20, 2012 2:39 am

Originally I didn't use zDepth, but when the functions are called rapidly, (Such as from a laser) Sim.time doesn't change and it starts appending to already created files. AMS considers everything after the first two lines as function arguments. I just haven't figured out a good way of handling the Thyme side yet... :/

And I'm looking into that bug report you sent, electronicboy said it worked fine for him, then screwed something up that prevented him from doing anything to the AMS folder... I'll check more when I'm back home and not on my laptop.
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: [1.2] Algodoo Mod System Now has Network Plugin!

Postby tatt61880 » Sun May 20, 2012 3:06 am

ags131 wrote:Originally I didn't use zDepth, but when the functions are called rapidly, (Such as from a laser) Sim.time doesn't change and it starts appending to already created files. AMS considers everything after the first two lines as function arguments. I just haven't figured out a good way of handling the Thyme side yet... :/

The code which I suggested works fine for me.

ags131 wrote:And I'm looking into that bug report you sent, electronicboy said it worked fine for him, then screwed something up that prevented him from doing anything to the AMS folder... I'll check more when I'm back home and not on my laptop.

The issue doesn't occur when AMS folder is empty when you executed AlgodooModSystem.exe
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: [1.2] Algodoo Mod System Now has Network Plugin!

Postby ags131 » Sun May 20, 2012 5:19 am

tatt61880 wrote:The code which I suggested works fine for me.


The code you posted works, BUT if a large amount of functions are called at once it tends to write 2 or more to one file. AMS is only capable of reading the first function in each file.
A normal file looks something like this:
Code: Select all
23.129999 (Sim.time)
musicplay
shore.ogg


A "bugged" file where it writes faster than sim.time changes:
Code: Select all
25.24999
sndplay
C:\Windows\Media\Windows Default.wav
25.24999
sndplay
C:\Windows\Media\Windows Default.wav
25.24999
sndplay
C:\Windows\Media\Windows Default.wav


In the second one only the first entry is processed. (That is an actual example from the bouncing balls)
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: [1.2] Algodoo Mod System Now has Network Plugin!

Postby tatt61880 » Sun May 20, 2012 6:04 am

ags131 wrote:
tatt61880 wrote:The code which I suggested works fine for me.


The code you posted works, BUT if a large amount of functions are called at once it tends to write 2 or more to one file. AMS is only capable of reading the first function in each file.
A normal file looks something like this:
Code: Select all
23.129999 (Sim.time)
musicplay
shore.ogg


A "bugged" file where it writes faster than sim.time changes:
Code: Select all
25.24999
sndplay
C:\Windows\Media\Windows Default.wav
25.24999
sndplay
C:\Windows\Media\Windows Default.wav
25.24999
sndplay
C:\Windows\Media\Windows Default.wav


In the second one only the first entry is processed. (That is an actual example from the bouncing balls)

Is it difficult to handle bugged file with next version of AMS? :angel:
I've added "\n" for the purpose.
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: [1.2] Algodoo Mod System Now has Network Plugin!

Postby ags131 » Sun May 20, 2012 6:19 am

Hmmm.. Possibly...
What do you think is the best way for thyme to be able to pass multiple parameters?
Currently every line after the function name is one.
I'm thinking about a format like below to account for the bugged files.
It would allow all functions in a bugged file to be processed.
Code: Select all
sim.time
Function Name
parameter count
parameter1
parameter2
etc


Im thinking, that for multi-parameter functions, I will make the plugin register functions.
Ex:
Plugin calls
registerFunction("functionName",parameterCount) (Will use 3 as parameterCount in this example
then AMS creates a function like this with thyme:
Code: Select all
scene.my.functionName=(param1,param2,param3)=>{
   system.writeToFile(sim.time+".out",sim.time+"\nfunctionName\n3\n"+param1+"\n"+param2+"\n"+param3+"\n";
}


Any Ideas/thoughts on this? Technically, with this system, I can remove all the scene.ams code except runonce (Which again, could be registered by AMS when it starts)
ags131
 
Posts: 71
Joined: Thu Oct 29, 2009 4:14 pm

Re: [1.2] Algodoo Mod System Now has Network Plugin!

Postby electronicboy » Sun May 20, 2012 4:04 pm

Your method for plugin calls seams okay, Best method really considering how algodoos functions can only be called with as many parameters as its wrote to take.

I am working on the Algodoo side of runonce code, I have a concept involving AMS counting how many commands have been sent, algodoo recieving that value and processing the code using a counter and the number of send commands.
I will reply once I manage look at it!
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm


Return to Algodoo related

Who is online

Users browsing this forum: No registered users and 4 guests