Is it possible to load external modules such as MQTT? If so, is there any documentation on how this can be done? I have a good amount of programming background but haven't done much scripting with Lua until recently. I've read something regarding Lua Rocks; however, the tool is looking for a lua.exe binary.
Thanks!

Hi,
I pretty often encounter the followning problem: I need something to be called before, or after the Start function of an script.
My actual problem is that I have an NPC and his "Load" function (I wrote by myself) is called before the script actually is initiated. The problem is, in the load function some values are set (like npc health) but then the script gets initiated and the script uses the default script value of 100% health and the loading does not work. A workaround I found is to use the first step of the update function but I find this not very smart. Here an example:
function Script:UpdateWorld()
if self.doOnce ~= true then
--do something here
self.doOnce = true
end
end
Any ideas how to solve this more elegant? Would be really glad if we could gather some ideas
Markus

Hi,
I have a general inventory script attached to every object, which should have an inventory. In the script settings of the inventory script I put an "firstSlotOffset" value, to adjust where the inventory starts to render its slots. In code this looks like that:
Script.firstSlotOffset = Vec2(0, 0) --Vec2 "Slot Offs."
In the start function I do some calculation:
self.firstSlotOffset.x = self.firstSlotOffset.x * context:GetWidth()
self.firstSlotOffset.y = self.firstSlotOffset.y * context:GetHeight()
The problem is if I load to another map and back to some other map the self.firstSlotOffset value seems corrupted. This happens only after I loaded twice (so changed the map two times). I found that out by printing the self.firstSlotOffset value in the start function. What I mentioned is if you loaded twice the self.firstSlotOffset value is not what is set in the script settings but the result of the above calculation which should not be. If you change a map, all variables should be "nil"-ed shouldn't they? And by the way what do you have to take care on when loading to an new map? Do you need to clean stuff up and if yes which stuff? I guess that could be the problem that I didnt clean up.
P.S.: The error only appears for the player inventory, which is the only entity staying the same on both maps I load to.

Just a quick question, I've been exploring the technologies of other engines and I've seen some very unique lighting techniques for global illumination in real-time. Is there any technology implemented within the Leadwerks to allow this feature, or is there any way to implement Nvidia's tech (Voxel-based Global Illumination, as seen in the Unreal Engine) through the use of their GameWorks SDK which requires direct contact to the OpenGL implementation (I believe, don't quote me on this)?

EDIT:
Just found out that the error was somewhere else ^^. The below code just works fine. Anyway thank you for the help :).
Hi there,
I faced some weird behavior, testing and debugging my project. The following shows the structure of my code, it would be very kind of you, if you could tell me if you can find any error, because I dont. Maybe I messed around with global/local/script variables, which I know, often cause such errors.
Explanation:
Of course this script makes no sense, but it should only representate the structure, because it would be way to complicated to explain the issue within the actual script. So what is the problem? When I apply the "Main Script" to one entity, everything works fine and I get printed the data. but if I apply the "Main Script" to more than one, for example two, then the problem occurs. In the output I get the "Send my data!"-message, but now comes the weird thing. It prints the data and then, even if the "Test"-function is just called once it prints "Variable data is nil!" twice. And this happens for both entitys. So this is my output with two entities with the "Main Script":
Send my data!
Test
Variable data is nil!
Variable data is nil!
Send my data!
Test
Variable data is nil!
Variable data is nil!
Main Script:
Script.dataToSend = "Test"
Script.data = nil
import "exampleScript.lua"
function Script:Start()
self.myLuaClass = testClass(self)
end
function Script:Test(data)
if data ~= nil then System:Print(data) else System:Print("Variable data is nil!") end
end
The "exampleScript.lua" Script:
function testClass(script)
local container = {}
function container:CallMeFromAnywhereToSendSomething()
self:SendSomething(script.dataToSend)
end
function container:SendSomething(sendData)
if sendData ~= nil then
script.data = sendData
end
if script.data ~= nil then System:Print("Sent my data!") script:Test(script.data) end
end
return container
end
Addition:
I was able to work around this issue by simply checking if the variable is nil, or not (I actually need/do stuff with the "data" variable in my actual script), but still I am confused. Maybe you can help me out. If you find other mistakes, or have improvement suggestions for my "Class" system please tell me. Thanks for reading

Hello,
I have recently purchased the Leadwerks game engine and Professional DLC. The DLC is installed correctly and I can see the .cpp source files in the script editor. I was about to create a few of my own classes but noticed that although I can open .cpp files in the editor I am only able to save new source files in .lua
Does the built in script editor support new .cpp files, what am I missing?
Cheers.

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

I was looking into improving the already implemented flashlight, but unfortunately my limited coding knowledge made me stuck pretty quickly, so here was my idea.
Have a flashlight model be a child of the fpsplayer (so it follows the mouses movement), line it up so it looks good, make a spotlight coming out of it, and then implement Hankinator's battery script to work with the new spotlight.
Battery script:
http://www.leadwerks.com/werkspace/topic/12783-flashlight-battery-tutorial/page__hl__flashlight
Problem is, I can't really figure out how to make it so that when the player presses F, the new spotlight appears and not the current one, and also how to implement the battery part of the code to work with it. (Since the battery script interacts with the player and not a child of the player)
Any guidance would be extremely helpful! Thanks!

I'm in the process of making my first game, so i went to Leadwerks and started creating things.
The problem comes when I want to make that a door opens when 2 pressure plates are activated.
So, i wrote this code to create a "switch" that requires 2 inputs to output a signal to the door (in the flowgraph editor), but it doesn't work...
function Script:Start()
bool1 = false
bool2 = false
end
function Script:Input1() --in
bool1 = true
end
function Script:Input2() --in
bool2 = true
end
if (bool1 == true and bool2 == true) then
self.component:CallOutputs("Output")
end
what i'm doing wrong? i'm very new in programming

After a long while of inactivity on the forums, I wanted to take the time and share my boilerplate and base game application, in c++, for the Leadwerks game engine. The source can be found here.
This project uses V$ 2013, C++11 and Leadwerks 3.X. There are currently no external dependencies outside from the full version of Leadwerks Game Engine, on Steam. If you have any problems setting up the application just let me know. I will gladly assist in any way possible. You should be able to clone/download the repo, drag in the Leadwerks asset folders, and be on your way!
What it includes:
Base Game Object
Input Manager
State Manager
Camera Manager
Planned enhancements:
Event Management
Network integration with Steam
Voxel Management
Game Object Management
Weapons and Bullets
Several generic C++ containers
much much more
The planned enhancements are actually already complete, I am just taking them out from my existing game application, cleaning them up, and adding documentation. I look to push changes to the public-facing repository bi-monthly.
I would love to get some feedback about what you guys and gals think, whether you are using it in your projects, and or what you think the template could use. I will be posting notes on my IndieDB blog as well to follow my releases.
P.S. The current template contains a simple example, demonstrating the use of the Game Object, Camera Manager, and how to switch between Camera Behaviors.

Hi,
I created a simple cube to animate with two bones on Blender 2.75a, and exported on FBX animation... Importing with Leadwerks and i don't see animation but only with two bones already created, please help me how to see for animation, have i missing it something ? There is a file to check what is wrong.

This is a link to the topic in the Programming area, but I am guessing it is really a GNU/Linux matter:
http://www.leadwerks.com/werkspace/topic/14289-material-patches-missing-on-model/
Do any other GNU/Linux users encounter this problem with setting up models?

Friendly Greetings!
I am an intermediate programmer that just wants to get acclimated with the Leadwerks 3D game engine and the Lua language. Can someone point me in the right direction?
Thank you in advance.

I am trying to make it so when you press space it advances to the next map, but am having a little trouble. I have it embedded in the Player (for the ball game template). Here's what I have
Script.mapname=""--string "Map Name"
if self.levelcomplete then
if window:KeyHit(Key.Space) then
return Map:Load("Maps/"..self.mapname)
end
When I hit space, the text disappears and reappers really fast. It's doing something, but I don't know what. Are there any suggestions???

Hello people. I am working on a new Marble Run like game (Because I may or may not have deleted my first one...). I have a few quick questions though
1. How do you add a start menu with a way to start a new game, and a way to choose different worlds. I sort of had in mind a thing like where it would show a picture with a yellow box around it, and you choose world 1 or world 2, but just have no clue what I am doing
2. How do you add a logo-animation at the beginning of the game while it loads (Like how valve has the guy with the valve in his head at the beginning of portal/halflife/every other valve game)?
Thank you in advance for responding.

I'm trying to create a script that spawns an object every so often at a set time, but I keep getting a script error that says " '=' expected near 'function'". I'm new to programming and have no clue what that means. here's a screenshot of it in context. ANy help would be very appreciated.
Script.spawnObject = "" --entity "Object"
Script.spawnTimer = 1.5 --float "Spawn timer"
Script.timer
function Script:UpdateWorld()
self.timer = self.timer + (Time:GetSpeed()/100)
if(self.timer > self.spawnTimer) then
local newObject = self.spawnObject:Instance()
newObject:SetPosition(self.entity:GetPosition())
self.timer = 0
end
end

5 years ago I wanted to learn programming. Still don't know how they make a script for a game.
I mean i know how to make make up a website with HTML and CSS. But i guess that is something totally different.
A lot of people say that programming is pretty easy once you know the basics. Like Variables Loops and something new I've learned Tables. i mean u can tell me what a Loop is but i will never shake this out of my head >>>
--Create a window
window = Window:Create()
--Create a rendering context
context = Context:Create(window)
--While loop
while window:KeyHit(Key.Escape)==false do
--Set the drawing color and clear the screen
context:SetColor(0,0,0)
context:Clear()
--Set the drawing color and blend mode
context:SetColor(1,1,1)
context:SetBlendMode(Blend.Alpha)
--Draw some text onscreen
context:DrawText("PRESS ESCAPE TO END THE PROGRAM.",2,2)
--Update the screen
context:Sync()
end
So my point is. Are there any specific ways to learn programming or replace programming in some way for people that are struggling with this problem. This is something that should not make someone give up their idea because he or she can not write a code.
thanks for reading,
Jefferey Oertel
2D/3D Artist

When I started the engine I thought I should combine the Lua and C++. For example scripts to do on Lua ,game logic and mechanics on C++. But everything you can write in C++, you can also write and Lua and I thought - does it make sense to combine Lua and C++? Are there any advantages in the combination of two languages?

1. I have been searching in the Internet and found a Rover model: http://opengameart.org/content/mars-rover
When I open it up in Blender, it says the rotation is 000, as well as the location.
But when I import it inside Leadwerks, it says that the rotation is 90,0,0 (it is rotated right, but it should be 0,0,0). That is why there are some problems with the car script.
2 The car script does not work on the rover, even if all physics are adjusted as same as the prefab car,
the rover tires have some weird position and only the starting sound appears to work.
3. So now I taught I will make it like this : SetParent the rover to the car and put an invisible material on the car(also scale it so it handles more realistic).
This has workend in parts, when I have no physics on the rover. Now the problem is , when I make this the rotation is 0,0,0 and not 90,0,0 ,so the rover is not rotated correct.
http://steamcommunity.com/sharedfiles/filedetails/?id=345315752&searchtext=car
Also something else, that is probably caused by the settings file:
I cannot select a box (or else shape) for the physics inside the editor.
I only see the following: physics mode, collision type, Mass, character angle, swept collision, nav obstacle.

Hello
My problem is that I have an Pivot which has the platform.lua script attached.
when I test it out and select it to be enabled at the program start, everything works just fine.
The pivot with all the atttached models are moving right where I want them and at the right speed.
But when I select it to be disabled at the start of the program, it just keeps locked.
I am pretty sure when you are ingame you cant make it change or just start inside the game.
I tested it inside flowgraph editor with multiple ways : collision, pushbotton (none of them work)
It am very confused about that since the most part of the script is in update...() functions.
So how do you can make it change (via flowgraph) ?