Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

General Script Help

TelinusTelinus Posts: 131Member ✭✭✭ - Distinguished
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.
Caynix

Comments

  • CaynixCaynix Posts: 28Member ✭✭✭ - Distinguished
    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
  • CaynixCaynix Posts: 28Member ✭✭✭ - Distinguished
    Wait nevermind, messaged you!   =)
  • AntoniusAntonius Posts: 4,114Member @@ - Legendary Achaean
    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.
  • SerinSerin Posts: 43Member ✭✭ - Stalwart
    edited October 11
    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!
  • AlyxeriAlyxeri Posts: 128Member ✭✭✭ - Distinguished
    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 :( )
    Tysandr
  • AntoniusAntonius Posts: 4,114Member @@ - Legendary Achaean
    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).
  • AlyxeriAlyxeri Posts: 128Member ✭✭✭ - Distinguished
    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 :(
    Caelan
  • CaynixCaynix Posts: 28Member ✭✭✭ - Distinguished
    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
  • TelinusTelinus Posts: 131Member ✭✭✭ - Distinguished
    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]
  • AlyxeriAlyxeri Posts: 128Member ✭✭✭ - Distinguished
    @Antonius can you rate me?

    TysandrCaelan
  • KlendathuKlendathu Eye of the StormPosts: 2,518Member @@ - Legendary Achaean
    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."
    Caelan
  • AntoniusAntonius Posts: 4,114Member @@ - Legendary Achaean
    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?
    Anze
  • AntoniusAntonius Posts: 4,114Member @@ - Legendary Achaean
    Alyxeri said:
    @Antonius can you rate me?

    10/10! Perfect troll post.
    Caelan
  • AlyxeriAlyxeri Posts: 128Member ✭✭✭ - Distinguished
    edited October 12
    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.
  • VadimusesVadimuses Posts: 962Member @ - Epic Achaean
    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: 
    TysandrSerin
  • TelinusTelinus Posts: 131Member ✭✭✭ - Distinguished
    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.
  • SobriquetSobriquet Posts: 1,546Member @@ - Legendary Achaean
    Sounds like I really need to use tables. My scripts are pretty much all nested IF statements. It does the job though -shrug-
    image
  • XadenXaden Posts: 1,954Member @@ - Legendary Achaean
    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 :(
    Sobriquet
  • AntoniusAntonius Posts: 4,114Member @@ - Legendary Achaean
    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.
  • SobriquetSobriquet Posts: 1,546Member @@ - Legendary Achaean
    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
    image
  • AlyxeriAlyxeri Posts: 128Member ✭✭✭ - Distinguished
    edited October 12
    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])
    gaveAffliction(getVenomAff)
    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.
  • SolnirSolnir Posts: 301Member ✭✭✭ - Distinguished
    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.
    Xaden
  • KlendathuKlendathu Eye of the StormPosts: 2,518Member @@ - Legendary Achaean
    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."
  • SolnirSolnir Posts: 301Member ✭✭✭ - Distinguished
    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.
  • AlyxeriAlyxeri Posts: 128Member ✭✭✭ - Distinguished
    edited October 12
    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.
  • SolnirSolnir Posts: 301Member ✭✭✭ - Distinguished
    Yup!  
  • AlyxeriAlyxeri Posts: 128Member ✭✭✭ - Distinguished
    Solnir said:
    Yup!  
    And for anyone else who wants it.
    http://forums.achaea.com/discussion/5960/city-bounty-list#latest

Sign In to Comment.