+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16

Thread: Lua for Beginners?

  1. #1
    Ascendant
    Join Date
    Feb 2011
    Posts
    1,526

    Default Lua for Beginners?

    Hiya guys.

    I have been wondering - how easy is it for a person without LUA experience to pick it up and learn? I have coded in HTML and CSS before, but this is a language I've never heard of. Is it similar in it's accessability?

    I looked around for help for beginners, but they all assume you know something about LUA to begin with. I couldn't find any that started from scratch. From scratch I mean really basic questions like "can I code in Notepad or do I need a special program", "Can I preview my work before I put it into game - similar to how, for HTML, I can preview before I upload.", and "How hard is it to pull information from Rift to make a file that uses game attributes in different ways?"

    I see all the great work that more experienced LUA designers can create. I don't know if I want to make an addon myself - more likely it would be a side project to keep me entertained and learning new skills. Does it take a long time to learn how to make small little programs?

    Lastly, I learned a lot of my HTML from looking at source files for websites I liked - Is this possible with LUA also? (This goes hand in hand I think with the preview question - I find it easy learn HTML by tweeking a section of code and previewing to see the effect)

    Anyways.. Thanks for answering these questions if you can.

  2. #2
    RIFT Guide Writer Noshei's Avatar
    Join Date
    Feb 2011
    Posts
    1,886

    Default

    The best place to get started is with the Programming in Lua book. You can find it online here http://www.lua.org/pil/#1ed

    It is a ton of information, but is very much worth it.

  3. #3
    Plane Touched
    Join Date
    Jan 2011
    Posts
    281

    Default

    Quote Originally Posted by Milyssa View Post
    I see all the great work that more experienced LUA designers can create. I don't know if I want to make an addon myself - more likely it would be a side project to keep me entertained and learning new skills. Does it take a long time to learn how to make small little programs?

    Lastly, I learned a lot of my HTML from looking at source files for websites I liked - Is this possible with LUA also? (This goes hand in hand I think with the preview question - I find it easy learn HTML by tweeking a section of code and previewing to see the effect)
    You can download the standalone LUA interpreter from the LUA website (www.lua.org). Then get a text editor (notepad++ would be my recommendation). That's all you need to start writing small programs, and you can simply run them via the commandline.

    Creating addons for Rift requires a bit more work, but its not bad...have a look here. Download the example addons, and study the riftaddon.toc files (with the editor). That should give you enough of an idea of how to include addons in Rift.

    If you want to look at example code, you are in a great position, since LUA files are all source code. You can go to addon sites like riftui or curseforge and download addons of other people to study the files.

  4. #4
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    Lua, which is Portuguese for "moon" and the name of the programming language, is not an acronym. Just saying.

    Anyway, on topic, I suggest checking out the RiftUI Wiki guides, and feel free to sign up for free and contribute.

    Also, the book World of Warcraft Programming, Second Edition, by James Whitehead and Rick Roe, while WoW-centric, still is chock full of basic Lua programming tips and practices that work fine with Rift, because they are generalized to Lua itself. At least half the book is like that.

  5. #5
    Ascendant
    Join Date
    Feb 2011
    Posts
    1,526

    Default

    Thank you all for the tips and advise.
    I'll look into that book from Wow. Suppose the skills required for Rift and WoW would be very similar so anything it has to teach me would be a good start.

    I looked at the source code in the examples here, but I think I'll need a background in the format before I step into that. The TOC file makes sense to me. All the tutorials I've found online deal only with the TOC file. But its the meat of it that I cannot follow. Perhaps because I don't know any of the command language yet.

    Thanks again.

  6. #6
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    The "meat" is simple. Rift, like WoW, runs on Events. Like their name, Events "fire" when something happens: damage is done, a buff is gained, a spell is cast, etc and so on. While every Event available to us currently is documented, not every Event is available. Those will come in time, as ZorbaTHut and his crew improve Rift's addon system.

    In order to look for an Event, you must register for it, passing the Identifier of the addon, a function, and a string description of what the function does. Once the Event fires, the function is automatically called, where in you process the code you want done.

    The Inspectors are lookup tables that return information like item names, player locations, bank or mail contents, etc.

    Both Inspectors and Events in Rift are based on tables (arrays in other languages) so if you understand those, you are good to go.

    The addon Trion Development Tools really should only be installed on the Player Test Shard, because it's a drastic drain on performance. It's main purpose is to pull more complete documentation from Events and Inspectors, above and beyond the official docs in these forums. TDT also is not a good addon to look and see how things are done because it is so complex. Check out other addons instead.

    One other thing: if you are wondering where the XML files are, there are none. ZorbaTHut (wisely, I think) doesn't like XML for UI coding, and thus Rift does not support XML.

  7. #7
    Ascendant
    Join Date
    Feb 2011
    Posts
    1,526

    Default

    Thank you again for putting it into simpler english. I wonder if there is a Lua programing for Dummies or an Idiot's guide. They are always really good at bringing things into simple language until you get a handle on what is being said (That's how I learned flash and some CSS)

    Let me rephrase what you have said to see if I fully understand.

    There is a table - a list if you will - of events that could happen in game. (If I remember correctly, I saw that list in Documentation here in the API forums)
    Could be anything action oriented - Like a player casting their own buff or a player being hit with a mob debuff (correct?)

    Your Lua file - the meatie one, not the TOC, tells your program to watch for this "event" and also what you want to happen when such an event happens (correct?)

    I think that part makes sense to me. Event based triggers make a lot of sense. I will have to do some reading about how to format my "When XYZ happens, perform ABC action/display".

    In terms of Events though - I've seen addons for WOW that were bag related.

    The really tricky ones that jump all your bag slots into a massive single bag - or go one further and allow you to divide up your bag slots into which ever configuration you like. (One Huge 40 slog bag or 4 10 slot bags or 10 4 slot bags etc)

    That is not really an event - unless you count "Open bag" as even. Same for things like Seeb's Meriesoux addon. I don't understand what event that is actioning - unless /b IS the event. Maybe I need to expand my understanding of event.

  8. #8
    RIFT Guide Writer Noshei's Avatar
    Join Date
    Feb 2011
    Posts
    1,886

    Default

    Quote Originally Posted by Milyssa View Post
    I wonder if there is a Lua programing for Dummies or an Idiot's guide.
    not sure how good this is, but found this: http://lua.gts-stolberg.de/en/index.php

  9. #9
    Champion Lorandii's Avatar
    Join Date
    Jun 2011
    Posts
    516

    Default

    For a Rift bag addon, check out Imhothar's Bags, but for a beginner, the code might be a bit thick to look at for your first run.

    As for "Lua for dummies", I don't think there is such a book, but then again, I would not be all that surprised. In the meantime, check out the links provided earlier in this thread to both lua.org and RiftUI Wiki. Also, get the book I mentioned.

    Here is an example addon that prints "Hello World" to the chat console (we can't print messages to Say, Yell, Guild, etc that I know of yet). The example also contains some commented lines that the Rift Lua interrpeter will ignore.
    Code:
    -- this is a commented line, which begins with two hyphens
    local MyAddon = {} -- everything after these hyphens is ignored
    local playerName = Inspect.Unit.Detail("player").name
    
    --[[
    this is a comment block, started with two hyphens
    followed by two open square brackets
    which will be closed with two close square brackets and two more hyphens
    ]]--
    
    -- since all addons are tables, and we don't want to
    -- confuse other addons, we made the variable MyAddon local to the addon
    -- we also made the variable playerName local to the addon
    
    --[[
    okay, yes, all events are tables, thus the event Event.Unit.Availability.Full
    can be broken down as follows, you should never do this
    I am only putting it here by way of example
    Event = {}
    Event.Unit = {}
    Event.Unit.Availability = {}
    Event.Unit.Availability.Full = {} <-- the actual event
    ]]--
    
    -- now let's add our function to the event table
    -- see the Wiki for more details
    table.insert(Event.Unit.Availability.Full, {MyAddon:Hello, "MyAddon", "Say hello"})
    
    -- when the event fires, it will also fire this function
    function MyAddon:Hello()
        Print("Hello to me!")
        Print(("My name is %s"):format(playerName))
    end
    So yes, there is indeed a table of events, but you should only concern yourself with the actual event, which is also a table unto itself. Your guess about action oriented is correct, yes. You can hook multiple events in the same Lua file, with their own functions that do stuff.

  10. #10
    Ascendant
    Join Date
    Feb 2011
    Posts
    1,526

    Default

    Thanks again. I think my best next step is to open up that wiki and read through it in bits. Maybe it'll have small applications that I can try out and tinker with.

    My local Chapters does not have the warcraft book, but I can order it in - so I have to waite for it. (Not available as e-book, that I could find)
    AH ha.. nope.. second edition is a ebook - fantastic!
    Last edited by Milyssa; 07-21-2012 at 09:52 AM.

  11. #11
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    Hi Mylissa,

    Coming from a HTML and CSS background, unfortunately, won't be much help to you. If you've ever written any JavaScript, that would be much closer to what Lua is. Lua is a programming language, which neither of those are.

    Hopefully I'm not patronising you, but it sounds like you're looking to learn the basics of programming first? The good news there is that Lua is a nice simple language to learn, so it's probably a really good place to start.

    When it actually comes down to it, there aren't many keywords to learn in Lua, the tricky bit is working out what to do with those keywords to make something useful happen!

    I'd recommend you start by installing Lua for Windows.

    Once you've got that installed, you'll have a new program in your Start menu called SciTE. This is a text editor that is all set up ready to run Lua programs.

    Run this editor, and save a new file from it called Test.lua (it has to have a .lua extension)

    Then type in the following:

    Code:
    print("Hello Milyssa")
    Press F5, and the program will run. You'll see the output at the bottom of the editor like this:

    Lua for Beginners?-milyssa.jpg

    The red arrow I've scrawled on there is pointing to the output from the program. Every time you hit F5, your program will run and write it's output here.

    So, for example, you could change your program to read:

    Code:
    myname = "Milyssa"
    for i = 1,10 do
      print("Hello " .. myname)
    end
    And it'll write the message 10 times.

    Again, I'm really sorry if this is patronising, but I thought it sounded like you needed a boost getting started

    Good luck!

    - Wild
    Last edited by DoomSprout; 07-21-2012 at 01:20 PM.

    Gadgets: Unit Frames and Other Stuff for RIFT

  12. #12
    Ascendant
    Join Date
    Feb 2011
    Posts
    1,526

    Default

    no no, i AM a total newbie when it comes to programming - but not adverse to learning through self study. Thanks for the starting tips.

  13. #13
    Rift Chaser NerfedWar's Avatar
    Join Date
    Dec 2010
    Posts
    377

    Default

    Wrote a few tutorials some time ago, slowly moving them over to my new website. Got a few moved already which should get you started: http://www.nerfedwar.net/
    You may find tutorial 2 which focuses on the Lua language itself is somewhat easier to follow than the official Lua manual. From there, the lua manual will help with more advanced topics.

    Key resources for me include:

    * RiftUI Wiki - http://wiki.riftui.com/Main_Page
    * Seebs API Docs - http://www.seebs.net/rift/live
    * This forum - http://forums.riftgame.com/rift-gene...i-development/
    * Great new Addon Developer Resources Thread by Imhothar - http://forums.riftgame.com/rift-gene...resources.html


    Good luck !
    Last edited by NerfedWar; 07-21-2012 at 11:31 PM.
    ...the internet treats censorship as damage, and routes around it...
    NerfedWar Addons and Tutorials
    * Note: tutorials are currently being ported to the new site.

  14. #14
    Ascendant
    Join Date
    Feb 2011
    Posts
    1,526

    Default

    I saw your tutorials, and thank you for the new link, because the one I had only had tutorial one and two and it frustrated me to know I would loose out on a tutorial after step 2. But if they are progressing I will have a look.

    I did pick up that WOW Lua book and had a look through the opening pages. It seems easy to follow as well. I'll slowly pick it up - but I'm sure I'll be back with questions.

    I like self study though.. Small projects and side educations like this give me goals to shoot fot. I'm not planning to make an addon right out of the gate.. but I fancy the idea that I COULD if any brilliant idea struck me. Or at the very least, understand what is making the addon I use work.

  15. #15
    Telaran mistmare's Avatar
    Join Date
    Jun 2012
    Posts
    85

    Default

    I used the Warcraft Programming 2nd Edition and just read Addon code (not just Rift, I read a bunch of WoW Addon code, larger sample size, so many different things) that did things similar to what I liked. I l just printed out the code and read it. It pays to check. You may even find someone did your idea better already, in which case do it better or consider something else. Also, some people write cleaner code than others. Some people like modular, well-commented code that's easy to understand. And some people like to write unreadable spaghetti nonsense that's impossible to update because the variable names aren't even descriptive.

    I found that LUA book on version 5.0 that's available for free online that everyone says is awesome useless and boring. To each his or her own I guess.

    I started on 7/13. Finished my first Addon, which is fairly spiffy in its wonderful use of (draggable, deletable) Tacky Notes to help you remember household tasks within the RIFT UI. There are no other similar addon programs that I'm aware of. It still needs some fixing to make it more efficient (not that the enduser will notice, but it will bug me that I used some kludges and didn't reuse contexts) and modular. I'm assuming I missed some bugs too (esp. inter-Addon) despite testing it on several machines..

    My next addon will go a little heavier on the Event Handlers. PVP-related, methinks.

    I knew a little C++ from years ago, and I regularly use AHK. Lua IMO is not so hard (even though its treatment of arrays annoys me and I hated it at first, it has a lot of good qualities), it was figuring the game API and how to use lua effectively with it, which is where that book came in. Boy, Whitehead & Roe are solid.

    Oh the Spec sheet is essential too. Zorba has posted it several times, but you can also dump it from within the game. The RiftUI Wiki is pretty good too at the nuts and bolts of that.

    If you programmed before, esp C/C++, this language isn't so bad. It's close cousins w/C/C++ except an obvious glue language.

    I use Notepad++. Some people use fancier stuff, but it works amazingly well (I use it for AHK too). It also has built in stuff for each programming language, so if you tick "lua" the formatting will be gorgeous.

    I just ran the addon in game whenever I had a new build with the ReloadUI addon.
    Last edited by mistmare; 07-26-2012 at 08:50 PM.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

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