Item Search
     
BG-Wiki Search
Page 226 of 302 FirstFirst ... 176 216 224 225 226 227 228 236 276 ... LastLast
Results 4501 to 4520 of 6036

Thread: Gearswap Help Thread!     submit to reddit submit to twitter

  1. #4501
    Bagel
    Join Date
    Dec 2012
    Posts
    1,488
    BG Level
    6

    Quote Originally Posted by Jeanne Renault View Post
    I've run into several differences just today, particularly load() accepting only functions and not strings. You're an open-source guy, right?
    load (chunk [, chunkname [, mode [, env]]])

    Loads a chunk.
    If chunk is a string, the chunk is this string. If chunk is a function, load calls it repeatedly to get the chunk pieces. Each call to chunk must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk.

    there is also
    loadstring()
    loadfile()

  2. #4502
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    Quote Originally Posted by dlsmd View Post
    load (chunk [, chunkname [, mode [, env]]])

    Loads a chunk.
    If chunk is a string, the chunk is this string. If chunk is a function, load calls it repeatedly to get the chunk pieces. Each call to chunk must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk.

    there is also
    loadstring()
    loadfile()
    Except loadstring()--which is the one I need--no longer exists as of 5.2, nor does it exist in Luacore. I've tried calling it and it always fails, with the error message suggesting Luacore thinks it's a variable. Then again it probably wouldn't work right even if it did exist.

    I figured out the problem with the sets, though. Instead of trying to assign oldSet or newSet to sets.engaged.Subtle or sets.engaged.Accurate (the possible values of oldValue/newValue) it's treating oldValue and newValue as part of the name. Unfortunately, without some way to convert strings to names, I can't fix it.

  3. #4503
    Bagel
    Join Date
    Dec 2012
    Posts
    1,488
    BG Level
    6

    Quote Originally Posted by Jeanne Renault View Post
    Except loadstring()--which is the one I need--no longer exists as of 5.2, nor does it exist in Luacore. I've tried calling it and it always fails, with the error message suggesting Luacore thinks it's a variable. Then again it probably wouldn't work right even if it did exist.

    I figured out the problem with the sets, though. Instead of trying to assign oldSet or newSet to sets.engaged.Subtle or sets.engaged.Accurate (the possible values of oldValue/newValue) it's treating oldValue and newValue as part of the name. Unfortunately, without some way to convert strings to names, I can't fix it.
    all loadstring() does is takes a string and decodes it to code
    i.e.
    loadstring("68656c6c6f") == "hello"

  4. #4504
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    Quote Originally Posted by dlsmd View Post
    all loadstring() does is takes a string and decodes it to code
    i.e.
    loadstring("68656c6c6f") == "hello"
    That's the most useless thing I've ever heard of. Please tell me you're joking.

  5. #4505
    Bagel
    Join Date
    Dec 2012
    Posts
    1,488
    BG Level
    6

    Quote Originally Posted by Jeanne Renault View Post
    That's the most useless thing I've ever heard of. Please tell me you're joking.
    you can do this
    f = assert (loadstring ("print 'hello, world'"))
    f () --> hello, world
    but its slower then
    function f() print(
    'hello, world') end
    f(
    ) --> hello, world

    its the only way to encrypt your lua code in any way but yes thats all you can do with it

  6. #4506
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    Quote Originally Posted by dlsmd View Post
    its the only way to encrypt your lua code in any way but yes thats all you can do with it
    The command reference for 5.1 said loadstring() would evaluate a string as code and even provided examples of using it for that. I figured it would do the same thing in 5.2 if it still existed.

    This is the worst language since Ada.

  7. #4507
    BG Content
    Join Date
    Jul 2007
    Posts
    22,350
    BG Level
    10
    FFXI Server
    Lakshmi
    Blog Entries
    1

    It's possible that loadstring isn't exposed to the user environment in gearswap (because I missed it initially and no one requested it).

    Lua is yet another high level scripting language. I don't find it that much more offensive than anything else I've tried. 5.1 has its issues, but 5.2 had some problems deeper in the code than we cared to dive.

  8. #4508
    Bagel
    Join Date
    Dec 2012
    Posts
    1,488
    BG Level
    6

    Quote Originally Posted by Byrthnoth View Post
    It's possible that loadstring isn't exposed to the user environment in gearswap (because I missed it initially and no one requested it).

    Lua is yet another high level scripting language. I don't find it that much more offensive than anything else I've tried. 5.1 has its issues, but 5.2 had some problems deeper in the code than we cared to dive.
    and its way faster/eaiser the xml lol

  9. #4509
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    Quote Originally Posted by Byrthnoth View Post
    It's possible that loadstring isn't exposed to the user environment in gearswap (because I missed it initially and no one requested it).
    Really? I'm the first person who asked about it? o.o

    Lua is yet another high level scripting language. I don't find it that much more offensive than anything else I've tried. 5.1 has its issues, but 5.2 had some problems deeper in the code than we cared to dive.
    Lua is the only "high level scripting language" without switch-case or eval functions that I've ever heard of. At what point do the Powers That Be finally have enough and say "Lua, you're full of crap, we're demoting you to mid-level"?

  10. #4510
    Bagel
    Join Date
    Dec 2012
    Posts
    1,488
    BG Level
    6

    Quote Originally Posted by Jeanne Renault View Post
    Lua is the only "high level scripting language" without switch-case or eval functions that I've ever heard of. At what point do the Powers That Be finally have enough and say "Lua, you're full of crap, we're demoting you to mid-level"?
    but it does tho some things have to be built manualy

  11. #4511
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    Quote Originally Posted by dlsmd View Post
    but it does
    You've just been trolling me this entire time, haven't you.

  12. #4512
    Bagel
    Join Date
    Dec 2012
    Posts
    1,488
    BG Level
    6

    Quote Originally Posted by Jeanne Renault View Post
    You've just been trolling me this entire time, haven't you.
    no byrth would have called me out in a heart beat

  13. #4513
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    By the looks of things, I'm not gonna get anywhere on this problem unless Byrth adds eval or switch-case functions to Luacore. Or the god of technology replaces all instances of Luacore with a Python interpreter. Wish in one hand and crap in the other though.

    But if you do add those, Byrth, I'll sing your praises from the gates of Castle Adoulin.

    EDIT: Well crap, turns out the solution was to use "oldSet = sets.engaged[oldValue]" and "newSet = sets.engaged[newValue]" instead. Let's see if it does what I want it to now.

    Quote Originally Posted by dlsmd View Post
    no byrth would have called me out in a heart beat
    You said Lua is easier than XML. That's definitely trolling.

  14. #4514
    Bagel
    Join Date
    Dec 2012
    Posts
    1,488
    BG Level
    6

    Quote Originally Posted by Jeanne Renault View Post
    By the looks of things, I'm not gonna get anywhere on this problem unless Byrth adds eval or switch-case functions to Luacore. Or the god of technology replaces all instances of Luacore with a Python interpreter. Wish in one hand and crap in the other though.
    if your talking eval as checking to see if code works just do this
    for
    a=2
    if a==1 then
    just
    print(a==1) -- will show false
    and there are already way to switch the case of strings its in the strings lib
    and as far as things like this
    this is java
    public class SwitchDemo {
    public static void main(String[] args) {

    int month = 8;
    String monthString;
    switch (month) {
    case 1: monthString = "January";
    break;
    case 2: monthString = "February";
    break;
    --etc.
    }
    System.out.println(monthString);
    }
    }
    this is lua
    local month = 8
    local monthString
    if month = 1 then
    monthString = "January"
    elseif month == 2 then
    monthString = "February"
    --etc.
    print(monthString)

    and if you talking about converting from number to string
    tostring()
    or string to number
    tonumber()

    lua 5.2 also has goto

    and there is a addon called eval to test code as well

  15. #4515
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    Quote Originally Posted by dlsmd View Post
    if your talking eval as checking to see if code works
    I'm not. In most scripting languages nowadays there's an eval() function that takes a string and parses it as code. In Ruby, for example,

    Code:
    instructions = "5.times print 'odelay! '"
    eval(instructions)
    would yield:

    Code:
    odelay! odelay! odelay! odelay! odelay!
    I'd still like to have it, since I could reduce job_state_change to one line and a table lookup if I did, but I can make do with if-chains.

    The eval addon doesn't do what I'm talking about either, as far as I know, and I'm pretty sure it can't see GearSwap's variables.

    "Switch-case" has nothing to do with upper- or lower-case letters, either. In most languages, instead of doing:

    Code:
    if fu == "bar" then
        print("Fucked up beyond all recognition, sir!")
    elseif fu == "sna" then
        print("Situation normal--all fucked up, sir!")
    elseif fu == "kung" then
        print("That cat was fast as lightning, sir!")
    else
        print("I don't have a joke for this one, sir!")
    end
    you can just do (another Ruby example--Python inexplicably doesn't have one either)
    Code:
    case fu
    when "bar"
        print("Fucked up beyond all recognition, sir!")
    when "sna"
        print("Situation normal--all fucked up, sir!")
    when "kung"
        print("That cat was fast as lightning, sir!")
    else
        print("I don't have a joke for this one, sir!")
    end
    You may think these are the same, except with if-elseif chains, you're testing the same condition multiple times, which reduces performance dramatically--especially if you perform further tests inside. With a switch-case, you test the same condition exactly once.

    Bro, do you even code?

  16. #4516
    Bagel
    Join Date
    Dec 2012
    Posts
    1,488
    BG Level
    6

    this explains it more
    http://lua-users.org/wiki/SwitchStatement

    eval (what lua ver im not sure)
    http://redis.io/commands/EVAL
    but this exists in the eval addon i think

  17. #4517
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    Quote Originally Posted by dlsmd View Post
    Yeah, I was looking at that earlier today while I worked on my substitute. None of the examples in there are remotely practical.

    Note that this works, but trashes the gc with a function closure each time the switch is used (as do most of the examples on this page). Still, i like the way it works. Just don't use it in real life --PeterPrade

    Redis is a database thing with its own Lua interpreter. EVAL and eval() are two completely different ideas, and I've never understood why databases are so loud.

  18. #4518
    BG Content
    Join Date
    Jul 2007
    Posts
    22,350
    BG Level
    10
    FFXI Server
    Lakshmi
    Blog Entries
    1

    First off, Lua and XML aren't directly comparable because Lua is an actual scripting language and XML is a format for data. When comparing structures to structures, XML is unarguably less complex than a Lua table. It's only possible to convert a fairly small subset of Lua tables to XML, but you can convert all standard XML documents to Lua Tables.

    So...
    * Are Lua Tables simpler than XML? No.

    * Is it easier to write functioning code in Lua than to code in a purpose-made language that uses non-standard XML formatting as a basis? Probably, unless you already know the purpose-made language and it doesn't bother you how terribly inefficient it is.

    As for switch: http://lua-users.org/wiki/SwitchStatement


    I'll expose LoadString when I get home and fix one other bug on the -dev client. Also, ftr, "//gs debugmode" opens up the "//gs eval ___" command, which will be executed in the top-level environment (not your user environment). Also, the eval addon exists if you're just interested in testing out general Lua things.

  19. #4519
    Melee Summoner
    Join Date
    Jul 2015
    Posts
    43
    BG Level
    1
    FFXI Server
    Bahamut

    Quote Originally Posted by Byrthnoth View Post
    First off, Lua and XML aren't directly comparable because Lua is an actual scripting language and XML is a format for data. When comparing structures to structures, XML is unarguably less complex than a Lua table. It's only possible to convert a fairly small subset of Lua tables to XML, but you can convert all standard XML documents to Lua Tables.

    So...
    * Are Lua Tables simpler than XML? No.

    * Is it easier to write functioning code in Lua than to code in a purpose-made language that uses non-standard XML formatting as a basis? Probably, unless you already know the purpose-made language and it doesn't bother you how terribly inefficient it is.
    If you don't know either, it's easier to pick up XML. Although I'm kind of glad I finally switched from macros to GearSwap, all things considered, because it's nice to code again.


    Already read through that. Aside from a few pointers in the right direction, it's almost all just proof-of-concept stuff.


    I'll expose LoadString when I get home and fix one other bug on the -dev client. Also, ftr, "//gs debugmode" opens up the "//gs eval ___" command, which will be executed in the top-level environment (not your user environment).
    Thanks. I'd rather not run it in debug mode on a daily basis though. I'll start writing your song in the meantime.

    Also, the eval addon exists if you're just interested in testing out general Lua things.
    Actually planning to use tables with the lines of code I want to execute stored as strings within them. That way it doesn't cause trouble the way storing functions in a table--like on that entry--would.

  20. #4520
    BG Content
    Join Date
    Jul 2007
    Posts
    22,350
    BG Level
    10
    FFXI Server
    Lakshmi
    Blog Entries
    1

    Honestly, we aren't on Pentium IIIs with 128MB of RAM anymore. Your Lua code is almost guaranteed to be so lightweight that inefficiency in it is negligible. I suspect that what GearSwap does before and after your code is going to take the vast majority of the processing time during every event until you approach an infinite loop in your code (which some people do).


    When I'm looking for Switches with a static set of outcomes, I typically just use the "table o' functions" approach. You can see this implemented around line 1770 of addons/libs/extdata.lua

Page 226 of 302 FirstFirst ... 176 216 224 225 226 227 228 236 276 ... LastLast

Similar Threads

  1. Replies: 6547
    Last Post: 2014-07-08, 22:45