Jump to content

Recommended Posts

Posted

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.

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

Posted

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:

 

image.thumb.png.2a9e167c54a66c83d27f5c32e0dee777.png

Posted

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.

Posted

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 ?

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.

×
×
  • Create New...