Troubleshooting

This page will roughly gather the bad things happening when compiling, scripting or running Valyria Tear for memory purpose.

Beware, it doesn't intend to be very well-written but simply letting there the useful hints that can make the difference when dealing with this engine:

- The "tuple" error:
When scripting, the game can crash after a modification, even when exception are handled while calling the script. This is coming from luabind and I guess I won't look into that before a long time.
When running the game with a debugger, this error will then be viewable most of the time:
typename boost::mpl::if_<boost::is_void<T>, 
luabind::detail::proxy_member_void_caller<boost::tuples::tuple 
<boost::tuples::null_type, 
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, 
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>
...

Also, on Windows, a popup can be shown telling that the game has ceased functioning depending on the case.

Note that both have the same causes: A scripting error done when:
- You're calling a method and are omitting parameters.
Even if certain parameters have default values in C++, the equivalent in scripting must be called with every parameters.
- You're calling an unexisting method (usually a syntax error.)
- You're calling a method on an object which is invalid.

- Use TerminateAllEvents(sprite) to break an event loop!
Especially when an NPC has got timed events, you have to stop everything linked to it, before starting a new event loop. that might sound obvious but this example does random things:
local npc = _CreateSprite(...)
event = hoa_map.PathMoveEvent(id, npc, x, y, false)
event:AddEventLinkAtEnd(id2, 4000)
EventManager.RegisterEvent(event)
event = hoa_map.PathMoveEvent(id2, npc, x2, y2, false)
event:AddEventLinkAtEnd(id, 4000)
EventManager.RegisterEvent(event)

event = hoa_map.PathMoveEvent(id3, npc, x3, y3, false)
event:AddEventLinkAtEnd(id3, 4000)
EventManager.RegisterEvent(event)

EventManager:StartEvent(id)
...
EventManager:StartEvent(id3)



- No StartEvent() in the map_functions array!
When scripting, you might have this:

...
event = hoa_map.scriptedEvent(id, my_function, my_update_function)
EventManager.RegisterEvent(event)
...
map_functions = {
  my_function() = function()
  ...
  end,
...
}
Don't put a call to StartEvent() functions family in my_function(), especially when you want to break an event loop.
Why? Because the engine won't call the StartEvent() in every cases. (A bug that should be analyzed someday).

Instead, add the TerminateAllEvents(sprite) in my_function()
and add the first event of the next event loop as a link at the end of the scripted event:
local my_sprite = {}
...
event = hoa_map.scriptedEvent(id, my_function, my_update_function)
event:AddEventLinkAtEnd(other_event)
EventManager.RegisterEvent(event)
...
map_functions = {
  my_function() = function()
  TerminateAllEvents(my_sprite);
  end,
...
}