Jump to content

Search the Community

Showing results for tags 'code'.

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 19 results

  1. I discovered that there can only be one eventqueue in leadwerks. I wanted local eventqueue instances, so I created a lua based version of EventQueue called EventQueueEx It is initialized as such: MyQueue = EventQueueEx:Create() It is used EXACTLY the same as the Leadwerks version.
  2. Hey there, Just wondering if there is a place to find scripts made by others that are ready to use? I know Leadwerks comes with some, but I'd like to play around with some others too. I've had a quick look around, can't seem to find any or maybe I just missed them all completely. Thanks
  3. This is a query more than anything. As I read the documentation both Script:UpdateWorld() and Script:UpdatePhysics() are both initiated by a single call to World::Update(). In fact the physics is a child of world and is always(?) invoked. So it appears that the separation is more a conceptual one rather than a functional one. The only reason I can think of is by putting all physics in UpdatePhysics then if (I'm not sure) that is invoked first you would know that all physics updates have been applied before you do any other world level checks/logic. So is that it or am I missing something important? I'm feeling rather dense today.
  4. I've been staring at this code for way too long and now I need different brains to look at it. This is the beginnings of a 3rd person character controller. I am now working at adding mouse look features but there seems to be a bug when the camera is at specific angles, notable y45 and y270. At those specific locations the camera glitches out. I will give it another try tomorrow, and no I don't want to create a pivot and anchor the camera to it and spin that --[[ Title: Third Person Controller Author: Einlander Start Date: 1-30-2016 Version: .01 Description: Script to control Player in 3rd person with keyboard and mouse Notes: This script is designed to mimic classical 3rd person game controls: *Look with mouse *Move with WASD *Follow Player as they move ]]-- Script.Cam =nil --entity "Camera" Script.moveSpeed = 2.5 --float "Move Speed" Script.speedMultiplier = 1.5 --float "Run Multiplier" Script.strafeSpeed = 4 --float "Strafe Speed" Script.jumpForce = 8 --float "Jump Force" function Script:Start() self.input={} self.unitangle = Vec3() self.anglemagnitude = nil end --[[ function Script:UpdateWorld() end --]] function Script:UpdatePhysics() local movex=0 local movez=0 self.input[0]=0 self.input[1]=0 local playerMovement = Vec3() -- I learned the boolean shortcuts from my years programming on a Casio Graphing Calculator self.input[1] = self.input[1] + ((window:KeyDown(Key.W) and 1 or 0) - (window:KeyDown(Key.S) and 1 or 0)) self.input[0] = self.input[0] - ((window:KeyDown(Key.A) and 1 or 0) - (window:KeyDown(Key.D) and 1 or 0)) playerMovement.z = self.input[1] * self.moveSpeed -- Strafing playerMovement.x = self.input[0] * self.moveSpeed if self.carryingEntity == nil and window:KeyDown(Key.Shift) then playerMovement.z = playerMovement.z * self.speedMultiplier -- Run while Strafed -- playerMovement.x = playerMovement.x * self.speedMultiplier end local jump = 0 if window:KeyHit(Key.Space) and self:IsAirborne() == 0 then jump = self.jumpForce playerMovement = playerMovement * 1.6 end self.entity:SetInput(0, playerMovement.z, playerMovement.x, jump , false, 1.0, 0.5, true) local startpos = Vec3( self.entity:GetPosition(true).x, self.entity:GetPosition(true).y + 5 , self.entity:GetPosition(true).z -5 ) -- y distance to get above players head, z - distance we want from player local endpos = Vec3() -- rotate the starting position (where the camera is at) around the player position if self.rot == nil then self.rot = 0 end self.rot = self.rot+.5 local finalpos = Vec3() finalpos = self:rotateX3D({startpos},self.entity:GetPosition(true) , 0)[1] finalpos = self:rotatePointY({finalpos},self.entity:GetPosition(true) , self.rot)[1] -- when self.rot ~ 45 or 270 it flips just for that 1 angle -- set camera at the final rotated positon self.Cam:SetPosition(finalpos) -- make camera look at player local lookAt = self:LookAt(self.entity:GetPosition(true)) lookAt.z = 0 -- THIS LINE IS IMPORTANT. DO NOT REMOVE IT, IF YOU DO IT WILL CAUSE A JUMP WHEN THE Z ANGLE CHANGES FROM NEGATIVE TO POSITIVE OR VICE VERSA self.Cam:SetRotation(lookAt,true) end function Script:IsAirborne() return self.entity:GetAirborne() and 1 or 0 end function Script:LookAt(lookAt) --http://www.leadwerks.com/werkspace/topic/10191-short-example-of-mathatan2/page__hl__lookat --http://stackoverflow.com/questions/1251828/calculate-rotations-to-look-at-a-3d-point --http://leadwerks.wikidot.com/wiki:face-entity --// Calculate angle from point A towards point B local tv = lookAt - self.Cam:GetPosition(true) local tRoty = Math:ATan2(tv.x, tv.z) local tRotx = 0 if lookAt.z >= self.Cam:GetPosition(true).z then tRotx = -Math:ATan2(tv.y* Math:Cos(tRoty), tv.z) else tRotx = Math:ATan2(tv.y* Math:Cos(tRoty), -tv.z) end tRotz = Math:ATan2( Math:Cos(tRotx), Math:Sin(tRotx) * Math:Sin(tRoty) ) return Vec3(tRotx,tRoty,tRotz-90) end function Script:Get3dDistance(pointa --[[as vec3--]], pointb--[[as vec3--]]) --[[as float--]] return math.sqrt((pointb.x - pointa.x)^2+ (pointb.y - pointa.y)^2+ (pointb.z - pointa.z)^2) end function Script:Get3dMagnitude(pointa --[[as vec3--]]) --[[as float--]] --http://www.fundza.com/vectors/normalize/ return math.abs(math.sqrt((pointa.x * pointa.x)+ (pointa.y * pointa.y)+ (pointa.z * pointa.z))) end function Script:NormalizeVector(pointa--[[as vec3--]], length--[[as float--]])--[[as vec3--]] --Yes I know leadwerks has these functions built in somewhere, but sometimes you just need to learn what it is you are exactly doing --http://www.fundza.com/vectors/normalize/ pointa.x = pointa.x / math.abs(length) pointa.y = pointa.y / math.abs(length) pointa.z = pointa.z / math.abs(length) return pointa end toRadians = function(degrees) return degrees / 180 * math.pi end function Script:rotatePointY(points, origin, degrees) local pointsout = {} for i = 1, #points do local point = Vec3(points.x,points.y,points.z) local x = origin.x + ( math.cos(toRadians(degrees)) * (point.x - origin.x) - math.sin(toRadians(degrees)) * (point.z - origin.z) ) local z = origin.z + ( math.sin(toRadians(degrees)) * (point.x - origin.x) + math.cos(toRadians(degrees)) * (point.z - origin.z) ) point.x = x point.z = z table.insert(pointsout, point) end return pointsout end function Script:rotatePointZ(points, origin, degrees) local pointsout = {} for i = 1, #points do local point = Vec3(points.x,points.y,points.z) local x = origin.x + ( math.cos(toRadians(degrees)) * (point.x - origin.x) - math.sin(toRadians(degrees)) * (point.y - origin.y) ) local y = origin.y + ( math.sin(toRadians(degrees)) * (point.x - origin.x) + math.cos(toRadians(degrees)) * (point.y - origin.y) ) point.x = x point.y = y table.insert(pointsout, point) end return pointsout end function Script:rotatePointX(points, origin, degrees) local pointsout = {} for i = 1, #points do local point = Vec3(points.x,points.y,points.z) local y = origin.y + ( math.cos(toRadians(degrees)) * (point.y - origin.y) - math.sin(toRadians(degrees)) * (point.z - origin.z) ) local z = origin.z + ( math.sin(toRadians(degrees)) * (point.y - origin.y) + math.cos(toRadians(degrees)) * (point.z - origin.z) ) point.y = y point.z = z table.insert(pointsout, point) end return pointsout end function Script:rotateX3D (points, origin, degrees) local pointsout = {} for i = 1, #points do local point = Vec3(points.x,points.y,points.z) local y = point.y; local z = point.z; point.y = origin.y + (y- origin.y) * math.cos(toRadians(degrees)) - (z - origin.z) * math.sin(toRadians(degrees)); point.z = origin.z + (z- origin.z) * math.cos(toRadians(degrees)) + (y - origin.y) * math.sin(toRadians(degrees)); table.insert(pointsout, point) end return pointsout end function Script:WrapAngle(angle) local currentrotation = angle if currentrotation.x < 0 then currentrotation.x = 359 - math.mod(currentrotation.x , 359) end if currentrotation.y < 0 then currentrotation.y = math.mod(currentrotation.y , 359) currentrotation.y = 359 - math.abs(currentrotation.y) end if currentrotation.z < 0 then currentrotation.z = 359 - math.mod(currentrotation.z , 359) end currentrotation.x = math.mod(currentrotation.x , 359) currentrotation.y = math.mod(currentrotation.y , 359) currentrotation.z = math.mod(currentrotation.z , 359) return currentrotation end --[[ function Script:Collision(entity, position, normal, speed) end --]] --[[ function Script:Draw() end --]] --[[ function Script:DrawEach(camera) end --]] --This function will be called after the world is rendered, before the screen is refreshed. --Use this to perform any 2D drawing you want the entity to display. function Script:PostRender(context) context:SetBlendMode(Blend.Alpha) local pos = self.Cam:GetRotation(true) local outText = "Actual angle" .. pos.x .. "|" ..pos.y .."|" ..pos.z --local outText = self:FaceEntity(self.Cam:GetPosition(true),self.entity:GetPosition(true)).x .."|" .. --self:FaceEntity(self.Cam:GetPosition(true),self.entity:GetPosition(true)).y .."|" .. --self:FaceEntity(self.Cam:GetPosition(true),self.entity:GetPosition(true)).z context:DrawText(outText,0,150) context:DrawText("Distance:" .. self:Get3dDistance(self.Cam:GetPosition(true) , self.entity:GetPosition(true)),0,165) pos = self.unitangle local outText = "unit angle" .. pos.x .. "|" ..pos.y .."|" ..pos.z context:DrawText(outText,0,180) pos = self.Cam:GetPosition(true) local outText = "Cam Position" .. pos.x .. "|" ..pos.y .."|" ..pos.z context:DrawText(outText,0,195) pos = self.entity:GetPosition(true) local outText = "Player Position" .. pos.x .. "|" ..pos.y .."|" ..pos.z context:DrawText(outText,0,210) end --[[ --This function will be called when the entity is deleted. function Script:Detach() end --]] --[[ --This function will be called when the last instance of this script is deleted. function Script:Cleanup() end --]]
  5. SetColor(1,1,1, 0.5) don't work(For each models in fame). I've tried everything. Help, please. What am i doing wrong?
  6. Have anyone code simples whis using sprites(Like a model, for bullets, for example)? It all, that i need
  7. Did anyone know, how to create effects like in ?Code sample, if possible
  8. If you now, fast objekts skip collision check and move through other objekts. Have engine any standart methods preventing it?
  9. When i create surface it look like it does not reflect light — very-very dark. What parameter setting it?
  10. What i need to setup qraphics to model like in editor? Open GL support all af this, but i don't know how turn on this methods
  11. Have anyone code exapmles with buffers using? In wiki it is VERY old
  12. Hi. How to check collision whith trigger and other objects and return this objects adress? In C++
  13. So, i want create models in real time via set vertices of this model, but model class have not similar functions
  14. So, i wanna project image that "see" camera at other place. How i can do that? I think, it have function simple fo this goal
  15. I thought you should know that the last update rendered the default fpsplayer code unable to look up or down. I have my own fps code I use, but thought I should tell you. Thank you.
  16. Hey so I have been messing around with the map changer that came with leadwerks (copied it and renamed it so I have the original still) to choose between random seed maps (initial starting areas the rest is generated) but when it tried to change maps it crashes or gives me a lua stack overflow issue. Is there something wrong with my code? Here it is. --[[ This script will act as a trigger to change the current map. Place this at the end of your map to make the player progress to the next level. ]]-- Script.mapname={} Script.mapname[0] = "" --string "Map Name" Script.mapname[1] = "" --string "Map Name" Script.mapname[2] = "" --string "Map Name" Script.mapname[3] = "" --string "Map Name" function Script:Start() self.enabled=true math.randomseed(Time:Millisecs()) math.random();math.random();math.random(); self.counter = 0 end function Script:Collision(entity, position, normal, speed) changemapname = math.random(0,3) end function Script:Enable()--in if self.enabled==false then self.enabled=true self:CallOutputs("Enable") end end function Script:Disable()--in if self.enabled then self.enabled=false self:CallOutputs("Disable") end end
  17. I believe this is a bug. When I put a pick-up code on an item (weapons collectables ect) and choose the mesh for it to represent, the (in case of the weapons) mesh chosen will show close to the pick-up mesh. Also if you have a weapon equipped then the mesh doesn't disappear when you pick up the pick-up. here is a pic of what appears with the pick-ups ( a few steps away)
  18. Hello everyone, I am creating a game where the player has to use physics to navigate the level, such as stacking objects to create stairs to get to a point, etc. In said game, the player can accidently drop objects off the level or get them destroyed by other forces. I would like to implement a feature where the player can hit a key and the level and all scripts, lighting, etc. is reloaded. This code must be in C++. How can I do this? Please help. Thanks.
  19. It's the holiday season again. As the forest air reaches freezing temperatures, I break out the ice shaver for my windshield. It's a time for celebrating family, sharing thanks for what we have, and behavior sets. That's right, fuzzy-logic for AI in-game. Since the world designers for the game won't have access to the direct behaviors, (nor the programming skills to code such things) I've managed to find some use for the custom Entity keys on objects in the Sandbox! Each entity will have actions assigned to a set of situations. Think of it like 'IF' statements that world builders have access too. This Enumeration of behaviors gives the designers flexibility to alter the NPCs actions easily within the sandbox. Global preset behavior collections, or custom sets per situation. For example, and NPC who follows the player may have something similar to this DefaultTarget = Player DefaultAction = FollowTarget Now if the NPC needs to defend the player... GuardTargetAction = KillAttacker Or... GuardTargetAction = HealTarget
  • Create New...