Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.
/ colyseus.lua Public archive

(DEPRECATED) LUA/CoronaSDK client for Colyseus Multiplayer Game Server (v0.3.x). Use colyseus-defold instead.

License

Notifications You must be signed in to change notification settings

colyseus/colyseus.lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

(DEPRECATED) LUA/CoronaSDK client for Colyseus Multiplayer Game Server (v0.3.x). Use colyseus-defold instead.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages