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. Hi Guys. I need some help with my PlayerAmmoBar script. This script is almost identical to Aggrors PlayerHealthBar script from his excellent video tutorials. Ive made some changes to it so that it graphically represents the amount of Ammo a player has left. The problem I have is that in Aggrors script he is able to get the health information from scripts belonging to the player by using this: self.player = self.entity:GetParent() From there he creates a healthFactor from self.player.script.health / self.player.script.maxHealth (these scripts belong to the Player entity. However for Ammo the information comes from self.Weapon.script.ammo / self.Weapon.script.clipsize. These scripts belong to the Autopistol.pfb which is attached to the player. Now I've tried GetParent (doesnt work because it not the parent) GetChild, Findchild didnt seem to work for me either. To confuse matters more I was looking at the FPS player script and found this line self.weapon.entity:SetParent(self.camera) So does that mean that the weapon is a child of the camera!? Any help would be greatly appreciated.
  2. NewPalette


    I'm just starting out with scripting in Leadwerks, having had a fair bit of experience with Love2d, and I'm having trouble with some standard Lua functions that I think should be working. In particular, I'm having trouble loading modules using the require function. I see people using the require function in examples, but when I try it I get "attempt to call global 'require' (a nil value)". It's as though the Lua standard libraries aren't loaded. Is there something I'm missing? Thank you, ye more-experienced-than-me, for any help.
  3. Doe anyone know if you can stop a looping Entity:EmitSound() method without releasing the entity, then start the sound again back in loop mode? It looks like EmitSound automatically creates a Source and the entity manages it. Is there some way to get reference to this Source to call Source:Stop()? EDIT: Nevermind, I'll just create and manage the Source manually.
  4. Is there any draw texture function that can tile the texture, or do I have to make a loop drawing my texture to create the effect. Context:DrawTexture does not seem to handle tiling.
  5. While working with the LUA script editor, running and debug, suddenly the debug window is gone. I cant get it back even after restart. Any ideas ?
  6. FindChild would work if got the root entity. But how to get that one?
  7. Hello all. As I am experimenting with Leadwerks, I have come across a strange issue. My monster runs on the spot, and wont chase the player. I am using all the default scripts and assets. Heres what I have done: -Drag the player prefab into the 3D viewport -Drag the monster prefab into the 3D viewport -Drag the player prefab from the scene view to the target slot of the monster's monsterAI.lua script. -Run the game -Monster runs on spot and doesnt attack the player unless I am really close and even then I need to shoot the monster to initiate the attack... I'm probably missing something obvious, but this is strange nevertheless. The desired result is that the monster(s) will find and run towards the player and attack the player. All help appreciated!
  8. Can anyone recommend the best method to rotate an entity in global space, over time, to a specific angle (90 degree increments)? I wrote a bit that does this, but it feels like bloated attempt and has some issues when it comes to detecting when the rotation has arrived at it's destination due to float value variations. In the example below, a button click sets the rotation in motion with (self.rotateX = true), and increments the first step in the rotation with (self.rotateSpeed). In the update function, the current global x rotation is compared to the target (self.rotAngle.x) rotation, and the rotation should continue until the global and target rotations match. At this point, the rotateX flag is disabled (self.rotateX = false). function Script:UpdateWorld() -- Attempting to detect when the target rotation has been reached if Math:Round(self.selected:GetRotation(true).x) ~= self.rotAngle.x and self.rotateX == true then self.newRot = self.selected:GetRotation(true) self.newRot.x = Math:Inc(self.rotAngle.x, self.selected:GetRotation(true).x, self.rotateSpeed) self.selected:SetRotation(self.newRot, true) if Math:Round(self.selected:GetRotation(true).x) == self.rotAngle.x and self.rotateX == true then self.rotateX = false System:Print("X rotation complete") end end end function Script:ButtonClick(mPos) if self:IsInRect(mPos, self.upRect) == true then self.rotateX = true self.rotAngle = self.selected:GetRotation(true) + Vec3(90,0,0) self.newRot.x = Math:Inc(self.rotAngle.x, self.selected:GetRotation(true).x, self.rotateSpeed) self.selected:SetRotation(self.newRot, true) end end
  9. I have been working on a simple laser deflection game that dynamically creates geometry-based beams that automatically calculate deflection, bounce angles, and allow the player to rotate deflectors to guide the beam to the goal. As I familiarize myself with the Leadwerks API, I thought I might share my experiences and code examples here if anyone is interested. Please let me know if this sounds interesting and I will continue.
  10. Does anyone know the filepath to load items from the Workshop using Lua? For example, I want to access a shader from the Workshop to attach as a PostEffect, how would I go about doing this? (I have to use ClearPostEffects in my code, so this is why I would need it in Lua).
  11. When you throw a small entity (with rigidbody physics, above 0 mass, swept collision mode on or off, and a generated or convex hull physics shape) the entity will sometimes fall right through the ground (whether the ground is a imported model, terrain, or BSP box). The throwing script I use is a slightly modified version of the FPSplayer.lua script. I made a video to help show the problem. https://www.youtube.com/watch?v=NYBlJxsM04k
  12. FYI, Math:Abs() is not listed in the command reference. It's available, and works as expected, just not documented. http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/math/
  13. as per: http://www.leadwerks.com/werkspace/topic/10573-lua-dynamic-libraries-not-enabled/ (I've request the topic moved or merged with this but I've no idea how to do that ) Seems LUA_USE_LINUX and/or LUA_USE_DLOPEN needs to be defined to enable dynamic library loading. I've provided a simple library to test with in the original thread.
  14. I was trying to use Math:DeltaAngle but it doesn't seem to exist. I guess it is a C++ function that hasn't been exposed to Lua. I'm using this as a temporary fix and it seems to do the job: function Math:DeltaAngle(a,B) local d = b-a d = d + (( (d>180) and -360 ) or ( (d<-180) and 360) or 0) return d end
  15. I have a script with a function that prints text to the console: function Script:TestFunction() System:Print("TEST PRINT") end When I import this script into player script and call this function in Script:Start everything works fine. import "Scripts/Player/TestScript.lua" ... function Script:Start() self:TestFunction() ... But when I also import this script into MonsterAI script calling this function from player script gives me error like this function doesn't exist there (attemt to call method 'TestFunction' (a nil value)). I wanted my RPG related functions to be imported into player script and NPC script and be able to access their variables through these RPG functions. For example: function Script:IncreaseSkill(skill, progress) self.skills[skill]=self.skills[skill]+progress if self.skills[skill]>100 then self.skills[skill]=100 end end I noticed that default scripts like ReleaseTableObjects.lua use global functions and only variables passed to these functions. Do I have to do the same? function IncreaseSkill(character, skill, progress) character.skills[skill]=character.skills[skill]+progress if character.skills[skill]>100 then character.skills[skill]=100 end end
  16. I've gotten render to texture working using this code http://leadwerks.wikidot.com/wiki:render-to-texture-security-cam but the Buffer functions are nowhere to be found in the current documentation. Unless I missed it, in which case please point it out Buffer isn't even highlighted in the script editor. I wasn't sure whether to post this in Bug Reports as it's not to do with the program itself...
  17. I get "Lua Error: error loading module 'plugin/libLua-test' from file './plugin/libLua-test.so':|dynamic libraries not enabled; check your Lua installation" When I try to load my own library. This thread http://www.leadwerks.com/werkspace/topic/10566-require/page__hl__require suggests that turning off sandbox will do the trick - I've tried it both in the LE editor and in c++ neither makes any difference. Since he made it work I'm thinking this could be the linux version having different lua permissions? Or is removing the sandbox check mark and doing Interpreter::sandboxmode=false; in App::Start() before loading the map not enough to turn off sandbox?
  18. Forgive me if this is a silly question, but my previous experience with collision normals is as follows: collision on X should return Vec3(1,0,0) collision on -X should return Vec3(-1,0,0) collision on Y should return Vec3(0,1,0) collision on -Y should return Vec3(0,-1,0) collision on Z should return Vec3(0,0,1) collision on -Z should return Vec3(0,0,-1) Leadwerks pickinfo.normal returns a fraction depending on where on a face the collision occurs. Is pickinfo.face the "normal" function I'm used to, and maybe pickinfo.normal is describing the hit point? If this is the case, how do you use pickinfo.face, I couldn't find much documentation on it? Thanks!
  19. I've managed to get a Buffer (and Texture) filled with the current screen. I want to write it to a file, so my game will have a builtin screenshot feature. Leadwerks 2 apparently had a function SaveBuffer which would do exactly what I want, but as far as I can tell it doesn't exist or has been renamed to something else. So, before I try to manually write the bytes to a file, does anyone know if there is a current function for writing a buffer to an image file? (Or maybe there is complete function for taking a screenshot that I don't know about?) EDIT: How do I even get individual values out of a buffer?
  20. The title says it all. It seems like I would have to iterate through all valid keys/mouse buttons if I just wanted to know what was just pressed/what is held down without having any expectation of what should be pressed/down. I just wanted to find out how Leadwerks deals with keys not found on a US keyboard like (Ä, Ö, Ü) and mice with more than three buttons. I couldn't find anything that would just get an input event and tell me what it is. This would also be very useful in dealing with options menus for key rebinding though this is still doable with iterating through all valid keys it just seems simpler and more powerful to just get the input event.
  21. I'm familiarizing myself with Leadwerks and so I have a simple test map that lets me place block prefabs like Minecraft. How can I retrieve the name from a pickinfo.entity? I tried the following, but it throws an error in Print in the window:MouseDown(1) check: (argument #3 is 'string'; '[no object]' expected.) function Script:UpdateWorld() if block == nil then block = Prefab:Load("Prefabs/CM/Block.pfb") block:SetKeyValue("name","Block") block:SetCollisionType(Collision.Prop) end local pickinfo = PickInfo() local mousePos = window:GetMousePosition() if (self.player.script.camera:Pick(mousePos.x, mousePos.y, pickinfo, pickradius, true)) then block:SetPosition(Vec3(math.floor(pickinfo.position.x), math.floor(pickinfo.position.y), math.floor(pickinfo.position.z)) + Vec3(pickinfo.normal.x, pickinfo.normal.y/2, pickinfo.normal.z)) end if window:MouseDown(2) then -- Place the block block = nil end if window:MouseDown(1) then -- Delete the block if pickinfo ~= nil then if pickinfo.entity ~= nil then System:Print(pickinfo.entity:GetKeyValue("name")) end --if pickinfo.entity:GetKeyValue("Name") == "Block" then -- pickinfo.entity:Release() --end end end end The other issue I'm having is that the placed prefabs have no physics collision. Thanks, Mike
  22. Quick question, what is the execution order of Lua scripts? For example, if I have a scene with 3 entities with Lua scripts, is the Lua script of the entity that is listed first always called first? I apologize if this is a repeated question since this sounds pretty basic, I tried searching but I couldn't find anything
  23. Whenever you copy and paste things in leadwerks 3.2 it tends to offset it a bit. Not only does it offset it, but it doesn't stick to the grid. This makes it very complex to copy and paste,(expecially with CSG's). Could you change it so that when you copy and paste it locks onto the grid? Would be nice.
  24. How would I go about setting up a perpetually rotating hinge joint? Once its reaches the SetAngle value, it will stop and I have no clue how to cleanly reset it without interrupting the process. The dirty way is to use GetAngle to capture the value just as it nears the SteAngle value and add a ton more to the SetAngle value and just add some more on top but that will break eventually as the numerical value reaches the maximum for floats. Which might take a ton of time but I truly hate conceptually broken code. Anyone got any ideas? Script.pin = Vec3(0,0,1) --Vec3 "Hinge Pin" Script.limitsenabled=false--bool "Enable limits" Script.limits = Vec2(-45,45) --Vec2 "Limits" Script.parent= nil --entity "Parent entity" function Script:Start() startrotation = self.entity:GetRotation() local pos = self.entity:GetPosition() local parent_pos = self.parent:GetPosition() local abs_pos = pos + parent_pos self.joint = Joint:Hinge(abs_pos.x, abs_pos.y, abs_pos.z, self.pin.x, self.pin.y, self.pin.z, self.entity, self.parent) if self.limitsenabled then self.joint:EnableLimits() end self.joint:SetAngle(1080) self.joint:EnableMotor() self.joint:SetMotorSpeed(360) self.joint:SetLimits(self.limits.x,self.limits.y) end function Script:UpdateWorld() --feed me! end
  25. I tried to do: local DateRan = os.date("%Y.%m.%d.%H.%M.%S") but got attempt to index global 'os' (a nil value) I did a search and couldn't see an obvious alternative.
  • Create New...