Jump to content

Einlander

Members
  • Posts

    778
  • Joined

  • Last visited

Posts posted by Einlander

  1. What do you mean with "without interrupting anything"?

    You can get the mouse wheel as the z-coordinate of the GetMousePosition()-function

    (http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/window/windowgetmouseposition-r455)

     

    What if i just want to poll if the mouse wheel is changed . Now I have introduce a global that will keep track of the change since the getmouseposition remembers its state. This brings up some complications. Is this the first time the function has been called? Does the value change even when I'm not testing for it? If this is true then how do I handle a non zero z value? do I say it didn't move or that it moved? Lots of problems can arise.

  2. While programming it became an increasing hassle to key track of what variable was a mouse button and what command was from the keyboard. So I wrote a function that will treat the mouse and the keyboard as the same input.

     

    
    

    -- This creates a function that is capable of handeling both keyboard and mouse input

    function InputHit(keycode)

    local window = Window:GetCurrent()

    local context=Context:GetCurrent()

    if keycode == Key.LButton then return window:MouseHit(Key.LButton) end

    if keycode == Key.RButton then return window:MouseHit(Key.RButton) end

    if keycode == Key.MButton then return window:MouseHit(Key.MButton) end

    return window:KeyHit(keycode)

    end

    function InputDown(keycode)

    local window = Window:GetCurrent()

    local context=Context:GetCurrent()

    if keycode == Key.LButton then return window:MouseDown(Key.LButton) end

    if keycode == Key.RButton then return window:MouseDown(Key.RButton) end

    if keycode == Key.MButton then return window:MouseDown(Key.MButton) end

    return window:KeyDown(keycode)

    end

     

    I'm still trying to figure out how to get the mouse wheel without interrupting anything

  3. It is completely possible to do this. You would need to have horde handle all 3d and 2d drawing features, and leadwerks can do the rest. You will have to still provide leadwerks with compatible models so it can properly handle the physics.

  4. Continuing the conversation from the status updates, you mentioned to you have assets already created. How are they constructed? Are they actual prefabs where walls, floors, and ceilings are already in place and you piece them together like a jigsaw puzzle? Or after you generating them at runtime?

    • Upvote 1
  5. You are now heading for technical territory. First you will need to turn off

    Sandbox Lua

    in the Leadwerks options menu. Your game will not work in the Leadwerks game player on Steam anymore.

     

    Now add this code when you want to make w messagebox appear

     

    local ffi = require("ffi")
    ffi.cdef[[int MessageBoxA(void *w, const char *txt, const char *cap, int type);]]
    self.window:ShowMouse()
    ffi.C.MessageBoxA(nil, "Hello world!", "Test", 0)
    self.window:HideMouse()
    

     

    Reference: http://luajit.org/ext_ffi.html

     

    Beyond this example I can't help as it is beyond my ability as a programmer.

    • Upvote 1
  6. I have a one too. My needlessly complicated version with markup language! No wordwrap though sad.png . Maybe one day...

     

    
    

    --This function will be called once when the program starts

    function App:Start()

     

    --Initialize Steamworks (optional)

     

    --Set the application title

     

    --Create a window

    local windowstyle = window.Titlebar

    if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+window.FullScreen end

    self.window=Window:Create(self.title,0,0,System:GetProperty("screenwidth","1024"),System:GetProperty("screenheight","768"),windowstyle)

    self.window:HideMouse()

     

    --Create the graphics context

    self.context=Context:Create(self.window,0)

    if self.context==nil then return false end

    return true

    end

    --This is our main program loop and will be called continuously until the program ends

    function RGBAToVec4Scalar(rgb,a)

    return Vec4(rgb[1]/256,rgb[2]/256,rgb[3]/256,a/256)

    end

     

    function split(string1,sep) --http://lua-users.org/wiki/SplitJoin

    local sep, fields = sep or ":", {}

    local pattern = string.format("([^%s]+)", sep)

    string1 = string.gsub(string1, pattern, function© fields[#fields+1] = c end)

    return fields

    end

    function drawtext2(text,x,y,width,height,colorastable)

    local TempContext = Context:GetCurrent()

    local tempblendmode = TempContext:GetBlendMode()

    local oldcolor = TempContext:GetColor()

    TempContext:SetColor(RGBAToVec4Scalar(colorastable,colorastable[4]))

    TempContext:SetBlendMode(Blend.Alpha)

     

    --[NOTICE] blend mode needs to be set to include alpha

    --[NOTICE] all set colors need to be changed to the class color set

    local oldcolor = TempContext:GetColor()

    TempContext:SetColor(RGBAToVec4Scalar(colorastable,colorastable[4]))

    -- [NOTICE] impliment command that will ignore all commands that change size in font and line breaks

    -- preprocess string

    local textcommands = {}

    local workingstring=text

    local watch = 1

    local last = 0

    local wraplines=false

    while watch ~= nil do

    watch,last = string.find(workingstring, '##(.-)##',watch)

    if watch ~= nil then

    --print(string.sub(workingstring,watch,last))

    table.insert(textcommands,{split(string.sub(workingstring,watch+2,last-2)),watch,last}) -- add it to list of all commands

    --split(string.sub(text,watch+2,last-2))

    -- remove it from string

    workingstring = string.gsub(workingstring,string.sub(workingstring,watch,last),"",1)

    if watch ~= nil then

    watch =1

    end

    end

     

    end

    local font = TempContext:GetFont()

    TempContext:SetBlendMode(Blend.Alpha)

    local i=0

    local linewidth = 0

    local lineheight = 0

    local linecollection = {}

    local currentline = 1

    local stringcount = 0

    local ignorelinebreak = false

    --local currentlinehieghttotal = 0

    while i < string.len(workingstring) do

    i=i+1

    currentletter = string.sub(workingstring,i,i) -- seriously pushing optimizations, no redunant code

    -- process fonts

    for ii =1 , #textcommands do

    if i == textcommands[ii][2] then

    local currentcommand = string.upper(textcommands[ii][1][1])

    if (currentcommand == "WRAPLINES") == true then

    --Debug:Error(textcommands[ii][1][2])

    if string.upper(textcommands[ii][1][2]) == "TRUE" then wraplines = true end

    if string.upper(textcommands[ii][1][2]) == "FALSE" then wraplines = false end

    end

    if (currentcommand == "FONTSIZE") == true then

    -- so........ leadwerks dosent have a fontsize option........

    end

    if (currentcommand == "LINEBREAK") == true then

    table.insert(linecollection,{linewidth,lineheight,stringcount})

    linewidth = 0

    lineheight = 0

    stringcount = 0

    end

    if (currentcommand == "COLORRGB") == true then

    end

    end

    end

    if lineheight < font:GetHeight() then

    lineheight = font:GetHeight()

    end

    if linewidth + font:GetTextWidth(currentletter) > width and wraplines == true then

    --stringcount = stringcount+1

    table.insert(linecollection,{linewidth,lineheight,stringcount})

    lineheight = 0

    linewidth = 0

    i=i-1

    currentline = currentline +1

    stringcount = 0

    elseif linewidth + font:GetTextWidth(currentletter) > width and wraplines == false then

    -- keep counting strings. we will ignore them later

    stringcount = stringcount+1

    else

    linewidth = linewidth + font:GetTextWidth(currentletter)

    stringcount = stringcount+1

    end

    end

    table.insert(linecollection,{linewidth,lineheight,stringcount})

    --"Einlanders Text Command:It supports forcedlinebreaks, Inline color changes and line wrapping. Font Size changesLeadwerks does'nt TEXT RENDERING LIKETHIS IS EXPENSIVE

    local stringcount = 1

    local stringbuilder = ""

    local oldlinelocation = 0

    local linelocation = 0

    local currentheight = 0

    local drawtext = false

    local currentcolor = TempContext:GetColor()

    for i = 1 , #linecollection do

    oldlinelocation = 0

    linelocation = 0

    stringbuilder = ""

    --build string till color change

    for stringlength = 1 , linecollection[3] do

    for ii =1 , #textcommands do

    if stringcount == textcommands[ii][2] then

    local currentcommand = string.upper(textcommands[ii][1][1])

    if (currentcommand == "COLORRGB") == true then

    --context:SetColor(currentcolor)

    --context:DrawText(stringbuilder,x+oldlinelocation,y+currentheight)

    --oldlinelocation = linelocation

    --stringbuilder = ""

    drawtext = true

    end

    end

    if drawtext == true then

    TempContext:SetColor(currentcolor)

    TempContext:DrawText(stringbuilder,x+oldlinelocation,y+currentheight)

    oldlinelocation = linelocation

    stringbuilder = ""

    drawtext= false

    end

    if stringcount == textcommands[ii][2] then

    local currentcommand = string.upper(textcommands[ii][1][1])

    if (currentcommand == "COLORRGB") == true then

    TempContext:SetColor(

    textcommands[ii][1][2]/255,

    textcommands[ii][1][3]/255,

    textcommands[ii][1][4]/255)

    currentcolor = TempContext:GetColor()

    end

    end

    end

    if drawtext == true then

     

    end

    currentletter = string.sub(workingstring,stringcount,stringcount)

     

    linelocation = linelocation + font:GetTextWidth(currentletter)

     

    if linelocation < width and (wraplines == false) then

    stringbuilder =stringbuilder .. currentletter

    elseif (wraplines == true) then

    stringbuilder =stringbuilder .. currentletter

    end

     

    stringcount = stringcount + 1

    if currentheight > height then break end

    if stringlength == linecollection[3] then

    TempContext:DrawText(stringbuilder,x+oldlinelocation,y+currentheight)

    currentheight = currentheight + linecollection[2]+5

    end

    end

     

    --print(string.sub(workingstring,stringcount,linecollection[3]))

    --stringcount =stringcount+ linecollection[3]

    end

    --os.exit()

    TempContext:SetColor(RGBAToVec4Scalar({oldcolor.r,oldcolor.g,oldcolor.b},256))

    TempContext:SetBlendMode(tempblendmode)

    end

    function App:Loop()

    --If window has been closed, end the program

    if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end

    self.context:SetColor(Vec4(100/256,100/256,100/256,1))

    self.context:DrawRect(50,200,300,180)

     

    -- need to set the box size manually

    drawtext2("##wraplines:true####colorrgb:256:0:0##Leadwerks Software##linebreak## ##colorrgb:256:256:256##Leadwerks Software was founded in 2006 to make game development fun and enjoyable."..

    "The company launched Leadwerks 3, their first multiplatform product, in April at the GDC 2013 expo. Last summer, the company "..

    "conducted a successful Kickstarter campaign to bring Leadwerks to the Linux operating system, reaching over 200% of their goal "..

    "in just six weeks. A concurrent Greenlight campaign for Steam was also successful, making Leadwerks the first 3D game engine "..

    "approved for distribution on Steam.",50,200,300,150,{255,255,255,255})

     

     

    self.context:Sync(true)

    return true

    end

    • Upvote 1
  7. First check to see if a backup temp.map exists in the projects map folder and see if that loads an older version of your map. If not check the Leadwerks backup folder

    %HOMEPATH%\Documents\Leadwerks\Backup

    <- paste that into explorer and it will take you there. Sort by modified to list it by the last time a map was changed. Pray there is a copy.

  8. I've been following this thread, but I'm getting a bit confused now. Are you trying to include a c library in your lua project to use from lua. Or are you trying to expose a c function to lua to be used from a lua script?

     

    If its the first look into "luajit ffi" ffi is the key as it allows you to directly load c code into luajit. The other way I can't help you.

  9. This would work awesome for traditional games and csg's, but issues will arise when you get creative. So lets say I create a portal clone. I create a new goo. How do I assign a new material type? Another issue is multi-material meshes. Say I import 1 house and it is a single mesh with multiple materials. How do I figure out the footsteps WITHOUT creating triggerzones to force the structure ts to change? Same thing with a mesh that uses a texture atlas.

×
×
  • Create New...