Jump to content

thehankinator

Members
  • Posts

    436
  • Joined

  • Last visited

Posts posted by thehankinator

  1. In your example if you print out mpac what does it show?

    Prints out garbage because the format bytes are not always alpha numeric when printed as a character plus I don't think the floats are encoded in a way that is human readable when packed. Gotta print each character as a byte. To inspect the packed data I did:

    str_mpac = ""
    for i=1, string.len(mpac) do
      str_mpac = str_mpac..string.format('%02X', string.byte(string.sub(mpac,i,i)))
    end
    System:Print(str_mpac)
    

    Which printed

    9283A179CA400EF9DBA178CA3F8FBE77A17ACA4056147B83A179CA40A77CEEA178CA4083EF9EA17ACA40CB0A3D
    

  2. Is this packing library available in C++ as well? I wouldn't recommend anyone really having a Lua server but instead a C++ server app if possible.

    I agree, I wouldn't do any heavy lifting in Lua. They have libraries for like every language, for C/C++ there are multiple implementations to choose from.

     

    http://msgpack.org

  3. I rebuilt lua-enet and linked it to LuaJIT 2.0.2 and enet 1.3.13. The significant result with this build is you don't need to duplicate lua51.dll (Step 4 of Rick's post). I've not thoroughly tested it but if anyone wants it I'll upload it.

  4. I haven't tried it with lua-enet but you can use lua-MessagePack to encode arbitrary data into a string. It isn't too space efficient but it should work if you don't have a large amount of things to synchronize.

     

    http://fperrad.github.io/lua-MessagePack

     

    Here is an example of how I encoded a couple Vec3s into a string to be sent via lua-enet (or whateva)

     

    mp = require 'Scripts/Functions/MessagePack'
    
    thing1 = Vec3()
    thing1.x = 1.123
    thing1.y = 2.234
    thing1.z = 3.345
    
    thing2 = Vec3()
    thing2.x = 4.123
    thing2.y = 5.234
    thing2.z = 6.345
    
    data = {{x=thing1.x, y=thing1.y, z=thing1.z}, {x=thing2.x, y=thing2.y, z=thing2.z}}
    
    mp.set_number'float'
    mp.set_array'with_hole'
    mp.set_string'string'
    
    mpac = mp.pack(data)
    
    System:Print("Len="..string.len(mpac))
    
    unpacked_data = mp.unpack(mpac)
    
    System:Print("pos.x="..unpacked_data[1].x.."pos.y="..unpacked_data[1].y.."pos.z="..unpacked_data[1].z)
    System:Print("pos.x="..unpacked_data[2].x.."pos.y="..unpacked_data[2].y.."pos.z="..unpacked_data[2].z)
    

     

    Result

    Len=45
    pos.x=1.1230000257492pos.y=2.2339999675751pos.z=3.3450000286102
    pos.x=4.1230001449585pos.y=5.2340002059937pos.z=6.3449997901917
    

    45 bytes compared to 24 if it was raw c++. Not ideal but it'd work.

     

    EDIT: I'm dumb, require works fine, no change required to MessagePack.lua

    • Upvote 1
  5. I'd use GetEntityNeighbors() function in Scripts/Functions/GetEntityNeighbors.lua.

     

    You could do something like:

    local radius = 10
    local entities = GetEntityNeighbors(self.entity, radius, true)
    
    for e=1, #entities do
     if entities[e].script.health ~= nil then
       --deal damage
     end
    end
    
    • Upvote 2
  6. Excellent, that's what I needed - thanks!

     

    So with Lua and Leadwerks in general, in order to keep a script 'alive' does it always need to be attached to an element (like a pivot) in the scene? For instance if I wanted to create a script that tabulates what Journal entries the player has selected over the course of the game I would need to attach this 'tabulation.lua' to a something like a pivot - yes?

    A script that is attached to an element will only stay alive until you call world:Clear() (this is done when you load a new level for instance). For something to persist through loading levels you would probably want to use a global variable to store that information. You can also load scripts in Main.lua, the items in those scripts would be global and would persist through a world:Clear(). This tutorial talks more about global variables. Bare in mind that the Journal script will likely need to be modified to use global variables to track progress through a world:Clear()

     

    http://www.leadwerks.com/werkspace/page/tutorials/_/variables-r14

  7. What I've done in the latest build (beta branch) is I set the MSAA setting to 2 by default when AMD cards are detected.

    I think this change has made it to stable by now. Looks like 2 is the default but FPSPlayer.lua (which most people use) sets it back to 1. I'm not sure anyone will see the benefit of the change unless it's clamped at a minimum of 2.

  8. Hi, I've been testing the Pause and Journal scripts following the provided instructions. I managed to get Pause to work fine but it seems that the Journal script creates a script error in Core.lua on Line 74 (attempt to index a nil value). For testing, do I simply attach JournalEntry.lua to a Model or am I missing something? I'm new to Leadwerks and Lua so please forgive any newb oversights.

    Thanks!

    Do you have the Journal.lua script on a pivot in your scene?

  9. Ubuntu 14 LTS uses GCC 4.9.1 and Ubuntu 16 uses GCC 5.3.1, did you try downgrading to 4.9.1 (I don't know if you can)? It's a bad idea to mix different versions of GCC with Leadwerks because a number of function signatures use STL (mostly std::string but I've seen std::vector a few times), the underlying implementation of STL has likely changed between GCC releases.

    • Upvote 1
  10. I will give that a try. I also could try to get some scripting logic out of Hankinators UI after downloading it. Thank you guys. I will reply again if I tried it out.

    My library does a look up in a quadtree that contains all widgets that are visible. If there is something there, it sets a hover flag on the widget so it can draw a hover effect(or whatever).

  11. Hello when even I load leadwerks it always shows EXCEPTION_ACCESS_VIOLATION when its loading the Devices spesificly when it gets to "Intel® Graphics Media Accelerator HD" please note that I am running this on a old fujist laptop and im using this temporarly because my PC's Motherboard, Processor and Memory fried there selves and geting replacement parts soonish but im on a time schedual for releasing my current project and I need it done by the end of the year so I have been trying to keep on schedual anyway is there a fix to my issue? or am I going to do all nighters to get it done? ( sorry about the last part I get a bit carried away when on forums *derp* )

    I'd check if Intel® Graphics Media Accelerator HD supports OpenGL 4, I doubt it. There might be a better tool but this will tell you what version it supports: http://www.realtech-vr.com/glview/download.php

  12. following code did nothing.

     

     

    mutant.control->SetCharacterControllerAngle(180);

     

    and neither did the code below.e.

     

    mutant.modell->SetCharacterControllerAngle(180);

     

     

    I might try SetRotation with a Boolean flag in main loop.

     

    with a more common format than mdl I could have loaded it into uu3d and rotated the model

    EDIT: it would be nice to have this feature in model editor..

     

    Have you tried changing the values you are using with SetCharacterControllerAngle? Like 0 instead of 180?

  13. I get steady 60fps until I get outside the city and everything is in the scene, then it drops to steady 30fps. I think it might be due to vertical sync. If I just missed a vsync the system will wait as long as 16.6ms(assuming 60hz) for the next vsync. If I disable vsync I get about 53fps (dipping to ~48fps every now and then). FX 8120 and R9 380.

    vsync on

    l9tRJNP.png

     

    vsync off

    RAAK6YQ.png

  14. I was doing some edits to the pause menu to make it pop up once the player starts the game-and it does. Unfortunately I can't seem to it so once the player clicks on Resume the script goes back to normal. Heres a copy of my most succesful attempt

     

    What are you trying to achieve? When I tried your script, the game starts paused with your menu up.

     

    Something I noticed is that I placed

    paused = false

    in an unfortunate spot in Main.lua. I should have put it above loading the map. If you do that, to show the Pause menu when the game starts you can just put self:ShowMenu() at the end the Start() function in your script. The solution you have now is perfectly fine though.

×
×
  • Create New...