C++ functions

You can find a list of the existing C++ functions that we can call from Lua/Javascript here: PDF.

Most don't include the possible parameters, but try calling them and the possible signatures should appear in an error message.

Calling C++ functions from Javascript

We can call client functions from Javascript, using radiant:call with the route name and the args we want to pass in:

  radiant.call('radiant:route_name', arg1, arg2, {arg3: {'x':1}{'y':2}{'z':3}} );

For instance:

  radiant.call('radiant:play_sound', {'track' : 'stonehearth:sounds:ui:action_click' });

Calling C++ functions from Lua

If a function has been made available to Javascript, it can be called from Lua also. Use this syntax:

  _radiant.call('radiant:game:get_game_speed')
     :done(function(r)
         -- Do something
      end)

We can access the C++ components too and use the functions listed in the PDF:

  local mob = entity:get_component('mob')
  local facing = mob and mob:get_facing()

Calling the functions from the Open Lua functions list from the PDF would be like this:

  _radiant.sim.topology.are_connected(entity, pt)