Coder Social home page Coder Social logo

takaaptech / colyseus.lua Goto Github PK

View Code? Open in Web Editor NEW

This project forked from colyseus/colyseus.lua

0.0 2.0 0.0 312 KB

LUA/CoronaSDK client for Colyseus MMO Game Server

Home Page: https://luarocks.org/modules/endel/colyseus

License: MIT License

Lua 99.78% JavaScript 0.22%

colyseus.lua's Introduction

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

CoronaSDK/LUA client for colyseus - a Minimalistic MMO 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, "leaved", 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

Watchers

 avatar  avatar

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.