Einlander
-
Posts
778 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Einlander
-
-
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
-
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.
-
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?
- 1
-
Just driving by and putting a speed bump here....
-
I started doing the same with buildings, but life took over and i never finished it. http://www.leadwerks.com/werkspace/blog/120/entry-1275-building-worlds/
-
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.
- 1
-
Do you want the pop up box to stop the game? If so this is what you want. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/debug/debugerror-r752
If you want it in game then you may have to choose it yourself.
-
I have a one too. My needlessly complicated version with markup language! No wordwrap though . 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
- 1
-
One of your meshes uses shape option from the dropdown in the physics tab. This was removed in the beta. This is a bug.
-
Do you have and AMD/ATI graphics card?
-
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.
-
Silo 2 and ray supreme. Both are on steam and ray supreme supports fbx and you can draw on the UV texture.
And as a anim8or user I do recommend that, export as obj/3ds to blender the save as fbx.
-
I need to step my game up...
Edit:
While looking at the images, I'm impressed with how they managed to recycle texture assets and how the approach they use for texture mapping.
-
-
If you have your Model Editor window open AND the Material window open, and change somthing in the Model editor, it moves the model from the perspective view to the material view.
-
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.
-
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.
-
Note the Leadwerks Ps,Vs shader will be red in Leadwerks if you don't make some changes.
-
There seems to bee a roll back in Shader tool. The feature I was talking about is now missing. I'm putting something on steam to help them out.
It use to be copy and paste.
http://steamcommunity.com/app/314720/discussions/0/618453594747407982/
-
In shadertool create a leadwerks template node. the Leadwerks fs,PS template has what looks to be a boilerplate diffuse shader with 1 texture.
-
As the title says searching for any string in the asset browser that includes a \ will crash to desktop.
How to reproduce: type / in the search box and hit enter.
-
I use it when I want to get a list of all my prefabs without going through folders, that's it.
-
I assume you are using an ati graphics card? http://www.leadwerks.com/werkspace/topic/10986-transparency-bug/
-
If or when it gets implemented can we have it as a check box in the settings so it doesn't mess up my already existing models?
A More Robust Input command
in Programming
Posted
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.