80 lines
2.5 KiB
Lua
80 lines
2.5 KiB
Lua
makeclass("world")
|
|
makeclass('login')
|
|
makeclass("engio")
|
|
makeclass('cube')
|
|
makeclass('sphere')
|
|
|
|
-- This gets called on every login except the admin user.
|
|
function login.init()
|
|
local player = global.get("nextplayer")
|
|
global.set("nextplayer", player + 1)
|
|
dprint("login.init initializing player ", player)
|
|
actor.player = player
|
|
tangible.animinit{tan=actor, anim={bp="character", mesh="manny", plane="earth", xyz={player * 100, 0, 90}}}
|
|
end
|
|
|
|
-- This gets called on the admin user. You can call login.init in here if you want.
|
|
function world.init()
|
|
dprint("world.init")
|
|
global.set("nextplayer", 0)
|
|
tangible.build{class=cube, anim={plane="earth", xyz={500,-100,0}, mat_color={1,0,0}}}
|
|
tangible.build{class=sphere, anim={plane="earth", xyz={500,100,0}, mat_color={0,0,1}}}
|
|
login.init()
|
|
end
|
|
|
|
function engio.move(action, xyz, facing)
|
|
-- todo: sanity check the parameters.
|
|
dprint("engio.move ", action, " ", xyz[1], " ", xyz[2], " ", xyz[3])
|
|
tangible.animate{tan=actor, anim={action=action, interactive=true, xyz=xyz, facing=facing}}
|
|
end
|
|
|
|
function moveto(x, y)
|
|
local z = tangible.animfinal(actor).xyz[3]
|
|
tangible.animate{tan=actor, anim={action="moveto", xyz={x, y, z}, facing=math.auto}}
|
|
end
|
|
|
|
function cube.lookhotkeys(add)
|
|
add("Z", "Cube Hi", function () dprint("Doing Cube Hi") end)
|
|
add("X", "Cube Bye", function () dprint("Doing Cube Bye") end)
|
|
add("C", "Cube Yo", function () dprint("Doing Cube Yo") end)
|
|
end
|
|
|
|
function sphere.lookhotkeys(add)
|
|
add("Z", "Sphere Hi", function () dprint("Doing Sphere Hi") end)
|
|
add("X", "Sphere Bye", function () dprint("Doing Sphere Bye") end)
|
|
add("C", "Sphere Yo", function () dprint("Doing Sphere Yo") end)
|
|
end
|
|
|
|
|
|
function engio.getlookat()
|
|
local class = tangible.getclass(place)
|
|
|
|
-- if the tangible is not of any class, return empty string.
|
|
if class == nil then
|
|
return ""
|
|
end
|
|
|
|
-- if the class has a function 'lookhotkeys', then the correct
|
|
-- look-at widget is 'hotkeys'.
|
|
if class.lookhotkeys ~= nil then
|
|
return "hotkeys"
|
|
end
|
|
|
|
-- otherwise, if the class has a function 'getlookat', use that.
|
|
if class.getlookat ~= nil then
|
|
return class.getlookat()
|
|
end
|
|
|
|
-- by default, return the empty string.
|
|
return ""
|
|
end
|
|
|
|
|
|
|
|
function jp3()
|
|
tangible.animate{tan=actor, anim={action="play", seq="jump"}}
|
|
tangible.animate{tan=actor, anim={action="play", seq="jump"}}
|
|
tangible.animate{tan=actor, anim={action="play", seq="jump"}}
|
|
end
|
|
|