Sign in to follow this  

Issues with calling Lua functions from C++.

This topic is 2594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Nevermind, the code itself seems to work fine. I ended up naming two functions the same thing, I had a legitimate error where one of the functions WAS missing from the script files, only I'd forgotten I'd named it the same thing as the functions I was dealing with here. Ergo, I was getting perfectly reasonable error messages about some OTHER function, but thought it was about THIS function because they had the same name.

Lesson: Don't program anything for at least a week after daylight savings time ends.

----

Basically, every object in my engine is scripted using Lua. This seems to be working fine. I'm now trying to add level-wide Lua scripts that get called at the beginning of every turn and whenever the player enters the level for the first time. This is not working so well.

The level script function calling code is in the nopaste link above. What it should be doing is loading a filename (based off the name assigned to the level. It's assumed that a level's name, directory, and script all have the same basic name), either in the form of an uncompiled or compiled lua file, generates a call string, sends the function call string to lua, and returns.

In terms of outward behaviors, everything works. The functions I try to call get called, they do what they're told, and everything LOOKS fine.

However, I get an stderr.txt file as output with a bunch of stuff like:

actors/wall.lua: [string "LevelEntered"]:1: attempt to call global `LevelEntered' (a nil value)
actors/wall.lua: [string "LevelEntered"]:1: attempt to call global `LevelEntered' (a nil value)
actors/creatures/dvorak.lua: [string "LevelEntered"]:1: attempt to call global `LevelEntered' (a nil value)
actors/player.lua: [string "LevelEntered"]:1: attempt to call global `LevelEntered' (a nil value)

Which are error message generated by the actual game object scripts when something tries to call a non-existent function in them. In this particular case, LevelEntered is a function I previously called in one of the level scripts.

It sort of looks like LevelEntered is getting stuck on the call stack somehow although I'm not entirely sure this is the case and I'm not entirely sure why this is happening.

Also it seems like the issue resolves itself after the first turn following the level script being run since each game object only generates one of the error messages above once, instead of once per turn.

[Edited by - MeshGearFox on November 9, 2010 11:29:53 PM]

Share this post


Link to post
Share on other sites

This topic is 2594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this