2014-09-19 01:10:54 +03:00
|
|
|
-- Buildat: test1/client_lua/init.lua
|
2014-09-19 14:50:25 +03:00
|
|
|
local log = buildat.Logger("test1")
|
2014-09-19 21:45:44 +03:00
|
|
|
local dump = buildat.dump
|
2014-09-19 01:10:54 +03:00
|
|
|
log:info("test1/init.lua loaded")
|
|
|
|
|
2014-09-19 21:45:44 +03:00
|
|
|
-- Test extension interface safety
|
2014-09-19 11:29:23 +03:00
|
|
|
local test = require("buildat/extension/test")
|
|
|
|
|
|
|
|
test.f()
|
|
|
|
|
2014-09-19 14:12:00 +03:00
|
|
|
-- Test some 3D things
|
|
|
|
local g3d = require("buildat/extension/graphics3d")
|
|
|
|
|
|
|
|
scene = g3d.Scene(g3d.Scene.SCENE_3D)
|
|
|
|
ground = g3d.ScenePrimitive(g3d.ScenePrimitive.TYPE_PLANE, 5,5)
|
2014-09-19 15:19:02 +03:00
|
|
|
ground:loadTexture("test1/green_texture.png")
|
2014-09-19 14:12:00 +03:00
|
|
|
scene:addEntity(ground)
|
|
|
|
|
|
|
|
scene:getDefaultCamera():setPosition(7,7,7)
|
|
|
|
scene:getDefaultCamera():lookAt(g3d.Vector3(0,0,0), g3d.Vector3(0,1,0))
|
2014-09-19 21:45:44 +03:00
|
|
|
|
|
|
|
local cereal = require("buildat/extension/cereal")
|
|
|
|
|
|
|
|
buildat.sub_packet("test1:add_box", function(data)
|
|
|
|
values = cereal.binary_input(data, {
|
|
|
|
"double", "double", "double",
|
|
|
|
"double", "double", "double"
|
|
|
|
})
|
|
|
|
local w = values[1]
|
|
|
|
local h = values[2]
|
|
|
|
local d = values[3]
|
|
|
|
local x = values[4]
|
|
|
|
local y = values[5]
|
|
|
|
local z = values[6]
|
|
|
|
log:info("values="..dump(values))
|
|
|
|
box = g3d.ScenePrimitive(g3d.ScenePrimitive.TYPE_BOX, w,h,d)
|
|
|
|
box:loadTexture("test1/pink_texture.png")
|
|
|
|
box:setPosition(x, y, z)
|
|
|
|
scene:addEntity(box)
|
2014-09-19 23:08:09 +03:00
|
|
|
|
|
|
|
data = cereal.binary_output(
|
|
|
|
{1, "Foo"},
|
|
|
|
{"byte", "string"}
|
|
|
|
)
|
|
|
|
buildat.send_packet("test1:box_added", data)
|
2014-09-19 21:45:44 +03:00
|
|
|
end)
|
|
|
|
|
|
|
|
--[[
|
|
|
|
-- Temporary test
|
|
|
|
require "Polycode/Core"
|
|
|
|
scene = Scene(Scene.SCENE_2D)
|
|
|
|
scene:getActiveCamera():setOrthoSize(640, 480)
|
|
|
|
label = SceneLabel("Hello from remote module!", 32)
|
|
|
|
label:setPosition(0, -100, 0)
|
|
|
|
scene:addChild(label)
|
|
|
|
--]]
|