General Script Help

HI Guys,

Not brilliant at coding in Lua, though I am looking to expand my skills.

As such, I would like to offer a free service where I will try and help you/create scripts for you that you find useful but don't know how to complete yourself.

I have a pretty solid background in Achaea - mostly combat oriented - so if there was something you wanted, let me know and I'll try and make it for you (I may already have it, too)!

No promises that it will be better than anything you can create yourself, but I think this could be mutually beneficial - I learn more, you get your scripts.

I'll work on a first-come-first-serve basis, and will be honest if I think I can or can't do something that you request.

Thanks,

Telinus.

Comments

  • Whoa I am so in, Telinus you rock. I want to begin learning Lua myself and having someone else's code to study would be so helpful. Do you want us to contact you in game or post requests here? Also tagging @Hervy
  • Wait nevermind, messaged you!   =)
  • Caynix said:
    I want to begin learning Lua myself and having someone else's code to study would be so helpful.
    Not a comment on Telinus specifically (to my knowledge I've not seen any of his code), but I've seen a lot of code from Achaeans, and I would estimate that 99% of what I've seen is a mess full of bad practices that make the code harder to write, read, understand and debug. A lot of the time you'll be doing yourself no favours by using that code as a basis for your own learning because you'll also learn those same bad practices.
  • edited October 2017
    Antonius said:
    Caynix said:
    I want to begin learning Lua myself and having someone else's code to study would be so helpful.
    Not a comment on Telinus specifically (to my knowledge I've not seen any of his code), but I've seen a lot of code from Achaeans, and I would estimate that 99% of what I've seen is a mess full of bad practices that make the code harder to write, read, understand and debug. A lot of the time you'll be doing yourself no favours by using that code as a basis for your own learning because you'll also learn those same bad practices.
    Do you have a guide to some of the better practices?  I've messed with Python and other scripting languages and have seen what you said in using other people's code, sometimes its not the best way to do things.  Thanks!

    EDIT: http://forums.achaea.com/discussion/5939/need-some-help-getting-started-with-mudlet#latest
    This post has some great links to exactly what I was asking for!
  • Antonius said:
    Not a comment on Telinus specifically (to my knowledge I've not seen any of his code), but I've seen a lot of code from Achaeans, and I would estimate that 99% of what I've seen is a mess full of bad practices that make the code harder to write, read, understand and debug.
    Pssh, I've seen some of your code! (although nothing recent, admittedly, it was still nightmarish :( )
  • Alyxeri said:
    Antonius said:
    Not a comment on Telinus specifically (to my knowledge I've not seen any of his code), but I've seen a lot of code from Achaeans, and I would estimate that 99% of what I've seen is a mess full of bad practices that make the code harder to write, read, understand and debug.
    Pssh, I've seen some of your code! (although nothing recent, admittedly, it was still nightmarish :( )
    Oh, I'm definitely not perfect. I don't know what you considered nightmarish about my code (though if you remember any examples I'd be interested to hear), but from my own observations I have a tendency to overuse Lua's binary operators to do one liners when the code would often be a lot more readable if I split things out (I justify that by telling myself that I'm never intending to give any of my code to anybody else, but I do end up doing that sometimes). I think I've rewritten every single part of my system at least once, so there shouldn't be any of my original code left at this point, but it also took me a while to figure out what style I wanted to use for coding in Lua so naming was (possibly still is in some places) inconsistent. In a lot of places, where the main focus is proving a concept/getting something working, there's lots of code repetition that should instead be moved into functions; that's the kind of second pass refactoring that I normally don't bother with unless I want to add major functionality somewhere.

    The major issues I see with code by other Achaeans are inconsistent - or just plain non-existent - indentation and other whitespace making it almost impossible to determine what code goes with which conditions, is part of a function, etc., large nested if statements (made worse by the previous point - tables are your friend, there's no need to be scared of them!), and inappropriate use of data types (in particular using 1 and 0 rather than true and false).
  • Antonius said:
    The major issues I see with code by other Achaeans are inconsistent - or just plain non-existent - indentation and other whitespace making it almost impossible to determine what code goes with which conditions, is part of a function, etc., large nested if statements (made worse by the previous point - tables are your friend, there's no need to be scared of them!), and inappropriate use of data types (in particular using 1 and 0 rather than true and false).
    GOD YES TO ALL OF THIS.

    Honestly the things I saw of yours wasn't "bad" they just hurt to look at. :p Like your massive index of tables:
    antonius.targetting.conf.requiredhits[classspec]
    Travesty! Looking through your limb counter you had up, I see so much stuff that could easily be condensed :(
  • Thanks Antonius, I'll keep what you said in mind as I learn and always keep an eye out for better ways to do things. Starting from zero though, right now I'm just happy to cobble together anything that works, even if it's ugly as sin.  :3
  • To expand on what's been said - I am by no means a professional coder, I do some coding at work, though again, not what I'm explicitly employed for.

    This is really just a way for me to work on other projects as I find it difficult to think up things I would actually need/utilise personally in Achaea.

    Comments in code would hopefully explain what each part is trying to achieve, and make it easy to edit/tear apart.

    [At work I am presently trying to rewrite a VB program that interacts with SAP/Sql and has no comments or information on what each sub/function does - they also have names like function1 and label1]
  • @Antonius can you rate me?

  • KlendathuKlendathu Eye of the Storm
    Alyxeri said:
    @Antonius can you rate me?

    Die in a ditch.

    Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."
  • Telinus said:
    To expand on what's been said - I am by no means a professional coder, I do some coding at work, though again, not what I'm explicitly employed for.

    This is really just a way for me to work on other projects as I find it difficult to think up things I would actually need/utilise personally in Achaea.

    Comments in code would hopefully explain what each part is trying to achieve, and make it easy to edit/tear apart.

    [At work I am presently trying to rewrite a VB program that interacts with SAP/Sql and has no comments or information on what each sub/function does - they also have names like function1 and label1]
    Are you rewriting it in VB or are you using a language that isn't totally awful now?
    Alyxeri said:
    Antonius said:
    The major issues I see with code by other Achaeans are inconsistent - or just plain non-existent - indentation and other whitespace making it almost impossible to determine what code goes with which conditions, is part of a function, etc., large nested if statements (made worse by the previous point - tables are your friend, there's no need to be scared of them!), and inappropriate use of data types (in particular using 1 and 0 rather than true and false).
    GOD YES TO ALL OF THIS.

    Honestly the things I saw of yours wasn't "bad" they just hurt to look at. :p Like your massive index of tables:
    antonius.targetting.conf.requiredhits[classspec]
    Travesty! Looking through your limb counter you had up, I see so much stuff that could easily be condensed :(
    Just be glad I used "conf" rather than "configuration" for the table that contains the configuration options for my limb counter!

    In all seriousness, namespacing is important (in my opinion), as is using meaningful variable names (though sometimes I'm guilty of using less than optimal names because I've already used the ideal name for something else in the script). I'd rather have slightly longer references because my code is properly namespaced and the variable names have meaning than risk potential conflicts with other pieces of code because a variable name gets reused; besides, I type reasonably fast and I usually store the value from a long reference in a local variable if it's going to be used more than once, so it's not a huge issue when writing the code (and I wouldn't ever consider it an issue when reading code, personally, but that's definitely a matter of taste - possibly it's more of an issue if you don't have much screen space?).

    Since I've brought up meaningful variable names, I just remembered another thing people have a strong tendency to do - and it's likely because a lot of tutorials do the same thing - is use meaningless names when iterating over a table with the pairs/ipairs functions. Using for i, v in ipairs(t) and for k, v in pairs(t) isn't great. Sure, i means index, k means key and v means value.

    But what is the key? The name of a person? The name of a class? A bodypart? Something else?
    What is the value? An entire object? A percentage? The name of a room?
  • edited October 2017
    Antonius said:
     is use meaningless names when iterating over a table with the pairs/ipairs functions. Using for i, v in ipairs(t) and for k, v in pairs(t) isn't great. Sure, i means index, k means key and v means value.
    I do this largely out of habit, more than anything. Usually for iterations where the values aren't very important to have 'proper' naming for. But I also don't give the vast majority of my code out, so it's not a big deal since I know what the tables are searching.

    For the 'specialised' stuff I make for people, or give out, I'll actually give it meaningful names / comments to ensure people don't have to come to me to ask what it's doing.

    And like I said, the deep namespacing in itself isn't bad. To me it just looks irksome to read, I'd rather split it into separate lists than have it like table1.table2.table3.table4.table5[setting] - personal preference, really, nothing wrong with doing it that way.

    Klendathu said:
    Die in a ditch.
    Rude.
  • Have you agree with @Antonius - seen a lotta bad code - but if it does the job, it does the job. That said, I decided to do something about it - check out this video I did for tips: 
  • Antonius said:
    Telinus said:
    To expand on what's been said - I am by no means a professional coder, I do some coding at work, though again, not what I'm explicitly employed for.

    This is really just a way for me to work on other projects as I find it difficult to think up things I would actually need/utilise personally in Achaea.

    Comments in code would hopefully explain what each part is trying to achieve, and make it easy to edit/tear apart.

    [At work I am presently trying to rewrite a VB program that interacts with SAP/Sql and has no comments or information on what each sub/function does - they also have names like function1 and label1]
    Are you rewriting it in VB or are you using a language that isn't totally awful now?
    Alyxeri said:
    Antonius said:
    The major issues I see with code by other Achaeans are inconsistent - or just plain non-existent - indentation and other whitespace making it almost impossible to determine what code goes with which conditions, is part of a function, etc., large nested if statements (made worse by the previous point - tables are your friend, there's no need to be scared of them!), and inappropriate use of data types (in particular using 1 and 0 rather than true and false).
    GOD YES TO ALL OF THIS.

    Honestly the things I saw of yours wasn't "bad" they just hurt to look at. :p Like your massive index of tables:
    antonius.targetting.conf.requiredhits[classspec]
    Travesty! Looking through your limb counter you had up, I see so much stuff that could easily be condensed :(
    Just be glad I used "conf" rather than "configuration" for the table that contains the configuration options for my limb counter!

    In all seriousness, namespacing is important (in my opinion), as is using meaningful variable names (though sometimes I'm guilty of using less than optimal names because I've already used the ideal name for something else in the script). I'd rather have slightly longer references because my code is properly namespaced and the variable names have meaning than risk potential conflicts with other pieces of code because a variable name gets reused; besides, I type reasonably fast and I usually store the value from a long reference in a local variable if it's going to be used more than once, so it's not a huge issue when writing the code (and I wouldn't ever consider it an issue when reading code, personally, but that's definitely a matter of taste - possibly it's more of an issue if you don't have much screen space?).

    Since I've brought up meaningful variable names, I just remembered another thing people have a strong tendency to do - and it's likely because a lot of tutorials do the same thing - is use meaningless names when iterating over a table with the pairs/ipairs functions. Using for i, v in ipairs(t) and for k, v in pairs(t) isn't great. Sure, i means index, k means key and v means value.

    But what is the key? The name of a person? The name of a class? A bodypart? Something else?
    What is the value? An entire object? A percentage? The name of a room?
    I have to try and add functionality to the pre-written system to take into account various other SAP tables.

    I've never worked with SAP tables before, there are a LOT of tables.. there's also a lot of crap naming conventions in the VB script, as well as in the stored procedures that are being used to then write into SAP.

    It's good fun. I've started just going through and adding comments to the code with what I think they do.
  • Sounds like I really need to use tables. My scripts are pretty much all nested IF statements. It does the job though -shrug-

    (Party): Mezghar says, "Stop."
  • Sobriquet said:
    Sounds like I really need to use tables. My scripts are pretty much all nested IF statements. It does the job though -shrug-
    When I started helping @Solnir with code he showed me a script with 45 elseif's. 

    It made me sad :(
         He is a coward who has to bring two friends as backup to jump people hunting.

  • Sobriquet said:
    Sounds like I really need to use tables. My scripts are pretty much all nested IF statements. It does the job though -shrug-
    If it works, it works. That's obviously the most important thing for hobby coding for a game.

    Whether or not a table would be suitable to replace an if chain depends on what exactly your nested if statements are doing, but I've seen quite a lot of code where people will have a long chain of if statements to check the value of variable X and set the value of variable Y accordingly (e.g. mapping an affliction to what curse to use). That's an obvious case where a dictionary lookup would be better, and - excluding the code to define the dictionary (one of the two types of table) - it takes that entire if chain and replaces it with a single line of code.
  • Well, in this case it's a pretty straight forward decision on the attack i use based on whether I'm wielding a sword, a hammer or a shield. Couple of extra bits to cover parrying, but that's about it

    (Party): Mezghar says, "Stop."
  • edited October 2017
    Antonius said:
    it takes that entire if chain and replaces it with a single line of code.
    I have this with a lot of things. Checking what affliction a class needs to stop their active cure, is done with a function that parses a table, for instance:
    target.lockAff = getLockAff(target.name)
    Also for converting venoms to their respective affliction, on weapon hits:
    local getVenomAff = toAffliction(envenomList[1])<br>gaveAffliction(getVenomAff)<br>
    both functions are reused in a few different scenarios, too, so it's extra nice. getLockAff is used for my prompt tags for example, to determine what the 'final' aff whatever class I'm playing needs, in order for a true lock to be registered.

    I try to think ahead a lot, to see if functions I write can serve multiple purposes. Saved me quite a lot of time and headaches.
  • Xaden said:
    Sobriquet said:
    Sounds like I really need to use tables. My scripts are pretty much all nested IF statements. It does the job though -shrug-
    When I started helping @Solnir with code he showed me a script with 45 elseif's. 

    It made me sad :(
    I've gotten a lot better since then!

    But.. it did do the job.
  • KlendathuKlendathu Eye of the Storm
    Solnir said:
    Xaden said:
    Sobriquet said:
    Sounds like I really need to use tables. My scripts are pretty much all nested IF statements. It does the job though -shrug-
    When I started helping @Solnir with code he showed me a script with 45 elseif's. 

    It made me sad :(
    I've gotten a lot better since then!

    But.. it did do the job.
    46 elseifs?

    Tharos, the Announcer of Delos shouts, "It's near the end of the egghunt and I still haven't figured out how to pronounce Clean-dat-hoo."
  • Yes.

    @Telinus Back to the original point though, I've always wanted something that would identify who was online (from qwho) on a city bounty list. Even if it just put an (x) next to their name or something, I think that'd be cool. Like check qwho, check city bounty list, boom if something matches it let's you know. Something to think about until you get higher priority requests.
  • edited October 2017
    Solnir said:
    Yes.
    Like check qwho, check city bounty list, boom if something matches it let's you know. Something to think about until you get higher priority requests.
    Something like this? :p

    First number is the number of the bounty, so I could do city bounty claim 243 to claim Halos's without having to sift through the board to find it.
  • Yup!  
Sign In or Register to comment.