Jump to content

Dexter

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by Dexter

  1. Hi,

    I'm trying to get lua examples for Map's Save and Reload functions working. If you try the example from https://www.ultraengine.com/learn/Map_Save?lang=lua , sol complains about args (with a StreamBuffer at least). It's not clear to me what to feed it for in-memory stuff.

    I assume it's outdated because it's trying to call this

    scene:Save(stream, "game.sav")

     

    But save and reload do not take a string whatsoever as a second arg in lua docs. I assume changing the examples to do something like this is the way?

     

    local buffer = CreateBuffer(1024)
    local stream = CreateBufferStream(buffer)
    
    -- Create a scene
    local scene = CreateMap()
    
    -- .... 
    
    -- Save the starting scene to an in memory buffer
    scene:Save(stream)

    This appears to work, but it's unclear to me how to do the next two things:

    1. seek to beginning of stream: I tried this `stream = CreateStreamBuffer(stream)`. an API to seek to beginning of oft-reused buffers for cute tricks would be nice though

    2. Actually reload a map from memory? `Map:Reload(Stream)` complains about args as well when trying a stream arg, it appears only the unary string function exists.

    I understand I can work around it with disk like so, maybe the old API was shorthand for this. But I'd like to avoid all disk I/O for reasons

    scene:Save('foo.sav')
    
    -- Main loop
    while not window:Closed() and not window:KeyDown(KEY_ESCAPE) do
        -- Reload the starting scene when space key is pressed
        if window:KeyHit(KEY_SPACE) then
            scene:Reload('foo.sav')
        end
        world:Update()
        world:Render(framebuffer)
    end

     

    If something like "`scene:Reload(stream, LOAD_DEFAULT)`" worked again that would be the money. Appreciate any input

  2. 1 hour ago, Josh said:

    Lua DLL modules need to be placed in the /Modules folder. Lua code file modules should be placed in /Source.

    Enet is nice to use but it doesn't support NAT punch-through, so it might not be very useful for modern networked games.

    The P2P system is pretty nice because when the lobby owner leaves, ownership gets transferred to another player. This acts like a dedicated server without needing to program and maintain one.

    ahh great, I had dlls next to exe, thanks. Fair point on ENet, just throwing out there are alternatives

    • Like 2
  3. Beware steamworks lobby is P2P only. This made me curious about something else tho, it appears lua's require doesnt work? I was trying it with enet, eg `require "enet"` and it blows up. If require isnt working, that would be nice to become available so the reams of existing solutions (eg, love community) could be used

     

    I did look at the Plugin architecture but that looks unrelated

  4. I had to do something kind of similar with a bowling ball. What I did was checked velocity, and if it was below a threshold I flat out set velocity to the minimum for that axis in UpdatePhysics()

     

    I'd recommend to update your velocity in UpdatePhysics() if possible, if I recall correctly it always runs at a constant rate regardless of FPS, where UpdateWorld does NOT. if you have to set velocity in update world, scale it by Time:GetSpeed() so its not jittery

  5. I'm working on something using lua right now and it' starting to get big to the point I want to better manage the code. I've considered two things: trying to use flowgraph for all gameplay code or just switching to C++ which I would prefer.

     

    I searched a bit and only found the suggestion of using hooks. I'd like placing something in the editor, and then pointing a C++ class at it for behavior but that doesn't seem to exist.

     

    Only idea I have so far: use a pivot and a key value pair with something like ("ClassName", "MyClass") and searching entities on load and gluing things up there, but that would probably take RTTI :(. What I'm basically after is avoiding creating objects procedurally.

     

    Am I missing something obvious? Anyone else handle this? If not, has anyone had massive flowgraphs handling gamplay instead of massive player luas?

    • Upvote 1
×
×
  • Create New...