Jump to content

All Activity

This stream auto-updates

  1. Yesterday
  2. newcomer here, bought leadwerks lua edition some years ago, and a total noob in programming (even if i understand some concepts) something was not working for me at line 195 in goblinai script that lead to a crash of the simulation...but i found a solution that worked, i'm so proud of myself if someone has the same error, just ask
  3. Here is an updated video. Not perfect yet, but better:
  4. The code wasn't there on a new project. Maybe he forgot to change it or doesn't know the best all-around solution is..
  5. Was this change added to official build? Had to change shader file manually to fix shadow acne again
  6. Last week
  7. If you have any examples of good modern terrain textures post them here. It's okay if they are in a commercial game, we can just use them as inspiration without copying them exactly. I'm looking for ideas. I have a good artist available and although the wide variety of photo-based materials we have is nice, I am not entirely happy with their cohesion.
      • 2
      • Like
  8. 1.0.0 I thought the slow speed of Lua games in debug mode was due to not using LuaJIT, but it was actually caused by some unoptimized code in the built-in debugger that executes each frame. The speed when the built-in debugger is running is much faster in this build. Yuu sync your project to get the latest Lua executables for the built-in IDE's debugger to work correctly. Games will run a lot faster with the debugger on now.
  9. That did the trick, thanks!
  10. A similar report was resolved recently. I think this will be fixed if you opt into the beta branch on Steam. (See the application properties when you right-click on the app on Steam.) If this is a Lua game, you will need to sync the project to get the new Lua executables.
  11. Default, afaik. However it ships on steam by default.
  12. Are you on the default or beta branch?
  13. In update of fps player in window loop: FPSPlayer.lua local pickInfo = self.camera:Pick(framebuffer, cx, cy, 0, true) Usually it happens in monster fight for some reason, but very randomly. Sometimes it happens when you enter in a room with first one, and another time it may not happen at all. So just try few times and you can put a player before monster trigger for faster reproducing, Can't pause debug to see if it's in loop or something, so probably it's in the engine code. Spent hours to find out what was causing it. Steam beta.
  14. The World Camera entity carries two components whose update functions simply won't execute so long as the World Camera is a child of a child. If we move said entity to the same level as the Camera Base entity, so on the level of a child of the Player pivot, the scripts execute flawlessly. https://ibb.co/0jHQjCrJ
  15. Thats how it should be instead of removing components and putting everything in entities:
  16. OOP (Object-Oriented Programming) in short: Encapsulation – bundling data and methods that operate on it into objects, controlling access. Abstraction – hiding implementation details, showing only the necessary interface. Inheritance – creating new classes based on existing ones, reusing and extending functionality. Polymorphism – the ability of different classes to be treated through a common interface, with behavior depending on the actual type. Modularity - the property of a system that has been decomposed into internally cohesive but loosely coupled modules. Thats what you currently do, i did improve for lua by my script and thats what Josh wants to destroy for no real reasons instead of doing what i did internally in the Engine. About OOP.lua: It starts before main.lua as script from "Source\Start" and add global functions that allow you to do Inheritance and Interfaces for tables, including components. CreateClass("className", BaseClass) - it needed to make table support interfaces and add parent table if needed to use its variables and methods component:AddInterface("interfaceName") - to add interface's variables and methods. Could be several of them per class. To use in component you just need to do: Monster = CreateClass("Monster") Monster:AddInterface("Killable") Interface scripts should be in Source\Interfaces folder To make one do something like that inside script: return CreateInterface("Killable", { health = 100, team = 0, Kill = function(self) end, IsDead = function(self) return self.health <= 0 end, DamageEffect = function(self, amount, attacker) end, Damage = function(self, amount, attacker) if self:IsDead() then return end self.health = MoveTowards(self.health, 0, amount) self:DamageEffect() if self:IsDead() then self:Kill() end end }) CreateInterface(name, members) - name of interface and vars with functions inside of {} You can make function implementation inside of functions there and use self as self of component, including interface functions and variables Or you can leave function body empty: "DamageEffect = function(self, amount, attacker) end" You can check if entity interface in a very simple way: GetComponentByInterface(entity, "Killable") So for example checking and doing damage for entity in bullet component will looks like that: local pickinfo = world:Pick(pos, nextpos, 0.0, true, Bullet.PickFilter, self.owner) local killable = GetComponentByInterface(pickinfo.entity, "Killable") if killable then killable:Damage(self.damage, entity) end No loops or removing component requires to make proper OOP code already. For comparison it looked like that before in Josh code: if type(pickinfo.entity.health) == "number" then pickinfo.entity.health = pickinfo.entity.health - self.damage for n = 1, #pickinfo.entity.components do if type(pickinfo.entity.components[n].Damage) == "function" then pickinfo.entity.components[n]:Damage(self.damage, entity) end if pickinfo.entity.health <= 0 and type(pickinfo.entity.components[n].Kill) == "function" then pickinfo.entity.components[n]:Kill() end end end And his way requiring copy pasting same functions and vars in every component that you want to make killable or usable for example. And it will not looks much better after removing components anyway: if type(pickinfo.entity.health) == "number" then pickinfo.entity.health = pickinfo.entity.health - self.damage if type(pickinfo.entity.Damage) == "function" then pickinfo.entity:Damage(self.damage, entity) end if pickinfo.entity.health <= 0 and type(pickinfo.entity.components[n].Kill) == "function" then pickinfo.entity:Kill() end end And even if Josh add Damage and health members in every entity (which is just silly), it will be same for anything else and in same time you will loose the most basic thing of modern engines as Component system without getting any real advantages. Source code: https://github.com/Dreikblack/OOP-FPS-Template OOP.zip
  17. This is very interesting. I just created a box in code, set the health and team values, and the monster will start to attack the box. local box = CreateBox(world) box:SetPosition(0,1,0) box:SetColor(1,0,0) box.health = 100 box.team = 0 This tricks the monster into thinking the box is alive, and is on an opposing team, so he should attack it. I did not have to add the box into any lists or add a tag, or anything else. The monster just detects the entity because it meets the requirements of the query it uses when choosing a target: local players = self.world:GetEntitiesInArea(p0, p1, "team","~=",self.team, "team","~=",nil, "health",">", 0) This will filter through what could be a large number of entities and return only the ones we are interested in. Checking the team is not nil will ensure the monster does not start attacking a non-player object like a breakable crate, that could use a health value to make it break if the player shoots it. I can dynamically add functions to the box entity, and after he finishes killing it, it disappears and he will come running after me: function box:Damage(amount) self.health = self.health - amount end function box:Kill() self:SetHidden(true) end This is not even a component script, it's just code I stuck in main.lua before the main loop.
  18. 1.0.0 Editor now generates thumbnails for prefabs. Delete C:/ProgramData/Leadwerks/Thumbnails if you want to force new thumbnails to be created. Some missing Lua bindings added. Added Entity:HasTag, Lua builds only updated at this time. Spacing between viewports in main window is 50% thicker now.
  19. Fixed.
  20. This would also work: function MyUpdateFunction(self) if self.globalcoords then self.entity:Translate(self.movementspeed / 60, true) else self.entity:Move(self.movementspeed / 60) end self.entity:Turn(self.rotationspeed / 60, self.globalcoords) end Mover = {} Mover.name = "Mover" Mover.movementspeed = Vec3(0)--"Movement" Mover.rotationspeed = Vec3(0,1,0)--"Rotation" Mover.globalcoords = false--"World space" Mover.Update = MyUpdateFunction RegisterComponent("Mover", Mover) return Mover
  21. Adding it now...
  22. Title
  23. I'm starting to document some properties and functions that are commonly used in scripts. You are not required to follow these conventions, but if you do your scripts will magically work together with other scripts that other people write, even if they weren't designed with each other in mind: https://github.com/Leadwerks/Documentation/blob/master/Lua/Components.md#common-properties I want to go very carefully and only add things to the list when I am sure they are the right design for most use cases. As time goes on I expect this list will expand.
  24. You can also simply copy a function from one table to another: local t = {} function t:Update() if self.globalcoords then self.entity:Translate(self.movementspeed / 60, true) else self.entity:Move(self.movementspeed / 60) end self.entity:Turn(self.rotationspeed / 60, self.globalcoords) end Mover = {} Mover.name = "Mover" Mover.movementspeed = Vec3(0)--"Movement" Mover.rotationspeed = Vec3(0,1,0)--"Rotation" Mover.globalcoords = false--"World space" Mover.Update = t.Update RegisterComponent("Mover", Mover) return Mover
  25. Please be specific.
  26. TweenMethod() is not in docs and used in FPS template, what is that even O_o I guess it reduce color of entity with time and emit EVENT_TWEENEND at the end. but not sure about details
  27. Honestly I recommend moreso individual tutorials in actual mechanics instead of broader stuff Also I heavily recommend explaining the important "backend" mechanics(like level transitions, or making "fairer" enemies that don't attack all at once)
  1. Load more activity
×
×
  • Create New...