Jump to content

Einlander

Members
  • Posts

    778
  • Joined

  • Last visited

Posts posted by Einlander

  1. I started playing around with the networking in Leadwerks and found that I needed enums. So I wrote a function that will allow you to enumerate a table.

     

    function enumerate(array,indexstart) -- indexstart is optional
    	if array == nil then return nil end
    	local array2 = {}
    	local count = tonumber(indexstart) ~= nil and tonumber(indexstart) or 0
    	for key,value in pairs(array) do
    		array2[value] = count
    		count = count + 1		
    	end
    	return array2
    end

    This will take an array of strings and output a named table array.

     

    enum_netchat =  enumerate({
      "client",
      "team",
      "all",
      "servertoclient",
      "servertoteam",
      "servertoall"
    },1)

     

    This is the simplest way to make an enum

    	enum_netchat.all
    	
    • Upvote 2
  2. Here is some pseudo-code of how i did it in the explosions workshop item

    Creates a unit vector pointing in the direction we want to push. Needs to be in the GLOBAL space.

    force_direction = ( destination_entity:GetPosition(true) - source_entity:GetPosition(true) ):Normalize() 

    Check if object is airborne. If it is, leave it alone. If there is more than one explosion close together, it will cause the entity to no clip since the force will become cumulative.

    if destination_entity:GetAirborne() == false then
    	force_direction y = 1
    else 
    	force_direction = Vec3(0)                        
    end 

    Push the object while attempting to cancel out the objects gravity. (we multiply by the worlds inverse gravity.). We push in the GLOBAL space.

    destination_entity:AddForce(force_direction * Vec3((-world:GetGravity().y / destination_entity:GetMass())) * blast_force, true)

     

    • Upvote 1
  3. Problem. It selects the Maximum resolution instead of the current resolutions. I have Virtual Super Resolution enabled in radeon settings, so my max res is 3200 x 1800 instead of my current resolution of 1920 x 1080.

    So main.lua needs to get the current resolution, then try to set the window to the current resolutions. If it fails either find a graphics mode closest to the current resolution but smaller, or try the smallest resolution available.

    In fact, can we get a lua command to get the desktop resolution? I would like to be able to center the window on the screen, or if making an application be able to properly place windows around the screen properly.

     

    I ran it from commandline to avoid the "devmode" branching.

  4. To get rid of the checkered boxes you need to do 2 things. In the water.mat that it comes with enable zsort. So the selected options will be, 2 sided, Depth test, Depth mask, and zsort. On the shader tab, switch the shader to refraction.shader.

    To make it more or less transparent, on the Properties tab in the diffuse section, the first 3 are your colors. The last one is the transparency. The higher the number the more transparent.

     

     

    • Upvote 1
  5. This is what i get if I count the graphics mode from c++ and getting the dpi scaling before and after the count

    > guitest.debug.exe
    Error: No debugger hostname supplied in command line.
    DPI Scaling0.000000
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    (0,0)
    DPI Scaling0.000000

     

  6. in menu.lua add this after line 249:

    gfxmode = {tostring(tonumber(gfxmode[1]) <= 0 and 1280 or gfxmode[1]) , tostring(tonumber(gfxmode[2]) <= 0 and 720 or gfxmode[2])}

    Does the same as the above. it will only catch if the screenres is (0,0) or lower then set it to 720p.

    This is just a failsafe for when a screen resolution is unable to be selected. Think gta 4 for people with more than 2gb of video ram iirc. The game was unable to see all the ram and was unable to see the screen resolutions.

  7. The solution that I found is to use a ternary operator to fix it.

    add this after line 21:

    gfxmode = Vec2( (gfxmode.x <= 0 and 1280 or gfxmode.x) , (gfxmode.x <= 0 and 720 or gfxmode.x))

    This will make sure the window is > (0,0), if not it will set it to 720p(16:9) .

    This will not effect the game if it is running properly. Think of it as safe mode like gta5 has, except it doesn't start at the absolute safest resolution (640,480).

    I need to do some looking into menu.lua to make sure it doesn't mess up when you select the non existent screen modes. (It gives you the option to select 0x0 screen res :/ )

     

  8. I would suggest that you have for the server:publish API you have a mandatory key string parameter. This way you can separate games of the same name and even the same game but different versions. 

    • Upvote 1
  9. 4 hours ago, Josh said:

    That turned out really cool.

    If you guys need any models next time, let me know.  You will have to correspond with the artist and give them your specs and review their work, but I will pay for it to be made.

    That's awesome!

×
×
  • Create New...