User Tag List

Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 34

Thread: Object-based MMF Interface

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

    Object-based MMF Interface

    I've been experimenting with an object-based model for XLua's MMF interface, which would exist as a separate loadable library (and maybe some time in the future the increasingly large interface would be separated from the XLua core). How much interest would there be in this kind of model?

    Instead of exporting an ID and passing it to each API call to interact with an object, the object would be exported as an object table, assigned to a variable of your choice. You'd be able to directly read or write most attributes, other methods would exist as member functions, e.g.
    Code:
    -- Some object is exported to the variable 'obj'
    local xCoord = obj.x
    obj.angle = 45
    obj.values[3] = 100
    obj.moveToFront()
    Each object would only expose fields and methods it safely supports. You could add new fields to the tables to hold associated data without affecting its MMF state. There's also the possibility of directly representing different kinds of objects, like object classes, collision masks, surfaces, etc. Some of the API would continue to exist in its current form, the parts that deal with global state and don't require object IDs passed around.

    The tradeoff is a small speed hit for the meta-indexing, but probably less than if you were to implement similar management on top of the existing API.

  2. #2
    No Products Registered

    Join Date
    Jun 2006
    Posts
    625
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Object-based MMF Interface

    I think it's a great idea. I'm not very used to Lua yet, but I think this syntax would be far easier to read/write/understand/debug, and most of the time, performance is not a big problem anyway.

    Users that really need critical perfs are aware this could be a bit slower, and will avoid using this system.

  3. #3
    Clicker Fusion 2.5 DeveloperSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,739
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Re: Object-based MMF Interface

    It does look very promising, I myself always would have preferred having the MMF interface object-based, but never asked whether you would realize this one day; I thought there wasn't much general interest in this. Anyway, as I said, I'd love this, and I wouldn't mind a minor speed hit.

  4. #4
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Aug 2006
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Object-based MMF Interface

    This sounds great

  5. #5
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module
    James's Avatar
    Join Date
    Jun 2006
    Location
    Newcastle, UK
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Object-based MMF Interface

    That sounds beautiful! These are all things I would have loved to have seen in Lua+, so it's great to see them being implemented in XLua. Kudos!

  6. #6
    No Products Registered

    Join Date
    Aug 2006
    Posts
    984
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Object-based MMF Interface

    sounds good to me

  7. #7
    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: Object-based MMF Interface

    Quote Originally Posted by xyzzy
    sounds good to me
    Well you already got the sneak preview anyway.

    I'm glad to see the positive response.

  8. #8
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jul 2006
    Location
    Denmark
    Posts
    1,812
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Object-based MMF Interface

    Very neat, while already somewhat possible to do with the current api, the above would definitely make things a lot easier.

  9. #9
    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: Object-based MMF Interface

    At the same time I am expanding the API in ways not currently possible

  10. #10
    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: Object-based MMF Interface

    I want to take a moment and share (in code) some of the way things are changing

    Code:
    -- On the frame, we've created a bunch of instances of a "Goomba" active object.  We've also got some "Koopa Shell"s
    
    -- An object class represents an object collectively
    -- An object represents a single instance
    goombaClass = mmf.NewObjectClass("Goomba")
    koopaShellClass = mmf.NewObjectClass("Koopa Shell")
    
    -- We can get objects from a class
    goombaList = goombaClass.objectList()
    
    -- And operate on them all
    for i,goomba in ipairs(goombaList) do
      if (goomba.overClass(koopaShellClass)) then
        -- When we destroy an object, the lua table backing it will
        -- disable itself, so even if we try to use it we're safe
        goomba.destroy()
      end
    end
    
    -- We can store our own data or methods with objects or object classes.
    goombaClass.step = function(obj)
      obj.x = obj.x - 1
    
      -- Speaking of names, now you can access alt values and strings
      -- by their names if you defined them in the editor
      obj.y = obj.y + obj.values['gravity']
    end
    
    for i,goomba in ipairs(goombaList) do
      -- Note, I still need to do some exploring but I may be able to
      -- get proper inheritance working with these special objects, thus
      -- avoiding needing call the class method via the class object
      goombaClass.step(goomba)
    end
    
    -- What am I doing here?
    goombaClass = nil
    collectgarbage()
    
    -- Oh no, I lost my class object with my custom defined method!
    -- But actually...
    goombaClass = mmf.newClassObject("Goomba")
    goombaClass.step(goombaClass.randomObject())
    
    -- ... the function is still there.
    goombaClass2 = mmf.newClassObject("Goomba")
    
    -- In fact goombaClass and goombaClass2 are the same table.  The
    -- library will keep a persistent reference of every object or 
    -- object class created, and always return the same table.
    So that's a little preview of the new things I've accomplished with the library.

    I'd like to hear anyone's suggestions on how you think the API should be designed, what should be included, issues like 1- vs 0-based indexing, etc. I never went out looking for input the first time I designed it, but now's your chance.

Page 1 of 4 1 2 3 ... LastLast

Similar Threads

  1. Interface Bar Object v1.0
    By DanielRehn in forum Released Extensions
    Replies: 2
    Last Post: 27th October 2013, 04:54 PM
  2. Interface Bar Object - Help Needed
    By Bowler in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 31st July 2012, 12:12 AM
  3. Interface Bar Object v1.0 released!
    By DanielRehn in forum Extension Development
    Replies: 40
    Last Post: 7th September 2008, 05:36 AM
  4. Interface Bar Object v1.0
    By mmf2 in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 11th August 2008, 01:34 AM
  5. MMF 2 - Object Interface Question
    By droberson in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 15th March 2007, 10:04 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
  •