Jump to content

Lua question


Alienhead
 Share

Recommended Posts

I got a simple table I create to store some misc. objects loaded from a map.
For example I'm caching a list of 'breakable' objects after I load a map :

        for x=0,world:CountEntities()-1 do
                local entity = world:GetEntity(x)
                local name = entity:GetKeyValue("name") 

               if name == "breakableglass" then
                   entity:Hide()
                   table.insert(bglass, {entity = entity, active = true })
               end

        end

 

This works fine the first pass through,  during my cleanup,  before loading a new map,  I simply reinitialize the table :

       bglass = {}

Now on the next pass through LE kicks back this error

Object table not found.

 

The table is clearly created in a global scope outside of the functions.

I then thought, okay I won't reinitialize the table, I'll just remove it's entries.

    for r, g in pairs(bglass) do
        table.remove( bglass, r )
        g= nil
    end

Still I get :

Object table not found.

on the next pass, works fine when initially running the application.,  just can seem to reuse this table whatsoever.   It's these kinda quarks that take so long to do anything in LE, to the point I almost dread adding anything new to my project. in fear of everything breaking...   so fragile.

Ironically, this error only occurs or 'shows up',  I should say,  when running in non-debug mode.   Running in debug just produces a silient client crash.

 

Does anyone have an answer to an Emitter question - Are emitters self-removed ( deleted ) upon reaching the end of their play cycle?
Im starting to think alot of my problems are coming from removing debris and smoke emitters after they are played out.

Would it be better to load, say like, 10 smoke emitters on mapload(), then just move these same emitters around the screen as they are needed and not delete/remove them after play ?

Link to comment
Share on other sites

  • 2 weeks later...

Just to post a follow up on this topic .  I spent the last week and half rewriting a good portion of my code to accommodate for the cache system I've implemented. No longer do I remove a single object or Release() anything during live play. I cache load a certain amount of objects I'll need,  example: 10 spark emitters get loaded, the code calls for one that's not in use, it then gets used by the calling function and tossed back to the cache pool awaiting another turn.   I actually do this with any and everything in the code now - from emitters, to decals, to objects to mdl's etc..   The results is fantastic.  I no longer have any random lock ups or freezes, the maps load and unload with ease and the mesh deforming problem all but disappeared under this new system. Basically just let LE handle all the removal via world:Clear() and reframe from using anything 'Load' in live stream gameplay.   I address the lua table problem I was having ( mentioned above ),  I used a system simular to tokenization, in short combined table arrays with less tables but using array static identifiers to differentiate between the different fields of data used in the tables. In short, I went from using close to 100 different tables down to 4 and the old issue I was having vanished. :)

I've actually noticed a pretty decent jump in framerate and overall smoothness as well.  Now that's all done I'll be glad to return to actual game developing..  The show must go on !  

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...