Jump to content

LE3 Lua


Benton
 Share

Recommended Posts

  • 2 weeks later...

Here's another shot showing it actually working. The argument count is being loaded from scripts, and the functions can be specified as an argument or an execution function.

post-1-0-58133400-1338852590_thumb.jpg

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

So trying to follow this. So when Box 1 enabled is fired it'll call the box 4 enable function passing in box 2 and box 3 return value of GetValue() function. Something like:

 

box4.enable(box2.GetValue(), box3.GetValue())

 

 

Putting them all to boxes makes it harder to understand. Are we going to be able to attach scripts to more of a generic "game object" or maybe even a pivot? Are you going to have pre-made entities like lights or sound? That way we could drag in a light entity and from box 4 that maybe has a collision script attacked we drag the OnCollide output to the light's TurnOn function, passing to it a variable we defined on a pivot?

Link to comment
Share on other sites

Putting them all to boxes makes it harder to understand. Are we going to be able to attach scripts to more of a generic "game object" or maybe even a pivot? Are you going to have pre-made entities like lights or sound? That way we could drag in a light entity and from box 4 that maybe has a collision script attacked we drag the OnCollide output to the light's TurnOn function, passing to it a variable we defined on a pivot?

Yep.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Take my money/IOU

 

Dont forget docs. The most forgotten but useful thing for software. Make sure they are really detailed. Let Leadwerks 3 be known for really good docs!

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

Yeah, if I skipped on docs, I might as well not do anything. They're important, and the design of Leadwerks3D makes it easier for me to say "this is the way to do x".

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Function reloading from script files works, even with arguments attached to connections! This means you can dynamically edit scripts, and see the result immediately when you save, even if they are in use in the flowgraph.

 

post-1-0-31842100-1339008999_thumb.jpg

 

The code behind this is pretty complex, but I don't see any way to write clean and neat code to do such a complicated task. I think the trick here is to test, test, test, and make sure there are no mem leaks. I try to keep the convoluted stuff in the editor, where no script is actually executed, and then it's easier to keep the engine code clean.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 1 month later...

Here's a sample script:

Script.movement=Vec3(0)--Vec3 "Player movement"

function Script:Attach()
   print("Calling Attach() function")
end

function Script:Update()
   local player = tolua.cast(self.entity,"Player")-- cast Entity to Player class
   if player~=nil then
       player:SetInput(0,1)
   end
end

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

The casting in the previous example was actually unnecessary.

 

Here's a better example I will try out tomorrow:

Script.target = nil--Entity
Script.distance = 10--float
Script.radius = 0.5--float
Script.smoothness = 0.5--float

--This script will make a camera follow any entity

function Script:RenderWorld()

--Make sure the target entity exists
if self.target~=nil then

--Get the target entity's position, in global coordinates
local p0 = self.target:GetPosition(true)

--Calculate a second point by backing up the camera away from the first point
local p1 = p0 + Transform::Normal(0,0,-1,self.entity,nil) * distance

--Perform a raycast to see if the ray hits anything
local pick = self.entity.world:Raycast(p0,p1,self.radius)
if (pick~=nil) then
--If anything was hit, modify the camera position
p1 = pick.position
end

--Set the camera position in global coordinates
local currentpos = self.entity:GetPosition(true)
if self.smoothness>0 then
p1.x = Math:Curve(currentpos.x,p1.x,self.smoothness)
p1.y = Math:Curve(currentpos.y,p1.y,self.smoothness)
p1.z = Math:Curve(currentpos.z,p1.z,self.smoothness)
end
self.entity:SetPosition(p1,true)
end
end

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...