Jump to content

Leadwerks 5 Scripting


Josh
 Share

Recommended Posts

I have this script working now with sol2:

print("Starting...")

local window = CreateWindow("My Game",0,0,1024,768)
local context = CreateContext(window,0)

local world = CreateWorld()

local model = CreateBox(world,1,1,1)
local camera = CreateCamera(world)

local v = Vec3(0,0,-5)
camera:SetPosition(v,false)

while true do
	
	local table = {}
	table.value = 1
	table.test = 3
	table.mything = "Hello how are you?"

	if window:KeyHit(KEY_ESCAPE) then break end

	if window:KeyHit(KEY_SPACE) then
		model = nil
	end
	
	if window:KeyHit(KEY_G) then
		collectgarbage()
	end

	world:Render(context)
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

1 hour ago, AggrorJorn said:

Very nice. Is calling the garbage collector something we will have to do or is this handled internally?

 

Lua automatically calls the GC when enough memory is accrued, but you can also call it yourself whenever you want.

  • Like 1

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

I’m at home right now and don’t have my computer here. I am very curious about something. Can someone please run this code in main.lua and telll me what it prints out?

v1 = Vec3(1,2,3)
v2 = Vec3(1,2,3)
v3 = v2

v3.x = 69

print(v1)
print(v2)
print(v3)

 

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...