Jump to content

Search the Community

Showing results for tags 'lua'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Models
    • Animals
    • Barriers
    • Characters
    • Containers
    • Environments
    • Furniture
    • Props
    • Rocks
    • Vegetation
    • Vehicles
    • Weapons
  • Materials
    • Brick
    • Cartoon
    • Decals
    • Dirt
    • Grass
    • Industrial
    • Medieval
    • Metal
    • Plastic
    • Plaster
    • Rock
    • SciFi
    • Sky
    • Signs
    • Tile
    • Stone
    • Walls
    • Wood
  • Plugins
  • Scripts
    • GUI
    • Object
    • Utilities
  • Shaders
    • Post-Processing Effects
    • Surface
  • Sounds
    • Ambience
    • Effects
    • Music
  • Tools
  • BATTLE LEAGUE's Assets


There are no results to display.

There are no results to display.


  • Leadwerks
    • Technical Assistance
    • General Discussion
    • Programming
    • Game Art
    • Suggestion Box
    • Bug Reports
  • Platforms
    • Windows
    • Linux
    • OSX
  • Community
    • Showcase
    • Promotion
    • Off-topic
  • Arena Shooter's Forum
  • BATTLE LEAGUE's Topics
  • Away from Home's Zone Script
  • Away from Home's General
  • Away from Home's Zone Rigging / Modeling
  • Vec-Tec's Releases
  • Vec-Tec's Topics
  • Forth's Development
  • Forth's Game design
  • Forth's Graphics
  • Forth's Documentation
  • Forth's TODO
  • Forth's IMPORTANT
  • Forth's Screenshots
  • The uncertain world's Game Design
  • The uncertain world's Programming
  • The uncertain world's TODO
  • The uncertain world's Graphics
  • The uncertain world's Screenshots
  • Dark Age Mist's Videos

Product Groups

  • Leadwerks
  • Model Packs
  • Gear

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Found 363 results

  1. If anyone needs, I'll leave it here Timer: if Timer~=nil then return end Timer={} function Timer:Create(name, interval,enable) local timer={} timer.name = name timer.interval = interval timer.enable = enable timer.time = Time:GetCurrent()+timer.interval local k,v for k,v in pairs(Timer) do timer[k] = v end return timer end function Timer:Update() if self.enable then if Time:GetCurrent() > self.time then self.time = Time:GetCurrent()+self.interval return true else return false end end end How to use: function App:Start() --Timer self.time_hours = 0 self.time_minutes = 0 self.time_seconds= 0 self.timer = Timer:Create("timer",1000,true) end function App:Loop() --Very complex calculation time if self.timer:Update() then self.time_seconds= self.time_seconds+1 if self.time_seconds== 60 then self.time_minutes = self.time_minutes+1 if self.time_minutes == 60 then self.time_hours = self.time_hours+1 self.time_minutes = 0 end self.time_seconds= 0 end end --Draw current time self.context:SetColor(1,1,1,1) --Seconds local seconds if self.time_seconds < 10 then seconds = "0"..self.time_seconds else seconds = self.time_seconds end --Minutes local minutes if self.time_minutes < 10 then minutes = "0"..self.time_minutes else minutes = self.time_minutes end --Hours local hours if self.time_hours < 10 then hours = "0"..self.time_hours else hours = self.time_hours end local time_string = hours..":"..minutes..":"..seconds self.context:DrawText("Timer: "..time_string,2,2) end
  2. Where can I find tutorials for LUA?
  3. There is a way to get the texture of the buffer, without a strong drawdown FPS? Simple code of Monitor: function Script:Start() --Material self.material = Material:Load("Materials/Monitor/monitor.mat") self.entity:SetMaterial(self.material) --Buffer self.buffer = Buffer:Create(App.window:GetWidth(),App.window:GetHeight(),1,0); self.buffer:SetColorTexture(Texture:Create(App.context:GetWidth(),App.context:GetHeight())) self.buffer:Disable(); end function Script:UpdateWorld() self.buffer:Clear() self.buffer:Enable() self.entity:Hide() --self.camera:Show() App.world:Render() --self.camera:Hide() self.buffer:Disable() self.material:SetTexture(self.buffer:GetColorTexture(),0) Context:SetCurrent(App.context) self.entity:Show() end One monitor, point light and room 4x4 As a result, the FPS - 5 If two monitor FPS - 10 etc Implementation in irrlicht engine: ITexture* RTTTex = driver->createRenderTargetTexture(dimension2d<s32>(512,512)); Result over 75 fps (For me) Demo, Source code and shaders: irrlicht.zip
  4. Just got this message ???? Why is that? Is it my ram (i have 16gb)? Is it my gpu memory (I have an nvidia 650 ti boost 2gb superclocked)...
  5. I want to hire a programmer to code a Login System or HWID lock with an online database. So I can manage my tool sales easier... I managed to make the tool but I don't know if I'm able to make the login system in LUA. I'm willing to pay someone to do this!
  6. Hello there! I require a more precise timer that deals with millionths of a second, or more. I've played around with default Leadwerks Time commands, but the most precise I can get is a thousandth of a second, eg: Time:GetCurrent() / 1000 -- 0.654 Does anyone know a way in which I can handle millionths or billionths of a second with Leadwerks and Lua?
  7. Please add in the next update - opportunity to get a type from the file material. I think it will be very comfortable and functional. You can make a return type int... int Material::GetType(); //Returns the type of material "Metal, Concrete, Wood, Water, Flesh, Grass etc.." Example of use: --FPSPlayer Footsteps Get type function Script:Collision(entity,position,normal,speed) if speed>20 then self:Hurt(100) end if entity:GetMaterial():GetType() ~! nil then if entity:GetMaterial():GetType() == Material:Type:Concrete then self.sound.footsteps.type = 1 end if entity:GetMaterial():GetType() == Material:Type:Metal then self.sound.footsteps.type = 2 end --etc end end Useful for the sound of footsteps, traces of bullets, particles etc.
  8. Hi there! I'm wondering if anyone has any tips or known techniques on how to create a split-screen in Leadwerks using Lua. Many thanks in advance!
  9. Something weird is happening. I have two objects with the scame script on them. Here is the code: Script.enabled=0 --bool "enabled" Script.int=0 Script.tab={1} function Script:UpdateWorld() System:Print("------------starts "..self.entity:GetKeyValue("name")) System:Print("int="..self.int) System:Print("#="..#self.tab) System:Print("[#]="..self.tab[#self.tab]) if not self.enabled then return end self.int=self.int+1 self.tab[#self.tab+1]=math.random(1,9) System:Print("-----------END "..self.entity:GetKeyValue("name")) end It has boolean variable which is set to true for one entity and to false for another entity in the editor. it also has one number variable (int) and one table (tab). Script with "enabled" entity ads +1 to int variable and one extra table element with random value each update. And here is what I get in output: ------------starts Pivot 1 (enabled) int=0 #=1 [#]=1 -----------END Pivot 1 (enabled) ------------starts Pivot 2 (disabled) int=0 #=2 [#]=4 ------------starts Pivot 1 (enabled) int=1 #=2 [#]=4 -----------END Pivot 1 (enabled) ------------starts Pivot 2 (disabled) int=0 #=3 [#]=8 ------------starts Pivot 1 (enabled) int=2 #=3 [#]=8 -----------END Pivot 1 (enabled) ------------starts Pivot 2 (disabled) int=0 #=4 [#]=7 ------------starts Pivot 1 (enabled) int=3 #=4 [#]=7 -----------END Pivot 1 (enabled) ------------starts Pivot 2 (disabled) int=0 #=5 [#]=9 ... (Added space after each update for easier reading) As you can see int variable increases in "enabled" entity and doesn't change in "disabled". Also disabled entity doesn't print last ("---END") line, so it is really disabled. But for some reason the table changes for both of those entities. It has same amount of elements and the last element is the same (it was generated randomly) for both scripts. Can you please explain me what is going on here?
  10. Hello, Ive been working off and on on learning the in and out of Leadwerks but I am running into a problem when it comes to scripting in lua. You see while I understand the basic syntax of the language I am having trouble using the built in editor due to the fact that I am having trouble with the technical command terms. I have a hard time with spelling some of these terms like transform and others I simply cant remember if they even exist without combing through the wiki. So does the built in editor have a option to bring up a list of suggested commands like if one types in a "t" it will bring up a list of all commands that begin with the letter t. Or is there another editor all together exist that will do this? Basically I need this to be idiot proofed, thanks.
  11. Hi there! I was just wondering if anyone has any ideas of how to make a Character Controller's jump "sharper", ie: jumps to desired max height as quick as we want, then falls to ground as quick as we want? I'm using the entity:SetInput() to move the Character Controller. Thanks!
  12. It seems if you save a script from the editor (not the one currently active in the entity's scripts tab) parameter fields get messed up with fields from another script. No file corruption or anything like that is apparent, hopefully just a visual bug. But still. Please see the video. http://www.olbyonline.com/bin/leadwerks/ScriptEditorParamsMess.mp4
  13. Recent files are not stored for the script editor. After a restart the list is always empty.
  14. As the title says, If you make a csg prefab and re-texture it using the drag and drop method it will appear correct in the editor. (NOTE: The warning about changing from and insanced prefab DOES NOT appear). If you change the texture through the appearance tab it will change the texture ingame and show the insance warning dialog
  15. Hello, Time:GetCurrent() seems to be rounded to a maximum precision of three decimal places, and I need it to be more precise for my timer. Is there any way I can have a more precise time, to say five or six decimal places? Thanks!
  16. Can someone please tell me a good way to do a timer that starts when the game starts and ends if a object is touched? I tryed many things but it doesnt worked. Thanks for your Answeres!
  17. So I want the game to pause (and specifically FPSplayer.pfb) when self.currentState == "menu" or "splash" So I want the moving gun animation to stop, I want it to ignore key presses and mouse movement, I want it to ignore mouse clicks. Basically, I want it to freeze up when app.currentState is not "game" Any ideas?
  18. Hi, in the Leadwerks Beta (3.3) the Lua example from the Command Reference "Surface::Add" shows an other result as the CPP example. Screenshot attached.. lua in first picture cpp second one
  19. Hey guys! I'm experiencing an issue when I try to switch maps: "OpenAL: AL_INVALID_OPERATION". I have many small audio samples loaded as a Source in one map (each 1 second long), each being played whenever the player triggers them through interaction. I've noticed that if none of the samples are played the map will switch just fine, but if one or more are played the map switch will fail with the above error. I've tried explicitly telling each sample to stop playing right before the map switch, just to make sure, but this didn't work. I've also combined this with releasing each Source, again with no luck. What could this invalid operation be, and how do I solve it? Many thanks in advance!
  20. Hi all! I'm wanting to create a motion blur effect on the player entity. I'm wondering how to go about this as the camera follows the player: so overlaying the previous rendered image probably wont work, as the player is always center screen. I'm guessing I could go about achieving the effect by creating a shader which duplicates the diffuse texture of the player entity and stretches it across the screen, and/or duplicates it across the screen with a fade on the alpha. I'm just getting started with shaders, and creating effects such as this, so I'm hoping someone can offer some advice or tips. Many thanks in advance!
  21. I released an OOP class sytem for leadwerks last time this time I'm going to post my StateManager class which I use to control all the gamestates for the game I am working on. If you don't know what a Statemanager is or what my interpretation of one is I'll run through it quickly. Generally speaking it's just a stack full of 'states' each state has a list of functions with identical names but different internal functionality, the game will call these functions but ONLY for the active state, say your game has a Draw function but you want a splash screen with a Draw function, you'll separate these into different States for the stack, now when your splash state is active only the splash's Draw function will be called. State stacks almost always run [L]ast n [F]irst [O]ut, so the last state you push onto the stack will be the one the game starts using, so to have a splash screen -> menu -> game order in your stack you would push the game onto the stack first, the menu second and the splash last so that the splash is the first thing the end user sees. Enough ramblings let me post some code. statemanager.lua requires the class scripts. class "CStateManager"; function CStateManager:Init() self.States = {} end function CStateManager:Push(state, init) if( ctype(state) == "CState" ) then self.States[#self.States+1] = state; if( init ) then if( self.States[#self.States-1] and self.States[#self.States-1].isinit ) then self.States[#self.States-1]:Shutdown(); self.States[#self.States-1].isinit = false; end self.States[#self.States]:Init(App.context); self.States[#self.States].isinit = true; end else print("StateManager: CStateManager.Push expected CState got: "..ctype(state)); end end function CStateManager:InitCurrentState() if( self.States[1] and not self.States[#self.States].isinit ) then self.States[#self.States]:Init(App.context); self.States[#self.States].isinit = true; end end function CStateManager:Pop() if( self.States[1] ) then if( self.States[#self.States].isinit ) then self.States[#self.States].isinit = false; self.States[#self.States]:Shutdown(); end local oldState = self.States[#self.States]; self.States[#self.States] = nil; self:InitCurrentState(); return oldState; end print("StateManager: Called CStateManager.Pop with empty stack"); end function CStateManager:GetAll() return self.States end function CStateManager:GetActive() if( self.States[1] and self.States[#self.States].isinit ) then return self.States[#self.States]; end print("StateManager: Called CStateManager.GetActive with no running states"); end function CStateManager:Pause(state) if( ctype(state) == "CState" ) then state.paused = true; end end function CStateManager:Resume(state) if( ctype(state) == "CState" ) then state.paused = false; end end function CStateManager:IsPaused(state) if( ctype(state) == "CState" ) then return state.paused; end end function CStateManager:Call(func, ...) if( self.States[1] and self.States[#self.States].isinit and not self.States[#self.States].paused ) then if( self.States[#self.States][func] ) then self.States[#self.States][func](self.States[#self.States], ...); end end end state.lua -- Tiny file this one. really just a declaration and a nilfix file. class "CState"; function CState:Init() end function CState:Shutdown() end Example useage. -- Our splash screen. SplashScreen = new "CState" function SplashScreen:Init() self.Something = "HELLO"; end function SplashScreen:Think() self.Something = self.Something.."O"; end function SplashScreen:Draw() App.context:DrawText(self.Something, 100, 100); end -- Now something else. Random = new "CState" function Random:Draw() App.context:DrawText("Second State", 100, 200); end -- Now in our main file to initialize out statemanager and load our states. function App:Start() StateManager = new "CStateManager"; StateManager:Push(Random); -- Remember this goes before the splash so we see it AFTER the splash StateManager:Push(SplashScreen, true); the true means we want to initialize this, as it's the last state being pushed we may aswell tell the statemanager we are ready to begin. end function App:Loop() StateManager:Call("Think") -- Can name your functions anything, Init and Shutdown are always the same though. StateManager:Call("Draw", "some", "arguments", "here", "if", "you", "want"); end To remove the current state from the stack and initialize the next, we use StateManager:Pop(); I hope people get some use out of this, and I hope I've explained it nice enough.
  22. While coding my lua GUI I found that I needed to be able to fill many 2d polygons. After looking at quite a few algorithms (I am very bad at math), I found one created in lua and felt that I needed to share. It was converted from the Corona lua which was in turn converted from PSP lua. I have modified it to work without change in Leadwerks See here for examples on how it works: http://forums.coronalabs.com/topic/8084-drawing-a-polygon-with-a-fill/ function rgbatovec4scalar(rgb,a) return Vec4(rgb[1]/256,rgb[2]/256,rgb[3]/256,a/256) end function paintPoly(poly, xoffset, yoffset, rgba) -- [url="http://forums.coronalabs.com/topic/8084-drawing-a-polygon-with-a-fill/"]http://forums.coronalabs.com/topic/8084-drawing-a-polygon-with-a-fill/[/url] local math_floor = math.floor local math_min = math.min local math_max = math.max local polyGroup = {} local n = table.getn(poly) local minY = poly[1].y local maxY = poly[1].y for i = 2, n do minY = math_min(minY, poly[i].y) maxY = math_max(maxY, poly[i].y) end for y = minY, maxY do local ints = {} local int = 0 local last = n for i = 1, n do local y1 = poly[last].y local y2 = poly[i].y if y1 < y2 then local x1 = poly[last].x local x2 = poly[i].x if (y >= y1) and (y < y2) then int = int + 1 ints[int] = math_floor((y - y1) * (x2 - x1) / (y2 - y1) + x1) end elseif y1 > y2 then local x1 = poly[last].x local x2 = poly[i].x if (y >= y2) and (y < y1) then int = int + 1 ints[int] = math_floor((y - y2) * (x1 - x2) / (y1 - y2) + x2) end end last = i end local i = 1 while i < int do polyfillcontex = Context:GetCurrent() polyfillcontex:SetColor(rgbatovec4scalar(rgba,rgba[4])) polyfillcontex:DrawLine(ints[i] + xoffset, y + yoffset, ints[i + 1] + xoffset, y + yoffset) i = i + 2 end end return polyGroup end
  23. So I've got a few of these little helper modules I've written while making my game, I figured I needed a place to post them so others can get some use from it, I'll be selective with what I release as some of them I would like to keep private but everytime I get a spare moment I'll try to write up a blog post with a new module release and how it's used. So anyone familiar with OOP will hopefully get some use from this module, Lua already has a semi-OOP system with it's 'metatables' and this module just extends those to be used in a class system with inheritance. -- This is the definition of the system, only a small file but it does a lot. class.lua -- Class system written by Averice _shardClass = {} _shardClass.__index = _shardClass; function class(nme) if( _G[nme] ) then print("Class: "..nme.." already exists."); return; end _G[nme] = {} setmetatable(_G[nme], _shardClass) _G[nme].istype = nme; return _G[nme]; end -- Really no reason for the shardClass metatable but it provides nice looking functionality -- class "CAnimatedEntity" : extends "CBaseEntity" <-- is now correct syntax function _shardClass:extends(superclass) if( _G[superclass] ) then self.parent = superclass; self.__index = _G[superclass]; end end function new(class) if( _G[class] ) then local newClass = {} setmetatable(newClass, _G[class]); for k, v in pairs(_G[class]) do newClass[k] = v; -- For some reason metamethods weren't being accessed properly, here's a hacky fix. end if( newClass.Init ) then newClass:Init(); end return newClass; end print("Class: "..class.." does not exist."); end function ctype(class) return class.istype or type(class); end Alright, if your hoping to use this and know OOP programming the above should be self-explanatory. Simple put to define a new class you do this. class "MyClass"; To define a class that inherits from another you do this. class "MySecondClass" : extends "MyClass"; To create a new instance of a class you do this. my_class_instance = new "MySecondClass"; If there is an 'Init()' function it will be called automatically when a new instance of the class is created. Here is an example. class "ExampleClass"; function ExampleClass:Init() self.Number = 10; end function ExampleClass:SimpleFunction() print(self.Number); end class "NewExampleClass" : extends "ExampleClass"; function NewExampleClass:Init() self.Number = 15; end -- Now we create an instance. MyClass = new "NewExampleClass"; MyClass:SimpleFunction() -- notice this function was inherited from "ExampleClass" not "NewExampleClass" -- will print 15;
  24. I have a level with 2 lua scripts. However only 1 KeyHit (or mouse hit for that matter) returns true in a single frame. --Script1 in UpdateWorld if KeyHit:Key.Q then System:Print("You are in script 1") end --Script2 in UpdateWorld if KeyHit:Key.Q then System:Print("You are in script 2") end I am not flushing any keys. Is this intended behaviour or am I overlooking something obvious?
  25. Been doing more GUI work, mainly porting more of my GUI lib, but I did decide to finally get around to Dropdown menus which the library was missing from the beginning, I like this sudden feeling of productivity, the hardest part was porting my TabPanel over. I must have written the original on a bad day and going over the old code made no sense to me, it's new and improved now. - Sliders and DropLists. - Tabs and the usual ScrollPanel.
  • Create New...