Giter Club home page Giter Club logo

colyseus.lua's Introduction

colyseus.lua Join the chat at https://gitter.im/gamestdio/colyseus

CoronaSDK/LUA client for colyseus - a Minimalist Multiplayer Game Server.

Usage

There's a sample project on coronasdk-example, which connects to a simple chat application demo.

local colyseus = require('colyseus')

local client = colyseus.connect('ws://localhost:2657');
local roomName = "room_name"
local room = client:join(roomName)

client:on('open', function()
  print("connected successfully:", client.id)
end)

room:on('join', function()
  print(client.id, "joined", roomName)
  room:send({ message = "I'm connected!" })
end)

room:on('error', function()
  print(client.id, "couldn't join", roomName)
end)

room:on('leave', function()
  print(client.id, "left", roomName)
end)

room:on('data', function(data)
  print(client.id, "received on", roomName, data)
end)

room:on('patch', function(patches)
  print(roomName, "will apply these changes:", patches)
})

room:on('update', function(newState, patches)
  print(roomName, "new state:", newState, "changes applied:", patches)
end)

Installation

You will need to let Corona play nice with luarocks, which is a powerful package manager for the LUA programming language.

  • Download and install luarocks.
  • Install luarocks package inside your source directory. (luarocks install luarocks --tree=src/luarocks)
  • Install colyseus package inside your source directory. (luarocks install colyseus --tree=src/luarocks)
  • Download and copy dmc_corona into your source directory.
  • Add openssl and bit plugins to your project. (inside build.settings file, plugins section)

Add this little piece of code at the very top of your main.lua file:

-- Integration with luarocks
package.path = string.gsub(system.pathForFile('luarocks/bin/luarocks', system.ResourceDirectory), 'bin/luarocks', '') .. 'share/lua/5.2/?.lua' .. ';' .. package.path
require("luarocks.loader")

Finally, your source directory should look like this: (only relevant files)

▾ source-files/
  ▸ luarocks/
  ▸ dmc_corona/
    dmc_corona.cfg
    dmc_corona_boot.lua
    build.settings
    main.lua

Dependencies

License

MIT

colyseus.lua's People

Contributors

endel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colyseus.lua's Issues

Error when start sample server?

When i try to start server via npm start or node index.js, it throws error:

colyseus.lua-master/server/chat_room.js:3
class ChatRoom extends Room {
^^^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:404:25)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/Users/macbook/Corona/colyseus.lua-master/server/index.js:2:16)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)

Support other LUA game engines

It would be great to support other engines such as:

  • love2d
  • defold

Some dependencies of this library are currently tied to CoronaSDK.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.