For my mod I need two get two pieces of information from a teleporter:
1) to see if it is active
I can make a teleporter active with the script "teleporter_1.controller:activate()" and deactivate it with "teleporter_1.controller:deactivate()". But I can't seem to find a function that tells me if the teleporter itself is active or not. The controller module has an isEnabled() function, but it returns whether the controller itself is enabled, not the teleporter. Other objects (like the door) have isOpen() and isClosed() functions to query it, but a teleporter doesn't seem to have any such function.
What am I missing?
2) the target location of a teleporter
According to the scripting reference there's a function that returns the target location of a teleporter, but it seems to only return the level, not the x, y and elevation.
Is this a bug, or am I missing something again?
A nudge in the right direction for either problems will help me a lot.
Thanks!
How to get info from a teleporter?
How to get info from a teleporter?
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
Re: How to get info from a teleporter?
Well if nothing else is working you can always implement your own "controller" like this:
now you can control your teleporters with state component instead on controller-component
Edit: This wasn't very good solution, because it doesn't work with connectors, so if you are gonna use this you must control teleporter status by scripting.
Code: Select all
defineObject{
name = "teleporter",
baseObject = "teleporter",
components = {
{
class="Script",
name="state",
source = [[
active = false
function isActive()
return active
end
function activate()
active = true
self.go.controller:activate()
end
function deactivate()
active = false
self.go.controller:deactivate()
end
]]
}
}
}
Code: Select all
teleporter_1.state:activate()
teleporter_1.state:deactivate()
teleporter_1.state:isActive()
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
Re: How to get info from a teleporter?
Here is a better workaround, which works with connectors too.
You can check teleport state by calling
teleporter_1.teleporter:isEnabled()
This is a bit hacky, but it seems to be impossible to get the state of the default teleporter. tested teleporter_1.light:isEnabled() etc. nothing worked. I hope that someone figures out a bit easier method than this
Code: Select all
defineObject{
name = "teleporter",
baseObject = "teleporter",
components = {
{
class="Controller",
onInitialActivate = function(c)
c.go.particle:enable()
c.go.teleporter:enable()
c.go.light:enable()
c.go.sound:enable()
end,
onActivate = function(c)
c.go.particle:enable()
c.go.teleporter:enable()
c.go.light:enable()
c.go.sound:enable()
end,
onInitialDeactivate = function(c)
c.go.particle:disable()
c.go.teleporter:disable()
c.go.light:disable()
c.go.sound:disable()
end,
onDeactivate = function(c)
c.go.particle:disable()
c.go.teleporter:disable()
c.go.light:disable()
c.go.sound:disable()
end,
onToggle = function(c)
if c.go.teleporter:isEnabled() then
c.go.controller:deactivate()
else
c.go.controller:activate()
end
end
}
}
}
teleporter_1.teleporter:isEnabled()
This is a bit hacky, but it seems to be impossible to get the state of the default teleporter. tested teleporter_1.light:isEnabled() etc. nothing worked. I hope that someone figures out a bit easier method than this
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
Re: How to get info from a teleporter?
If you wanted to get lazy you could make another object that you know you can check, such as a script entity with a variable or even a hidden door or lever. Then any time you activate the teleporter also activate the hidden object and check the object for the status.
-
- Posts: 168
- Joined: Thu Oct 30, 2014 1:56 am
Re: How to get info from a teleporter?
Here is an example.sps999 wrote:If you wanted to get lazy you could make another object that you know you can check, such as a script entity with a variable or even a hidden door or lever. Then any time you activate the teleporter also activate the hidden object and check the object for the status.
Code: Select all
teleportActive = false
function tele()
if teleportActive == false then
teleport_1.controller:deactivate()
else
teleport_1.controller:activate()
end
end
Re: How to get info from a teleporter?
Thank you all, this will keep the development of my mod in top gear!
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?