+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 11 to 15 of 15

Thread: E2 string match functions (for LUA's string.Match functions)

  1. #11
    Bug Buster

    TomyLobo has a spectacular aura about TomyLobo has a spectacular aura about TomyLobo's Avatar
    Join Date
    Feb 2009
    Posts
    2,772

    Default Re: E2 string match functions (for LUA's string.Match functions)

    see the extension tutorial. it describes all the types:
    Wire Expression2 Extension Tutorial

    also, try 'return foobar or ""'
    will return "" if foobar is nil (or false) and foobar if not.
    "It's easy to win forgiveness for being wrong; being right is what gets you into real trouble." - Bjarne Stroustrup

    Lífið læðist lúmskt áfram

  2. #12
    Bug Buster

    TomyLobo has a spectacular aura about TomyLobo has a spectacular aura about TomyLobo's Avatar
    Join Date
    Feb 2009
    Posts
    2,772

    Default Re: E2 string match functions (for LUA's string.Match functions)

    I'm committing these now.
    "It's easy to win forgiveness for being wrong; being right is what gets you into real trouble." - Bjarne Stroustrup

    Lífið læðist lúmskt áfram

  3. #13
    Wirezard


    Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    2,102

    Default Re: E2 string match functions (for LUA's string.Match functions)

    I think an implode and a reverse string function could be useful. I've taken the time to make them, and they work. The reverse()-function returns the string you input reversed, and the implode()-function takes an array and returns all the cells as a string. The opposite of explode.
    syntax:

    S:reverse()
    R:implode(S) or R:implode()

    lua Code:
    1. e2function string string:reverse()
    2. return string.reverse(this)
    3. end
    4.  
    5.  
    6. e2function string array:implode(string that)
    7. if !this then return "" end
    8. Tbl = {}
    9. for k,v in pairs(this) do
    10. table.insert(Tbl,tostring(v))
    11. end
    12. return string.Implode(that,Tbl)
    13. end
    14.  
    15. e2function string array:implode()
    16. if !this then return "" end
    17. Tbl = {}
    18. for k,v in pairs(this) do
    19. table.insert(Tbl,tostring(v))
    20. end
    21. return string.Implode("",Tbl)
    22. end
    Last edited by Matte; 07-05-2009 at 06:17 AM.
    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr


  4. #14
    Bug Buster

    TomyLobo has a spectacular aura about TomyLobo has a spectacular aura about TomyLobo's Avatar
    Join Date
    Feb 2009
    Posts
    2,772

    Default Re: E2 string match functions (for LUA's string.Match functions)

    we already have implode. it's named concat.
    and as I told Jeremydeath before you, E2 strings are never nil, so this check in E:reverse is superfluous.
    "It's easy to win forgiveness for being wrong; being right is what gets you into real trouble." - Bjarne Stroustrup

    Lífið læðist lúmskt áfram

  5. #15
    Wirezard


    Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    2,102

    Default Re: E2 string match functions (for LUA's string.Match functions)

    Ah, ok! Then it's no need for the implode function. Heh, I didn't even know there was such a function.
    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr


+ Reply to Thread
Page 2 of 2
FirstFirst 1 2

Similar Threads

  1. NPC functions - Egate2
    By Bobsymalone in forum Wiremod Addons
    Replies: 50
    Last Post: 10-30-2009, 08:15 AM
  2. functions
    By bobthe2lol in forum Expression Help
    Replies: 2
    Last Post: 06-24-2009, 08:22 AM
  3. E2 - CJ's functions
    By [FX]CJ[CrS] in forum Wiremod Addons
    Replies: 5
    Last Post: 04-22-2009, 11:36 AM
  4. E-2 some functions.
    By Whodunnit in forum Ideas & Suggestions
    Replies: 12
    Last Post: 03-11-2009, 04:31 AM
  5. E2: Few new functions
    By d3cr1pt0r in forum Wiremod Lua Coding
    Replies: 24
    Last Post: 02-22-2009, 09:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts