I'm having some issues with my lua. I finally got it working, and I got it to make me some buttons on the screen, but I'm having issues getting the buttons to call a lua function when pressed.
At the moment when the button is pressed I get an access violation error...
...which triggers a breakpoint on this line in luafunction.h:
Here's the lua I wrote for this:
Display All
The scene table just initializes the various scene elements. All I have implemented right now is a button and some text.
The code seems to be able to load this fine. I get the buttons and text on the screen, so that doesn't seem to be an issue. However, the function won't work.
obj is the particular element of the table I'm looking at currently, in this case the button.
And here's where I make the actual function. It's passed into a class that holds onto it and the button's ID so that when the button is pressed the correct function is called, which seems to work just awesome.
And here's where I actually call the function. it is the iterator for the map that holds all of the buttons in the current scene.
Any help would be greatly appreciated.
At the moment when the button is pressed I get an access violation error...
First-chance exception at 0x10022d86 in FPS Game.exe: 0xC0000005: Access violation reading location 0x0000000c.
Unhandled exception at 0x10022d86 in FPS Game.exe: 0xC0000005: Access violation reading location 0x0000000c.
...which triggers a breakpoint on this line in luafunction.h:
Here's the lua I wrote for this:
Source Code
- function testfunction()
- EventManager:QueueEvent("DetachSceneEvent")
- end
- Scene =
- {
- { font = "Default", type = 0, text = "Button", tooltip = "I am a button!", x = 10, y = 10, width = 90, height = 40, callback = testfunction, centered = false },
- { type = 1, text = "I am some text!", x = 300, y = 10, centered = true, font = "Default" }
- }
- EventManager:QueueEvent("AttachSceneEvent", Scene)
The scene table just initializes the various scene elements. All I have implemented right now is a button and some text.
The code seems to be able to load this fine. I get the buttons and text on the screen, so that doesn't seem to be an issue. However, the function won't work.
obj is the particular element of the table I'm looking at currently, in this case the button.
And here's where I make the actual function. It's passed into a class that holds onto it and the button's ID so that when the button is pressed the correct function is called, which seems to work just awesome.
And here's where I actually call the function. it is the iterator for the map that holds all of the buttons in the current scene.
Any help would be greatly appreciated.