Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Ability to add shared functions & vars in virtual device


Question

Posted

Hi Fibaro team

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

I use a lot of functions in my LUA code and the ability to add shared functions would be very useful. I'm a OOP developer and I'm frustrated of not being able to re-use any part of my code !

Exemple: Write in each button code the same function or local variable for device ip, device port, global config etc, this is boring...

Requested today on bugzilla :

Please login or register to see this link.

9 answers to this question

Recommended Posts

  • 0
Posted

+1

I don't do a lot of code, because I am lazy.

But I must finish my installation and all of my code.

  • 0
Posted

+1

Please login or register to see this image.

/emoticons/default_icon_rolleyes.gif" alt=":roll:" />

  • 0
Posted

+1

and a few more

Please login or register to see this link.

  • 0
Guest b95_lun
Posted

+1

  • 0
Posted

The thread on the main loop in the BETA has got me thinking...

More than one instance of a scene can run at a time.

How should a local variable run across instances of scene?

I would say that it should be local to an instance of the scene and use a global to work across. I think this is standard visibility for LUA as I would think each scene is an instance of a anonymous function ... chunk.

and

global variable or function are registered in the sandbox environment table so they can be used from any instance of a scene or virtual device

Is all that needs to happen is define an _ENV table for the sandbox? This would not impact the _G so no risk.

  • 0
Posted

+1

  • 0
Posted

+1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...