Lua scripting for modding

Discussion in 'Clockwork Empires General' started by Kaidelong, Dec 6, 2012.

  1. Kaidelong

    Kaidelong Member

    Can has?

    And if so, have an event driven or reactive interface for changing variables?
     
    OmniaNigrum likes this.
  2. Essence

    Essence Will Mod for Digglebucks

    Haven't we already had this conversation? Didn't Nicholas basically already say "it's XML, deal with it"?
     
    OmniaNigrum likes this.
  3. Kaidelong

    Kaidelong Member

    How are the two mutually exclusive in any way? DHTML is entirely around the idea of embedded scripting in a markup language.
     
    OmniaNigrum likes this.
  4. mining

    mining Member

    Also this is CWE, Essence, if you didn't notice.

    @Gaslamp: All you need to do is expose some stuff for us to hook. Pretty please?
     
    OmniaNigrum and Kaidelong like this.
  5. jeremywc

    jeremywc Member

    They're not mutually exclusive, but that doesn't mean it's a good idea either. HTML was designed to be a displayed document format. DHTML is really just HTML + JavaScript and was born out of the need to make web sites more interactive. XML has evolved down a different path and is used more like a universal data storage mechanism. There's not really a need to add any interactivity to XML. The interactivity is already being handled by the language libraries you're parsing XML with. Embedding a scripting language like Lua inside an XML file would be inefficient. Generally you'd just allow the game to be accessed via Lua directly.

    tl;dr - If you decide to add scripting support for mods, you're probably just going to expose APIs to hook into.
     
  6. Kaidelong

    Kaidelong Member

    I mostly agree with all that, I just wanted to illustrate to Essence that the use of XML does not mean there is no role for a scripting language (unless, god forbid, a whole ad-hoc programming language starts to get rolled into XML over time, like what started happening in Dungeons of Dredmor).

    One note though, I do not really understand why it would be "inefficient" as in, how would the two approaches be any different other than the embedding one being a pain in the neck for everyone involved. That kind of inefficiency I understand perfectly, but I do not see how performance need be affected at all, save perhaps longer load times.

    Also, if not Lua, how about Scheme?
     
    OmniaNigrum and Essence like this.
  7. mining

    mining Member

    Scheme would be Fun.
     
    OmniaNigrum likes this.
  8. Alistaire

    Alistaire Member

    Tho; Lua would be sweet. Every item could be stored in a table (main_table["buildings"]["military"]["diggle_targetting_device"] = {"hp", "damage", "spell", "rate_of_fire", "range"} or something), and all spells could be made in functions (main_table.buildings.military.diggle_targetting_device.spell = func_bullets(damage, knockback, etc), and func_bullets(d, k, etc))

    So much want. But prolly ain't gonna happen..
     
    OmniaNigrum likes this.
  9. Kaidelong

    Kaidelong Member

    The really sad part is, it probably wouldn't even be that hard to implement, and may speed up development at their end.
     
    OmniaNigrum likes this.
  10. Nicholas

    Nicholas Technology Director Staff Member

    I actually really like Scheme, more specifically Guile.

    Lua scripting isn't happening because of two fundamental problems. First, Lua is not thread safe. You can run different Lua instances from different Lua states, but the interactions between our multi-threaded gameplay code and the multi-threaded Lua Stuff is just bad.

    Second, Lua gives you a lot more options for breaking things badly and in a mystery way that freezes the engine. Because it's Turing-complete, the category of things that can go wrong is much, much larger. I don't think you actually want a Turing-complete scripting layer in a game! Radical, I know, but there you have it.

    As far as XML goes, we are much better in CE than in Dredmor at catching and reporting errors effectively (having learned that particular lesson) so that should, hopefully, make people's lives a bit better. I should post some stuff for people to look at and comment on at some point.
     
    OmniaNigrum, mining and Kaidelong like this.
  11. Alistaire

    Alistaire Member

    It's more that I know Lua and XML, and not Scheme or Guile. Oh well.
     
    OmniaNigrum likes this.
  12. Kaidelong

    Kaidelong Member

    This just made my day. I too am a sub-turing language fan. However, I plead with you, do not force people to prove their code terminates. It is what adds a lot of the learning curve's steepness to languages like ACL2, and I get the impression many people including Essence prefer things to be relatively easy to get into and hack. Compare Java's checked exceptions way back when.

    Also, adding a turing complete interface may be worthwhile anyway as an "escape hatch" if someone finds they cannot implement what they want to do with the existing tools. It would be discouraged, of course, but it's analogous to the use of unsafePerformIO in Haskell where the programmer asserts that an operation is pure even if the compiler cannot prove it.
     
    OmniaNigrum likes this.
  13. Essence

    Essence Will Mod for Digglebucks

    Did I just get name-dropped in a conversation with the devs? That's...very odd.
     
    OmniaNigrum likes this.
  14. Nicholas

    Nicholas Technology Director Staff Member

    It's not a question of proving your code terminates; it's a question of having a language where code that does not terminate is impossible.

    That said: we have actually revisited this today. Micah is looking into it to see if it actually makes sense (having discovered that, yeah, you can do about 99% of what we want to do with the data-driven stuff, but that last 1% is elusive.) So stay tuned and we may tell you more in January.
     
    omeg and OmniaNigrum like this.
  15. mining

    mining Member

    :D:D:D
     
    OmniaNigrum likes this.
  16. Nicholas

    Nicholas Technology Director Staff Member

    Micah actually assembled a working prototype of Lua scripted game objects over the Christmas holidays, and I am sufficiently impressed/happy with it that we will be transitioning to this moving forward.
     
    Giygas, Createx, omeg and 6 others like this.
  17. Essence

    Essence Will Mod for Digglebucks

    Kaidelong is going to take Wandcrafting when he reads this.
     
  18. kikito

    kikito Member

    I just created this account to say: I love this so much.

    My favourite game-to-be may have my favourite scripting language.

    I'm so into this. Yes! :burliness:
     
    Kazeto and Createx like this.
  19. mailersmate

    mailersmate Member

    Hi

    can anyone link to someplace that explains the Lua syntax? I know a few languages and just want to be prepared for when we get our hands on CE. Also do we have any graphic designers amongst us?
     
  20. Kaidelong

    Kaidelong Member

    http://www.lua.org/manual/5.1/manual.html

    So far this has pretty much been all the documentation I needed on the language itself.
     
    Kazeto and Essence like this.