Jump to content

Recommended Posts

Posted

1.0.0

  • All Lua scripts are updated to work with the definition file generation system.
  • Added close delay to door scripts (Lua only)
  • Like 1
  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

1.0.0

Updated C++ components to work with auto-generated definition files. I might have missed some properties, but it is a good first pass.

This means if you modify the stock C++ components, your new properties and methods will appear in the editor.

  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

1.0.0

C++ header files must now have the comment "Component" after the class declaration, in order for them to trigger a definition file to be written. This prevents base classes that are not meant to be used in the editor from creating a definition file.

class Relay : public BaseComponent//Component
  • Like 1
  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

1.0.0

  • Classes derived from the Entity class are now declared with virtual inheritance.
  • Library and Lua executables are updated.

If you have any problems compiling, update to the latest version of Visual Studio, 17.14.11 (thanks @Dreikblack)

  • Like 1
  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

1.0.0

In previous builds, you had to define a C++ component name in the constructer, like this:

Mover::Mover()
{
	name = "Mover";
}

Specifying the class name like this is no longer necessary. The system will now use the object type ID to figure out the name.

All virtual inheritance in class declarations are now removed, since I don't think this is needed for anything.

Fixed a bug in the FPSGun C++ component that could start you with a random amount of loaded ammo in the gun.

  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

1.0.0

In this build of the editor, when a material is generated, if no metalness texture is present then the material metalness value will be set to 0, while the blue channel of the rough / metal texture will still by 255 (full bright). So if no metal texture is present, the material will be assumed to have zero metalness, but still allow you to adjust the material metal value to make it more metallic if you want to.

  • Like 1
  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

1.0.0

  • Added missing Scene:GetEntity definition method to Lua syntax highlighting.
  • Component is now using virtual inheritance from Object class.
  • Corrected the case of one include file.
  • Added Lua utilities file in Scripts/Start with these functions: isnumber(), isstring(), isboolean(), isfunction(), istable(), isuserdata().
  • Like 1
  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

1.0.0

Replaced File > Load Collider menu item in model editor interface with Load Static Collider and Load Dynamic Collider, for a polygon or multi-convex hull collider.

  • Like 1
  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

1.0.0

Fixed a bug that would cause duplicate child limbs to be saved when the Save as Model feature was used in the editor.

  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

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.
  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

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.

  • Thanks 2

Let's build cool stuff and have fun. :)

Posted

A new branch is created on Steam called "beta2" for testing. This contains a build that adds the ability to atttach properties and functions directly to an entity itself in Lua. You must opt into the beta2 branch to receive this update:

image.thumb.png.3d6aa51a67a76f14cb1ff9964f440ded.png

In this branch, in Lua scripts, self refers to the entity itself. Most self-contained scripts will work with no changes because self.entity will just return self (the entity).

A typical script looks like this. Notice that the script properties and entity methods are both accessible directly from self, without any sub-object:

---@class Mover : Entity
Mover = {}
Mover.rotationspeed = Vec3(0,1,0)--"Rotation"
Mover.globalcoords = false--"World space"

---@param self Mover
function Mover:Update()
  	self:Turn(self.rotationspeed / 60, self.globalcoords)

  	--This will still work, for backwards compatibility:
	--self.entity:Turn(self.rotationspeed / 60, self.globalcoords)
end

Defining a "class" on the line before the table is created will allow Lua language server to show autocompletion for all the properties defined in the script, as well as all the entity members and methods. This is very cool!

Entity script properties will be displayed in a "fields" group in the debugger, just for visual clarity:

image.png.0758559bef7ad068dff06afed48074cc.png

This approach greatly simplifies the interactions of objects, and retrieving the state of other entities in the game. For example, instead of this:

function MyScript:Collide(entity, position, normal, speed)
	local h = 0
	local k, c
	for k, c in pairs(entity.components) do
		if isnumber(c.health) and c.health > 0 then
			h = c.health
			break      
		end
	end
	if h > 0 then Print("Collided entity has health!") end
end

You can now just access the property directly on the entity itself:

function MyScript:Collide(entity, position, normal, speed)
	if isnumber(entity.health) and entity.health > 0 then
		Print("Collided entity has health!")
	end
end

You no longer need to call RegisterComponent, set a name field for the table, or return the table from the script.

All stock scripts have been updated to work this way, along with the FPS example map. The script template is updated, so it will set everything up for you correctly when a new script is added to the project.

There is currently nothing in the editor to prevent you from adding multiple scripts to one entity, but in this build only one of those scripts will get loaded.

For the FPS map, I had a few objects that had a relay attached to themselves, and I just replaced this with a new pivot with a multi-replay script that controls the timing of all the objects in the chain.

A MultiRelay script has been added that accepts an input signal and outputs 8 functions, with an adjustable delay time for each.

The Physics/Impulse script is removed from the stock scripts, since it is no longer needed.

You also have the option to specify optional filters with the World:GetEntities and World:GetEntitiesInArea methods. In this example,  entities will only be returned if they have a numberic health value greater than zero, and a team value that is not equal to nil or this entitiy's own team value.

local players = self.world:GetEntities("health", ">", 0, "team", "~=", self.team, "team", "~=", nil)

You can include any number of filters, with three arguments each, for the field name, operator, and value to compare it to. The following operators are supported: ==, ~=, >, <, >=, <=

  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

Here's another example. This whole block of code in Bullet.lua:

local n
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

Can be reduced down to a single line:

if isfunction(pickinfo.entity.Damage) then pickinfo.entity:Damage(self.damage, self.owner) end

The first example could be further simplified, but I have noticed that with the new system the improvements I can make jump out at me a lot more easily, and it's more obvious what to do to make the code better, whereas with the previous approach I tended to just leave things as-is once they are working.

  • Like 1
  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

The beta and beta branches are removed. You will need to opt into one of the following:

beta-e uses Lua properties attached to entities. This is the same build that was previously called "beta2".

beta-s uses Lua properties attached to entity sub-objects / components. This is the same build that was previously called "beta".

image.thumb.png.e467a1265b530ce2dee125a089c62082.png

  • Thanks 1

Let's build cool stuff and have fun. :)

Posted

Beta

  • Full update of everything
  • In Lua projects, some adjustments have been made to the entity properties UI to better reflect the way entity scripts are working now. Behavior in C++ project is unchanged.

image.png.59dc1f69132b60379dbd12c14fc998b4.png 

  • Thanks 1

Let's build cool stuff and have fun. :)

Guest
This topic is now closed to further replies.
×
×
  • Create New...