Page 1 of 2
Retrieving Object Parameter Values
Posted: Tue Oct 21, 2014 6:11 pm
by NutJob
How do I get component parameter states/values?
Ex. I can turn on [an already shut off] lantern with a lever with this code:
Code: Select all
dungeon_wall_lantern_1.light:enable()
But I need to write a conditional to turn it back off with that same lever, so I need to check it's state. I can't figure out the function to retrieve that information.
Is there universal function that I can test the state (retrieve it's value) of anything within an object?
I must be overlooking something extremely simple.
Re: Object Parameters
Posted: Tue Oct 21, 2014 6:39 pm
by SnowyOwl47
NutJob wrote:How do I get component parameter states/values?
Ex. I can turn on [an already shut off] lantern with a lever with this code:
Code: Select all
dungeon_wall_lantern_1.light:enable()
But I need to write a conditional to turn it back off with that same lever, so I need to check it's state. I can't figure out the function to retrieve that information.
Is there universal function that I can test the state (retrieve it's value) of anything within an object?
I must be overlooking something extremely simple.
Code: Select all
if dungeon_wall_lantern_1.light:enable() == enable then
else if dungeon_wall_lantern_1.light:disable() == disable then
end
That should do it
Re: Object Parameters
Posted: Tue Oct 21, 2014 7:01 pm
by NutJob
SnowyOwl47 wrote:
Code: Select all
if dungeon_wall_lantern_1.light:enable() == enable then
else if dungeon_wall_lantern_1.light:disable() == disable then
end
That should do it
Not too sure why that would work but once I get back I'll give it a shot. Thanks.
--
Edit
Would be nice if there was something like:
Code: Select all
v = object_name_x.some_componant:getEnabled()
or
Code: Select all
v = object_name_x.some_componant:getState()
or, even
Re: Object Parameters
Posted: Tue Oct 21, 2014 7:47 pm
by SnowyOwl47
NutJob wrote:SnowyOwl47 wrote:
Code: Select all
if dungeon_wall_lantern_1.light:enable() == enable then
else if dungeon_wall_lantern_1.light:disable() == disable then
end
That should do it
Not too sure why that would work but once I get back I'll give it a shot. Thanks.
--
Edit
Would be nice if there was something like:
Code: Select all
v = object_name_x.some_componant:getEnabled()
or
Code: Select all
v = object_name_x.some_componant:getState()
or, even
I'm actually working on that, in a script_entity I have that copy paste on Basic Scripting that is called easy commands I'm working on adding a ton of new code for just fiscally getting if something is enabled or not

Re: Retrieving Object Parameter Values
Posted: Tue Oct 21, 2014 7:57 pm
by NutJob
found the method call, it's:
Code: Select all
v = dungeon_wall_lantern_1.light:isEnabled()
Will return true or false.
Wow, that only took about 50 guesses. heh
Re: Retrieving Object Parameter Values
Posted: Wed Oct 22, 2014 4:07 pm
by NutJob
Instead of making a new thread I'll bump this one with a slightly related question. So many questions! ha!
I've set up a Lever, a Button, and a Floor Trigger and they all connect to one script_entity and call this function:
Code: Select all
function sayAmsg()
hudPrint(self.id)
end
So, my question is "How do I get the object calling my function?"
With the code above I expected "Lever_3" in hopes of being able to use the "calling" object properties to progress some other code.
Re: Retrieving Object Parameter Values
Posted: Wed Oct 22, 2014 5:52 pm
by AdrTru
Code: Select all
function sayAmsg(entity)
hudPrint(entity.go.id)
end
All connectors send function(self).
( "self" isnt visible in editor during making connector )
Re: Retrieving Object Parameter Values
Posted: Wed Oct 22, 2014 6:46 pm
by NutJob
AdrTru wrote:Code: Select all
function sayAmsg(entity)
hudPrint(entity.go.id)
end
All connectors send function(self).
( "self" isnt visible in editor during making connector )
I use it in JavaScript I write, always. In that language it'll return the element and all it's properties that made the method call. I expected this would behave the same, but I'm not getting the results back due to [????].
So I just put a scalar into the function header? "entity" then I can use the properties
from the object making the call?
Re: Retrieving Object Parameter Values
Posted: Wed Oct 22, 2014 6:51 pm
by SnowyOwl47
NutJob wrote:AdrTru wrote:Code: Select all
function sayAmsg(entity)
hudPrint(entity.go.id)
end
All connectors send function(self).
( "self" isnt visible in editor during making connector )
I use it in JavaScript I write, always. In that language it'll return the element and all it's properties that made the method call. I expected this would behave the same, but I'm not getting the results back due to [????].
So I just put a scalar into the function header? "entity" then I can use the properties
from the object making the call?
This is lua not javascript and another thing, well what are you trying to get with the hudPrint?
Re: Retrieving Object Parameter Values
Posted: Wed Oct 22, 2014 6:54 pm
by NutJob
SnowyOwl47 wrote:This is lua not javascript and another thing, well what are you trying to get with the hudPrint?
This.
NutJob wrote:
I've set up a Lever, a Button, and a Floor Trigger and they all connect to one script_entity and call this function:
Code: Select all
function sayAmsg()
hudPrint(self.id)
end
So, my question is "How do I get the object calling my function?"
With the code above I expected "Lever_3" in hopes of being able to use the "calling" object properties to progress some other code.