How do I create a LUA module?
  • Moderator
    Kronos
    Posts: 1889 from 2003/2/24
    O.k. here is what I've tried sofar:

    - took the source for os.module and replaced all "os" with "test"
    - added "t_" in front of all function-names

    -> compiled without issues

    - copied to "ibs:lua/" (also tried" mossys.libs/lua")

    1st line of script: " require 'test'"

    ->
    Code:
    lua: Work:module_test/test.lua:1: module 'test' not found:
    no field package.preload['test']
    no file '/usr/local/share/lua/5.3/test.lua'
    no file '/usr/local/share/lua/5.3/test/init.lua'
    no file '/usr/local/lib/lua/5.3/test.lua'
    no file '/usr/local/lib/lua/5.3/test/init.lua'
    no file './test.lua'
    no file './test/init.lua'
    no file '/usr/local/lib/lua/5.3/test.so'
    no file '/usr/local/lib/lua/5.3/loadall.so'
    no file './test.so'
    stack traceback:
    [C]: in function 'require'
    Work:module_test/test.lua:1: in main chunk
    [C]: in ?


    Seems that LUA only knows a fixed number of modules listed in "package".

    LUA docs itself want me to either do a .dll (would that work???) or compile my own LUA with my module linked to it (not really an option).
    --------------------- May the 4th be with you ------------------
    Mother Russia dance of the Zar, don't you know how lucky you are
  • »20.06.19 - 18:46
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    polluks
    Posts: 438 from 2007/10/23
    From: Gelsenkirchen,...
    Hmm, this is the output of Lua not LuaX...
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.11
  • »20.06.19 - 19:33
    Profile
  • Moderator
    Kronos
    Posts: 1889 from 2003/2/24
    *facepalm*

    So that actually works.....


    Thats for always starting LUA-scripts from inside a C-App


    *facepalm*
    --------------------- May the 4th be with you ------------------
    Mother Russia dance of the Zar, don't you know how lucky you are
  • »20.06.19 - 19:39
    Profile
  • Moderator
    Kronos
    Posts: 1889 from 2003/2/24
    Preliminary result (ported from AROS not yet 100%)

    LUALUAMUIeeeeeehhhh

    [ Edited by Kronos 12.09.2019 - 14:59 ]
    --------------------- May the 4th be with you ------------------
    Mother Russia dance of the Zar, don't you know how lucky you are
  • »12.09.19 - 13:59
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    polluks
    Posts: 438 from 2007/10/23
    From: Gelsenkirchen,...
    Well done! :-)
    zuluwget.i386-aros.lha works
    ZuluWget.png
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.11
  • »15.09.19 - 20:59
    Profile
  • ASiegel
    Posts: 1139 from 2003/2/15
    From: Central Europe
    Very cool!
  • »16.09.19 - 11:17
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 1797 from 2003/3/5
    From: Poland
    While using MUI from Lua is cool, I'd go for the proper OO approach Lua is capable of. It shouldn't be too hard to allow subclassing with Lua.

    You generally need a BOOPSi dispatcher that will perform a lookup of the MUIM_ value in lua class' metatable to determine whether a method was overloaded or not. You'd have to parse mui.h in order to find which method belongs to which class too, etc. A bit of work but doable.

    This is generally how ObjectiveC MUI was implemented - its code is actually in large parts generated with OO lua that internally has a class corresponding to each supported MUI class.
  • »16.09.19 - 12:32
    Profile Visit Website
  • Moderator
    Kronos
    Posts: 1889 from 2003/2/24
    Lets not go overboard....

    The whole thing started with an attempt to have scripted objects in SteamDraw. These do work in principle but are rather limited without some basic GUI.

    1st thought was to have SteamDraw supply some basic objects (Buttons,Cycles and so on), but then I remembered that Krashan had planned some MUI module way back. So I googled and found nothing, I looked into the CVS wether there might have been something alpha committed before he went 68k, again nada....

    Well, not nada at all as I found your ObjC generating LUA code taking me a moment to figure out what that was all about ;)

    So I thought about doing it myself and came up a few principle designs when some more googling revealed Zulu.....

    Zulu is quite close to what I thought about, so a port seemed the logical choice.

    It is also very small and straightforward to use for anyone with basic MUI experience.

    It does use some basic OO (as in all MUI objects being of one class seen from LUA) and I see no problem expanding it further.

    I also have a parser for mui.h at hand (part of MMamM) which I could adapt to autogenerate the header like LUA scripts.

    Going full in with making a wrapper for MUI (like yours for ObjC) is something I don't plan, cos for the scope of LUA scripts one can either handle writing "classic" MUI-makro-maddness or is better of using a GUI-creator (also part of my project bucketlist).


    ->

    Will see if I can add subclassing and mcc support
    Might add another module for (cyber)graphics, maybe based on amilua (also AROS)
    --------------------- May the 4th be with you ------------------
    Mother Russia dance of the Zar, don't you know how lucky you are
  • »16.09.19 - 17:31
    Profile