Add global variables 'actor' and 'place'

This commit is contained in:
2025-06-27 16:34:11 -04:00
parent 8298ef6e72
commit be9ff4db35
2 changed files with 33 additions and 8 deletions

View File

@@ -6,15 +6,17 @@ makeclass('sphere')
-- This gets called on every login except the admin user.
function login.init()
local actor = tangible.actor()
dprint("login.init:", actor)
tangible.animinit(actor, {bp="character", plane="earth", xyz={0, 0, 90}})
local player = global.get("nextplayer")
global.set("nextplayer", player + 1)
dprint("login.init initializing player ", player)
actor.player = player
tangible.animinit(actor, {bp="character", 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()
local actor = tangible.actor()
dprint("world.init:", actor)
dprint("world.init")
global.set("nextplayer", 0)
tangible.build{class=cube, plane="earth", xyz={500,-100,0}}
tangible.build{class=sphere, plane="earth", xyz={500,100,0}}
login.init()
@@ -22,7 +24,6 @@ end
function engio.move(action, xyz, facing)
-- todo: sanity check the parameters.
local actor = tangible.actor()
dprint("engio.move ", action, " ", xyz[1], " ", xyz[2], " ", xyz[3])
tangible.animate(actor, nil, {action=action, xyz=xyz, facing=facing})
end
@@ -41,7 +42,7 @@ end
function engio.getlookat()
local class = tangible.getclass(tangible.place())
local class = tangible.getclass(place)
-- if the tangible is not of any class, return empty string.
if class == nil then
@@ -68,7 +69,7 @@ function engio.getlookat()
end
function engio.presshotkey(action)
local class = tangible.getclass(tangible.place())
local class = tangible.getclass(place)
-- if the tangible doesn't have a 'lookhotkeys' function, do nothing
if class == nil or class.lookhotkeys == nil then