Jorns2 Posted October 5, 2019 Share Posted October 5, 2019 Hi, i started programming my game with c++. When i tried to load context,world,window everything is ok. When i call world->Update i give error: attempt to index world a nil value or something like this. . In definition is virtual void Render();//lua. If i understand this good world->Render method is executed only in .lua script? Why ? This is caused when i Load map in c++.. Thanks for answers. Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted October 5, 2019 Share Posted October 5, 2019 9 hours ago, Jorns2 said: In definition is virtual void Render();//lua. If i understand this good world->Render method is executed only in .lua script? Why ? No, the comment "//lua" only means that this function is available in lua, as well, but that does not mean, that it is only executed in lua. As for your other problem, it seems like you might not be setting the variable "world" before calling the Update-function or you are probably setting a function-local variable in the Start-function and then accessing a global variable in the update function or something like that. It's hard to say without seeing your code. Quote Link to comment Share on other sites More sharing options...
Jorns2 Posted October 5, 2019 Author Share Posted October 5, 2019 I have used a example script from documentation #include "Leadwerks.h" using namespace Leadwerks; Model* model = NULL; int main(int argc, const char *argv[]) { Leadwerks::Window* window = Leadwerks::Window::Create(); Context* context = Context::Create(window); World* world = World::Create(); Camera* camera = Camera::Create(); camera->Move(0,0,-3); Light* light = DirectionalLight::Create(); light->SetRotation(35,35,0); model = Model::Box(); model->SetColor(0.0,0.0,1.0); while (true) { if (window->Closed() || window->KeyDown(Key::Escape)) return false; model->Turn(0,Leadwerks::Time::GetSpeed(),0); Leadwerks::Time::Update(); world->Update(); world->Render(); context->Sync(false); } return 0; } and then: Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted October 5, 2019 Share Posted October 5, 2019 I am pretty sure, the problem is coming from a LUA script of an object in your map, not from C++. That script has probably a world render or update hook, where it tries to access that variable. Quote Link to comment Share on other sites More sharing options...
Jorns2 Posted October 5, 2019 Author Share Posted October 5, 2019 now the same problem with window Quote Link to comment Share on other sites More sharing options...
gamecreator Posted October 5, 2019 Share Posted October 5, 2019 Try removing everything from your project except for main.cpp if you only want to use C/C++. Quote Link to comment Share on other sites More sharing options...
Jorns2 Posted October 5, 2019 Author Share Posted October 5, 2019 have removed all, only main.cpp remain Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted October 5, 2019 Share Posted October 5, 2019 As I said, you should take a look at the objects on your map and the scripts they have attached! Quote Link to comment Share on other sites More sharing options...
Jorns2 Posted October 5, 2019 Author Share Posted October 5, 2019 perfect ! big thanks ! Quote Link to comment Share on other sites More sharing options...
Jorns2 Posted October 5, 2019 Author Share Posted October 5, 2019 And now, when i have removed all script from scene and i want to control character in map how i assign a script to playable character from c++. Or how make it with LUA ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.