[PLUGIN] Zack0Wack0's Construct 2 Plugins

0 favourites
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Source code available on Github

    Changelog

    07/01/12

    Socket: Upgraded socket.io version. Writing a tutorial.

    19/09/11

    Sockets: Fixed to work with the API changes.

    WebSockets: Now supports the new mozilla version of WebSockets. It's probably going to screw up compatibility on the server side, but if you have a good server it should be able to work with both of them.

    Storage: Fixed to work with the API changes.

    09/08/11

    Socket: Messages are now stored in a data stack to prevent packet loss.

    Plugins

    Socket (Cross-browser version) - Download

    <img src="http://dl.dropbox.com/u/551734/dev/c2/plugins/socket-io1.png" border="0">

    The cross-browser version of the Socket plugin is powered by socket.io, which is a JavaScript library that aims to allow real-time streaming web connections for all browsers that it can. Socket.IO first tries with WebSockets, if they're not supported then it tries Flash sockets (which are basically the same as WebSockets - asynchronous, and fast - however not supported by Construct due to not being able to bundle resources) which are usually supported by every browser because practically every one has Flash. If Flash isn't supported then it tries XHR multiparting, which is a way to make XMLHTTPRequests (ie. AJAX) stream connections. If even that isn't supported, it then tries JSONP polling and XHR polling.

    Socket.IO needs a custom server. The default server is built in node.js, which is actually server-side JavaScript (and powered by the same engine that Construct uses for JavaScript). I would highly suggest using this version of socket.io, as it works perfectly. You can see a list of Socket.IO servers here, at the bottom of the page, and there's pretty much a server for all the good networking supported programming languages (perl, ruby, python, java, etc).

    If you want to use node.js (suggested), then you will need to install it and then install the socket.io module via the command line (npm comes when you install node.js):

    npm install socket.io
    

    There is an example server and client inside the zip file. You can also read the quick tutorial linked in the tutorials section below.

    Socket (WebSocket version) - Download

    <img src="http://dl.dropbox.com/u/551734/dev/c2/plugins/socket-websocket1.png" border="0">

    The WebSocket version of the Socket plugin works using WebSockets, a new HTML5 standard. Unfortunately WebSockets support has been dropped by Firefox and Opera because the specification was flawed, so this version only works in Google Chrome and WebKit based browsers. You can enable WebSockets by command line though, if you want to play around with it in other browsers, google it.

    Obviously due to the fact that this is a socket you need a server on the other side to communicate with. This version of the Socket plugin supports normal WebSocket servers. If you google 'WebSocket server' you'll find a server that works in a language that you like, and then you can program the server-side stuff. You won't be able to make a server as easily as you can make a game in construct, you'll have to put in hard code.

    I've included an example .capx in the download. This example connects to the echo.websocket.org server, which sends back anything that you send towards it. When the 'Echo test' message pops up (at least it should if its working), that means that the echo.websocket.org server has sent back the 'Echo test' message that the socket in the example sends towards it.

    NOTE: DON'T USE THIS UNLESS YOU HAVE TO. The specifications for WebSockets are very dodgy, and this is only here for people who really-must use WebSockets with a pure WebSocket server for some strange reason. The cross browser version of the plugin is much better.

    Storage - Download

    The Storage plugin allows you to store data in the browser. There are two places to store the data: Session Storage, which is available in your current HTTP session; and Local Storage which is available forever (or until the user clears there browser cache, as far as I know).

    The 'Store * data' actions take a key and the value to store. The key is simple something to remember the data by so you can use the data later. The value is a value, simply.

    The '* Storage supported' conditionals are to check whether the browser supports each storage type. You'll find a large majority of browsers that support the HTML5 Canvas support HTML5 DOM Storage, therefore any browser that can render Construct 2 games will support this plugin.

    The '* data exists' conditionals are to check whether the key has data set to something in the storage.

    The 'Get * data' expressions allow you to fetch data from storage. They take the key which is the key that you used to set the value originally.

    NOTE: This is deprecated. This was implemented as an official plugin, so there's no point downloading it.

    Installation

    Simply extract the file into your plugins directory, by default at C:\Program Files\Construct 2\exporters\html\plugins.

    Tutorials

    TODO

  • Awesome! Thanks for sharing Zack0Wack0

  • Great work! I was going to write a storage plugin at some point, but you beat me to it. Well done!

  • Thanks, I really like the new plugin system.

    I have some more ideas that I'll make:

    Box2D physics (I already implemented this in my game engine so I know what to do)

    Run time image manipulation (again, done this before)

    I also really want to help with the engine

  • Thanks, I really like the new plugin system.

    I have some more ideas that I'll make:

    Box2D physics (I already implemented this in my game engine so I know what to do)

    Run time image manipulation (again, done this before)

    I also really want to help with the engine

    That's good news. Was worried we wouldn't get something like the image manipulator.

    Now if we could get something like distort map with z heights....

  • Hi, thanks for the plugin.

    I have a question:

    Can I put a variable in key, so i can storage automatically a set of data?

    In this case, an array.

    Edit: Nevermind, I alredy did it. Thanks again.

    If i have lucky, by the end of the day i will present to you one of the first games made with C2 with game savings options.

    Edit2: Wow, alredy made the save system, and it store the 24336 pieces of data of the array that contains the whole world in 20 seconds!!!

    Edit3: Look how is going: Enter the game, pres new, then, wait a few seconds and press S in your keyboard. When it finish, reload the game. Then enter to saved and watch.

    Go to the project

  • Also, I forgot to mention the maximum amount of space the storage can hold. 5mb for most browsers (Chrome, Firefox, Opera, Safari, etc) and 10mb for Internet Explorer 8 - 10.

  • I just use like 23kb and it looks like a huge ammount of data, so temporally i think that 5mb is enough.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well, I'm unable to edit the OP, so I'll just put this here.

    Socket (WebSocket version) - Download 1

    <img src="http://dl.dropbox.com/u/551734/dev/c2/plugins/socket-websocket1.png" border="0">

    The WebSocket version of the Socket plugin works using WebSockets, a new HTML5 standard. Unfortunately WebSockets support has been dropped by Firefox and Opera because the specification was flawed, so this version only works in Google Chrome and WebKit based browsers. You can enable WebSockets by command line though, if you want to play around with it in other browsers, google it.

    Obviously due to the fact that this is a socket you need a server on the other side to communicate with. This version of the Socket plugin supports normal WebSocket servers. If you google 'WebSocket server' you'll find a server that works in a language that you like, and then you can program the server-side stuff.

    I've included an example .capx in the download. This example connects to the echo.websocket.org server, which sends back anything that you send towards it. When the 'Echo test' message pops up (at least it should if its working), that means that the echo.websocket.org server has sent back the 'Echo test' message that the socket in the example sends towards it.

    Socket (Cross-browser version) - Download 1

    <img src="http://dl.dropbox.com/u/551734/dev/c2/plugins/socket-io1.png" border="0">

    The cross-browser version of the Socket plugin is powered by socket.io, which is a JavaScript library that aims to allow real-time streaming web connections for all browsers that it can. Socket.IO first tries with WebSockets, if they're not supported then it tries Flash sockets (which are basically the same as WebSockets - asynchronous, and fast) which are usually supported by every browser because practically every one has Flash. If Flash isn't supported then it tries XHR multiparting, which is a way to make XmlHTTPRequests (ie. AJAX) stream connections. If even that isn't supported, it then tries JSONP polling and XHR polling.

    Unfortunately, Socket.IO has a rather limited amount of servers you can use. I suggest Tornadio, which is an extension of the Python module tornado. Its the module I used to write the test echo server in. The server.py file is also available in the download. You should note, that in order for Flash sockets to work, there also needs to be a flashpolicy.xml file with the server which has been included as well.

    You can see a list of Socket.IO servers here, at the bottom of the page, and there's pretty much a server for all the good networking supported programming languages (perl, ruby, python, java, etc). The default server is written in node.js which is a really nice server-sided implementation of JavaScript for server-networking, it's also using the same JavaScript engine, v8, as Construct 2 (I think..). I had to use version 0.6 of Socket.IO due to the fact that the new version doesn't work too well with Tornadio.

    I'm not too sure about Flash sockets as well, I believe that they will work however if you can't get them to work try including the WebSocket Flash (.swf) files included in the download.

    All in all, it should work nicely. I've written a multi-player game before with the Socket.IO library and I got it working in Opera. If there are any issues with this version, just post them here and I'll try and fix them.

  • Once again, I'm unable to edit my posts, so I'll just double post.

    I've started the Physics behavior, see the really (broken) test here.

    There's a few problems currently, I also need some engine changes from Ashley.

    1. You'll notice as you click (spawning new objects) the physics processes speed up. This is because I can't get my head around the logic to make it tween properly.

    2. In order for me to continue with this, I need onDestroy functions (so I can remove the rigidbody from the box2d world) and a way to move the box2d body when the object's position and angle are changed from events. These aren't available in the engine at the moment.

  • Zack0Wack0, you are officially a god amongst men.

  • Zack0Wack0

    Is your avatar a picture of you dressed as a dog ?

    ... definitely a little wacko <img src="smileys/smiley4.gif" border="0" align="middle" />

  • , these are awesome. I'll get those changes in to the engine for the next build.

  • Zack, you should be able to edit posts now. The new forum set it to 30 min limit, it's off now.

  • Hopefully this helps:

    To get the time passed for this tick, use

    ar dt = this.runtime.getDt(this.inst);

    dt is the time, in seconds, that the physics simulation should advance. That should keep the speed steady no matter the framerate.

    To get a callback when an instance is destroyed:

    I just remembered there's already a function for this, because other parts of the runtime need it. Call

    untime.addDestroyCallback(function(inst) { alert(inst.toString()); });

    and it will alert the instance ID whenever something is destroyed.

    To get a callback when an instance is moved or rotated:

    There's nothing for this right now, but for the next build I've added a method for instances:

    nstance.add_bbox_changed_callback(function(inst) { alert(inst.toString()); });

    This will alert the instance ID whenever its bounding box is changed (x, y, width, height or angle is changed). Try to only add one callback and only for instances that really need it, because otherwise it'll add unnecessary overhead.

    Hope that helps, let me know if there's anything else you need!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)