User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Is LUA good for user scripting in games?

  1. #1
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Is LUA good for user scripting in games?

    The whole reason I requested the Custom User C Code object was so that users could add some custom code to thier levels in my game using only the functions and feature I had predefined, and thier own functions, just like in C based software. The problem with LUA is that it is more of an internal thing, and in my tests there isn't a good way to interact with it the way I want to. I am not going for speed or efficiency, I am going for the user ability to make thier levels more fun and unique by having more control over their level in the game.

    While LUA does seem easier to learn and is more user friendly, it takes up a bit more space and needs to have some work done to create a compression system than with C and others. For example; I will give two versions of code, LUA and C, that do the same thing:

    LUA:
    Code:
    if MyBooleanFunction()
    then
    DoMyStuff()
    end
    Not including NewLines, 40 characters.

    C:
    Code:
    if(MyBooleanFunction()){
    DoMyStuff();
    }
    Not including NewLines, 37 characters.

    What I want to know is if there is a possibility for the folowing things with LUA:
    -Ability to stop loops
    -Ability to run code step by step (for user debuggers)
    -Knowledge of wheather in a situation as above with the two code formats, which type (LUA or C) would take up less space
    -Ability to disable certian things and only use certian syntax forms (eg do not allow use of include scripts)

    And some more things. The point is that although people tell me LUA is exactly what I am looking for and will do what I want, it just doesn't. These are the things I am looking for to implement in my game, but I am not finding them where people tell me I will find them.

    LUA+ is an awesome extension and it does a very good job, it just doesn't fit in my situation. So, I want to know how I can get these things with LUA or other, and if this is a good idea. I don't want to have to make my own code parser in MMF2 with the features I need, that'd be too slow. Although MMF2's event interface allows me to do this easily it just won't do it faster than 1 FPS on most computers. :crazy:

    So, and suggestions or ideas?
    Working as fast as I can on Fusion 3

  2. #2
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    Err. Why does the length of the code in characters have any relevance?

  3. #3
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    Quote Originally Posted by LB
    compression system
    I want my levels to be compressed, and representing "then" or "end" with my system uses one character. So why not just forget trying to represent it as something else and then change to C code where it's already one character?
    Working as fast as I can on Fusion 3

  4. #4
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    Alright, let's ignore the compression then (since a compression algorithm would make the line very blurred - longer text can end up smaller compressed) and assume you're storing it uncompressed.

    We'll also assume that your scripts are to be downloaded from a server at 800 kilobytes per second (slow DSL).

    To take one second longer to download, the script would have to be 800 kilobytes longer. That's 819200 characters.

  5. #5
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    I'm not downloading any scripts. If you read my post, I am trying to allow users to code thier levels so they are more unique. And, as I also said in my post, I am not going for complete time efficiency, I just want it to be able to run at a reasonable 60FPS and have a small file size. I am having trouble doing the things I need to do with LUA, which is why I made the rquest for the Custom User C Code extension.
    Working as fast as I can on Fusion 3

  6. #6
    Clicker Multimedia Fusion 2
    Retriever2's Avatar
    Join Date
    Jun 2006
    Location
    United States
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    Okay ... how do I even tackle this...

    First, why Lua+ and not XLua?

    Second, people tell you Lua will do what you want because it will, or it will be very close within reason. Some of the things you are requesting are not reasonable and you will not see anyone implement them. Debugging, stepping, no one is going to link a full C debugger and compiler into an extension. I'm not sure if anything this could be done with .net either, but it's certainly not implemented currently.

    You can partially get around loop stopping with coroutines but they're not going to work with the ease of use that you want. You can get around disabling some features, like standard library functions (including code inclusion mechanisms) by setting them to nil. You cannot disable core syntax, but I can think of no language except perhaps metaprogramming languages that would give you the ability to selectively disable core syntax.

    Your "compression" comparison is extremely contrived and if you really dug into the language I think you could find that you can represent interesting code more compactly in lua than in C, or at least come out to a draw when you average it out.

  7. #7
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    Why do you want to compress locally stored scripts? All the sources I have on my hard drive are uncompressed, and they're all under 100 KB.

    Lua scripts are compiled to bytecode (and then again to machine code if LuaJIT is used), so the number of characters in the script has nothing to do with the FPS. Lua scripts will usually end up smaller anyway, because it takes a lot more code to do anything useful in C.

    EDIT: Retriever2 beat me

  8. #8
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    Sorry, I mean XLua, not LUA+. I have my exntion names confused when their names are so close.

    I don't want a compiler. I want a dynamic code interpretation system. LUA isn't exactly dynamic the way I need it.

    I wasn't trying to start an argument here, I am giving a few of my opinions and asking if what I am trying to do is reasonable. It seem you're telling me it isn't reasonable, so I will find another way.
    Working as fast as I can on Fusion 3

  9. #9
    No Products Registered

    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    I think you need to look more into LUA, it should be suitable for what you want.
    You just ened to hardcode the core part such as coroutines and such so its transparent to teh user and you can easily get your users to make their own scripts based on the core functions that you integrate into LUA.
    You are better off defining your own syntax and functions so that its you own custom script langauge they learn rather than LUA itself

  10. #10
    Forum Moderator Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module

    Join Date
    Jul 2006
    Location
    USA
    Posts
    461
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Is LUA good for user scripting in games?

    Lua (not all caps) is pretty dynamic. You don't "have" to compile it if you don't want to. If you know how to right elegant scripts, then any scripting language will get the job done and Lua in particular is one of the best choices available. It can do almost whatever you think other scripts can do. What you probably have in mind has more to do with pre-processing your inputs. After all how tough would it be to read "then" from the user and replace it with "{" internally?
    -Mokhtar M. Khorshid

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Where is a good place to get good sounds?
    By delta9857 in forum The Games Factory 2 - Technical Support
    Replies: 4
    Last Post: 25th November 2010, 12:34 AM
  2. MMF and Scripting
    By Pkeod in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 8th May 2008, 04:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •