Accessing properties

Post Reply
Quaan
Posts: 3
Joined: Sat Jul 18, 2009 12:04 pm

Accessing properties

Post by Quaan »

I'm quite new to LUA-scripting and have some questions about the objects in Mudlet.
I'm working on some bars and such for my UI and I want to change just the alpha of lables in several places.
The long solution would be setting the whole thing both color and alpha but what I would like is the posibility to do something like:
setAlpha("labelOne", 255)

The problem I have here is that my function wont know what the original color of the label had. Is there any way to access the properties of the label or will I just have to do it the long way?

thanks

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Accessing properties

Post by Heiko »

No, there isn't at this point. However, you can set up a table that holds the current alpha values of your labels. In case you need this for on click callback functions, there is a new undocumented feature to add optional parameters to the callback function just like with events. These parameters will be passed on to the callback. For more information look through caled's postings.

Quaan
Posts: 3
Joined: Sat Jul 18, 2009 12:04 pm

Re: Accessing properties

Post by Quaan »

Thank you for that :)

Now I have hit another bump...
I programmatically set up several timers that will execute on different times all involving the same variable, in this case a time string. Since the timers will run att different intervals and with variable commands I cant set up normal timers to turn on/off instead I'm trying it with temp timers.
The problem is the variable that I want to be a part of the command that the tempTimer runns.
Simplfied example:

Code: Select all

for i=1,10 do
  someGlobalVariable = someGlobalVariable + 1
  tempTimer(i, [[echo(someGlobalVariable)]])
end
The obvious problem here is that tells the timer to run echo(someGlobalVariable) and someGlobalVariable will always be the last value. Is there some way I can make the script parse the variable so I'm actually telling the timer to do echo(1) echo(2) echo(3) etc? I guess the problem here is I dont really understand the [[]] annotation...

Thanks again!

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Accessing properties

Post by Heiko »

You simply concatenate the variables to form the correct lambda function call.
myFuncCall = [[echo("]] .. matches[2] ..[[","]] .. matches[3] .. [[")]];
tempTimer(0.3, myFuncCall)

or all in one line:

tempTimer( 0.3, [[echo("]] .. matches[2] ..[[","]] .. matches[3] .. [[")]] )

or

tempTimer( 0.3, "echo(" .. matches[2] ")" )

The [[]] notation is form of string notation that comprises all chars in between [[]] including ".

Quaan
Posts: 3
Joined: Sat Jul 18, 2009 12:04 pm

Re: Accessing properties

Post by Quaan »

I had a feeling it was something simple! ;) Thank you for the answer!

Post Reply