Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who's Online
1 user(s) are online (1 user(s) are browsing Forum)

Members: 0
Guests: 1

more...

Browsing this Thread:   1 Anonymous Users



« 1 2 (3) 4 »


Re: getting my hands dirty with lua

Joined:
2005/8/17 16:00
From Germany
Group:
Member
Posts: 2204
Offline
Quote:

saimon69 wrote:
@mazze

can you please show an example snippet using group and the attribute?


This example lets you enable/disable the group with the two text fields.

require "muidefs"
require "muifuncs"

ok_id 1
cancel_id 
2

function creategui()
  
local okbutton mui.SimpleButton("_Enable")
  
local cancelbutton mui.SimpleButton("_Disable")
  
local text1 mui.TextObject(mui.MUIA_Text_Contents"27cHello world!")
  
local text2 mui.TextObject(mui.MUIA_Text_Contents"27cHow are you?")

  
group mui.VGroup(
      
mui.Childtext1,
      
mui.Childtext2
  
)

  
window mui.WindowObject(
    
mui.MUIA_Window_Title"Hello world!",
    
mui.MUIA_Window_RootObjectmui.VGroup(
      
mui.Childgroup,
      
mui.Childmui.HGroup(
        
mui.Childokbutton,
        
mui.Childcancelbutton
      
)
    )
  )
  
app mui.ApplicationObject(
    
mui.MUIA_Application_Windowwindow
  
)
  
assert(app:check(), "Cant create application")
  
window:doint(mui.MUIM_Notifymui.MUIA_Window_CloseRequesttrue,
    
app2mui.MUIM_Application_ReturnIDmui.MUIV_Application_ReturnID_Quit)

  
okbutton:doint(mui.MUIM_Notifymui.MUIA_Pressedfalseapp2mui.MUIM_Application_ReturnIDok_id)
  
cancelbutton:doint(mui.MUIM_Notifymui.MUIA_Pressedfalseapp2mui.MUIM_Application_ReturnIDcancel_id)

  
window:set(mui.MUIA_Window_Opentrue)
end


function main()
  
creategui()
  
running true
  
while running do
    
idsignals app:input()
    if 
id == mui.MUIV_Application_ReturnID_Quit then
      running 
false
    
elseif id == ok_id then
      group
:set(mui.MUIA_Disabledfalse)
    elseif 
id == cancel_id then
      group
:set(mui.MUIA_Disabledtrue)
    
end
    
if running then mui.wait(signalsend
  end
end


_
err pcall(main)
if 
err then print("Error: " .. errend
if app then app:dispose() end


Quote:

Plus, can I treat a group in the same way i can treat a checkbox or a textfield, like in example


Groups are MUI/Zune classes, too. Of course, you have to look in the documentation what attributes are possible. The Group class is a subclass of the Area class, this makes it possible to use its attributes like MUIA_Disabled.

Posted on: 2009/4/18 0:51
_________________
AROS - Make code, not war
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2007/10/23 8:47
From Los Angeles,CA
Group:
Member
Posts: 805
Offline
Well, thanks for the code example, will try to put it in practice soon, just hope that can do the switch with the check box active/inactive.

Now am working still on the inner logic, after some day that was unable to, so am parsing finally the interfaces file, the snippet of code provided and the lua guide helped me; jsut i wonder if there is a way to retrieve an index from a table known one of the elements inside.

Saimon69

Posted on: 2009/4/18 1:41
_________________
Kitteh Fav OS since 1995 =^x^=
---
Scarabocchi Binari - blog
Binary Doodles - english blog
Twitter
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2005/8/17 16:00
From Germany
Group:
Member
Posts: 2204
Offline
Quote:

saimon69 wrote:
jsut i wonder if there is a way to retrieve an index from a table known one of the elements inside.


What do you mean with table? Lua tables, Zune List objects?

Posted on: 2009/4/18 2:47
_________________
AROS - Make code, not war
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2005/8/17 16:00
From Germany
Group:
Member
Posts: 2204
Offline
Quote:

mazze wrote:
Quote:

clusteruk wrote:
@mazze

Spent two or three hours trying to get code to give me filesystem access so I can scan directories and files. It appears that i need the "lfs" - (Lua File System) library which this lua implementation does not seem to offer.

http://www.keplerproject.org/luafilesystem/


This external library isn't part of standard Lua.
It shouldn't be that hard to port these few functions to AROS.


Done. Luafilesystem is now included in AmiLua in current nightly build. I'll run some tests, but it looks good so far.

Posted on: 2009/4/18 2:52
_________________
AROS - Make code, not war
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2008/6/7 13:52
Group:
Member
Posts: 2066
Offline
@mazze

Thanks for that, I will try it during the week.

Posted on: 2009/4/18 15:56
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2007/10/23 8:47
From Los Angeles,CA
Group:
Member
Posts: 805
Offline
Sorry if i took so long to answer, been kinda busy, but my actual next step is to show in the interface the parameters as they have been loaded from the config files; for the textfields that was fkinda easy, but did not found the way to do it with the list: so if in example the network card is the "PCNet32/VMWare Ethernet cards" that in the devices table has index 1 and same index in the strarray, how can i set the list object to show the index 1 (or whatever other index is in the config) at the GUI opening?

BTW, i made some progress with the non-gui related part, now pressing "save" the application save backup copies of the config files with filename plus the date of the modification.


Saimon69

Posted on: 2009/4/24 15:49
_________________
Kitteh Fav OS since 1995 =^x^=
---
Scarabocchi Binari - blog
Binary Doodles - english blog
Twitter
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2005/8/17 16:00
From Germany
Group:
Member
Posts: 2204
Offline
I'm not sure what you want to do. If you want to activate an entry by index you can do:
MUIA_List_Active, number

Posted on: 2009/4/24 23:53
_________________
AROS - Make code, not war
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2007/10/23 8:47
From Los Angeles,CA
Group:
Member
Posts: 805
Offline
Sorry for the long wait again, computer got messed up and so now that am almost up and running again can go back to work.

Quote:

I'm not sure what you want to do. If you want to activate an entry by index you can do:
MUIA_List_Active, number


And what for a cycle gadget like this, if i want to appear on load with a determinated value from the list?

cardlist_cyc mui.CycleObject(mui.MUIA_Cycle_Entriescardlistmui.MUIA_Cycle_Active2)


Saimon69

Posted on: 2009/5/15 15:34
_________________
Kitteh Fav OS since 1995 =^x^=
---
Scarabocchi Binari - blog
Binary Doodles - english blog
Twitter
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2005/8/17 16:00
From Germany
Group:
Member
Posts: 2204
Offline
Quote:

saimon69 wrote:

And what for a cycle gadget like this, if i want to appear on load with a determinated value from the list?

cardlist_cyc mui.CycleObject(mui.MUIA_Cycle_Entriescardlistmui.MUIA_Cycle_Active2)



According to MUI_Cycle.doc, MUIA_Cycle_Active is [ISG]. This means the line above is correct ("I" means "init").

If this doesn't work it's a bug in Zune. You can do a workaround with:

cardlist_cyc:set(mui.MUIA_Cycle_Active,2)

Posted on: 2009/5/16 1:29
_________________
AROS - Make code, not war
Transfer the post to other applications Transfer


Re: getting my hands dirty with lua

Joined:
2007/10/23 8:47
From Los Angeles,CA
Group:
Member
Posts: 805
Offline
I continue with this thread because now have a different question:

Because was already unable to parse the initial nested networkcards table I replaced it with four normal tables, and i am trying to retrieve the table index of an element.

Will explain better: I have a table called networkcards
composed like this:

networkcards = {"DEVS:networks/etherlink3.device",
"DEVS:networks/pcnet32.device",
"DEVS:networks/nforce.device",
"DEVS:networks/prm-rtl8029.device",
"DEVS:networks/prism2.device",
"DEVS:networks/intelpro100.device",
"DEVS:networks/tap.device",
"DEVS:networks/sis900.device"}


(the code has been splitted in lines for space)

In a function I already parse the interfaces file and already have found the current online network card and store the found string in the variable devfound.


now is my intention, parsing the networkcards array, to retrieve the matching value on the array, store the index of it and use it to make apperar the card selected in the cycle gadget;

The strings in the networkcard array are the same that can be found inside the interfaces config file, so a simple string comparison should work.

To do that i wrote this code that returns the "parsing a table" error:

for head,iline in pairs(networkcards) do
   if 
networkcards[iline] == devfound then
    
print ("found in index "..head)
    
devicedevidx head
    
else print("nothing found")
    
end
end


how do i retrieve the value index in the table where the content of networkcards matches devfound?

Saimon69

Posted on: 2009/5/28 17:40
_________________
Kitteh Fav OS since 1995 =^x^=
---
Scarabocchi Binari - blog
Binary Doodles - english blog
Twitter
Transfer the post to other applications Transfer



« 1 2 (3) 4 »



You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4338
2 magorium
magorium
4095
3 phoenixkonsole
phoenixkonsole
3887
4 nikolaos
nikolaos
3677
5 deadwood
deadwood
2923
6 ncafferkey
ncafferkey
2612
7 mazze
mazze
2204
8 clusteruk
clusteruk
2066
9 Kalamatee
Kalamatee
2023
10 damocles
damocles
1789
© 2004-2017 AROS Exec