Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
LUAU replacement of macros with |code| — Gideros Forum

LUAU replacement of macros with |code|

Hey all, returning to my app to fill it with some content. Just discovered the change to LUAU which probably is great, but without the macro support. I have used a lot of macros, not only for constants but also to reduce repetitive code, like this
deltaX @ |application:getLogicalTranslateX() / application:getLogicalScaleX()|
or
repetitivecodewithexpression @ |* constant1 * contant2|

Is there a simple way to replace these, specifically those with double |'s after the @? I'm using them (among other places) extensively inside movieclips (where functions cannot be called).

Comments

  • MoKaLuxMoKaLux Member
    edited March 2022
    I am afraid you will have to do it by hand. You can use CTRL+SHIFT+F to find all occurences of | for example.
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • saeyssaeys Member
    Well yeah, and to replace them with non-macro code should be no problem. .lua size will grow and code readability will worsen. :/ The Lua to Luau conversion guide only suggests changing macro constants to variables, but is there really no counterpart in Gideros Luau to Gideros Lua's macro implementation when using delimiter pairs like
    macro @ |any code between delimiters|
    ?
    If so, Gideros just got less intuitive. Too bad. :(
  • hgy29hgy29 Maintainer
    @saeys, I think the macro stuff can be added back, but it was better to avoid changing luau code too much at the beginning. Now we know it does work quite well and Gideros integration looks almost stable, it may be a good time to re-implement them.
    I can probably do it, but I don't use them myself so this isn't a top priority for me, and it didn't seem to be one for others either so far.
    +1 -1 (+3 / -0 )Share on Facebook
  • hito9hito9 Member
    My english is not enough editing a wiki topic. Could anyone?
    The following issues should be documented and some should be clarified.
    Replacements
    * math.mod --> math.modf
    * table.unpack() --> unpack()
    * require('core.tablex') --> require "core/tablex"

    Should be clarify
    * dofile("phrase.lst") --> loadfile("phrase.json")()

    Only for including return{lua_code or tables} files
    --local map = loadfile(filename/path)()

    instead of should be called like this ?
    local map = require "filename/path"

    or In the Studio mark as "Exclude from Execution"

    What is the Luau alternative (...) method?
    function foo(bar, ...)

    I think "profi.lua" is deprecated?
  • @hito9 gideros wiki will need some updates for sure :#
    When you write: "* math.mod --> math.modf" we have this in gideros https://wiki.gideros.rocks/index.php/Math.fmod
    ...

    This is tricky because maybe some people do not use new gideros luau!?

    Should we do it now? There is this thread related to gideros wiki to make changes to the wiki: https://forum.gideros.rocks/discussion/7465/new-gideros-docs-wiki#latest

    See you there :)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • hito9hito9 Member
    MoKaLux said:

    @hito9 gideros wiki will need some updates for sure :#
    When you write: "* math.mod --> math.modf" we have this in gideros https://wiki.gideros.rocks/index.php/Math.fmod
    ...

    This is tricky because maybe some people do not use new gideros luau!?

    Should we do it now? There is this thread related to gideros wiki to make changes to the wiki: https://forum.gideros.rocks/discussion/7465/new-gideros-docs-wiki#latest

    See you there :)

    I think this entry is good place to be a reminder of this replacements.

    Pardon, modf or fmod which one? Some examples have math.mod method that have to convert math.modf for luau compatibility.

    Of course not now :) as i said just reminder to be considered. Yes this tricky, We should offer resolving compatibility issues as much as possible for new Giderans and veteran Giderans

    Likes: MoKaLux, saeys

    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.