Exemplo n.º 1
0
static int
lua_filep(lua_State *L)
{
  lua_pushboolean(L, filep(L, 1));
  return 1;
}
Exemplo n.º 2
0
		/// lua:	bool	IsUnderPos	(x,y)
		static int			IsUnderPos	(lua_State *L) { PROFILE
			lua_pushboolean(L,checkudata_alive(L)->IsUnderPos(luaL_checkint(L,2),luaL_checkint(L,3)));
			return 1;
		}
Exemplo n.º 3
0
/**
 * @upvalue z_stream - Memory for the z_stream.
 * @upvalue remainder - Any remainder from the last deflate call.
 *
 * @param string - "print" to deflate stream.
 * @param int - flush output buffer? Z_SYNC_FLUSH, Z_FULL_FLUSH, or Z_FINISH.
 *
 * if no params, terminates the stream (as if we got empty string and Z_FINISH).
 */
static int lz_filter_impl(lua_State *L, int (*filter)(z_streamp, int), int (*end)(z_streamp), char* name) {
    int flush = Z_NO_FLUSH, result;
    z_stream* stream;
    luaL_Buffer buff;
    size_t avail_in;

    if ( filter == deflate ) {
        const char *const opts[] = { "none", "sync", "full", "finish", NULL };
        flush = luaL_checkoption(L, 2, opts[0], opts);
        if ( flush ) flush++; 
        /* Z_NO_FLUSH(0) Z_SYNC_FLUSH(2), Z_FULL_FLUSH(3), Z_FINISH (4) */

        /* No arguments or nil, we are terminating the stream: */
        if ( lua_gettop(L) == 0 || lua_isnil(L, 1) ) {
            flush = Z_FINISH;
        }
    }

    stream = (z_stream*)lua_touserdata(L, lua_upvalueindex(1));
    if ( stream == NULL ) {
        if ( lua_gettop(L) >= 1 && lua_isstring(L, 1) ) {
            lua_pushfstring(L, "IllegalState: calling %s function when stream was previously closed", name);
            lua_error(L);
        }
        lua_pushstring(L, "");
        lua_pushboolean(L, 1);
        return 2; /* Ignore duplicate calls to "close". */
    }

    luaL_buffinit(L, &buff);

    if ( lua_gettop(L) > 1 ) lua_pushvalue(L, 1);

    if ( lua_isstring(L, lua_upvalueindex(2)) ) {
        lua_pushvalue(L, lua_upvalueindex(2));
        if ( lua_gettop(L) > 1 && lua_isstring(L, -2) ) {
            lua_concat(L, 2);
        }
    }

    /*  Do the actual deflate'ing: */
    if (lua_gettop(L) > 0) {
        stream->next_in = (unsigned char*)lua_tolstring(L, -1, &avail_in);
    } else {
        stream->next_in = NULL;
        avail_in = 0;
    }
    stream->avail_in = avail_in;

    if ( ! stream->avail_in && ! flush ) {
        /*  Passed empty string, make it a noop instead of erroring out. */
        lua_pushstring(L, "");
        lua_pushboolean(L, 0);
        lua_pushinteger(L, stream->total_in);
        lua_pushinteger(L, stream->total_out);
        return 4;
    }

    do {
        stream->next_out  = (unsigned char*)luaL_prepbuffer(&buff);
        stream->avail_out = LUAL_BUFFERSIZE;
        result = filter(stream, flush);
        if ( Z_BUF_ERROR != result ) {
            /* Ignore Z_BUF_ERROR since that just indicates that we
             * need a larger buffer in order to proceed.  Thanks to
             * Tobias Markmann for finding this bug!
             */
            lz_assert(L, result, stream, __FILE__, __LINE__);
        }
        luaL_addsize(&buff, LUAL_BUFFERSIZE - stream->avail_out);
    } while ( stream->avail_out == 0 );

    /*  Need to do this before we alter the stack: */
    luaL_pushresult(&buff);

    /*  Save remainder in lua_upvalueindex(2): */
    if ( NULL != stream->next_in ) {
        lua_pushlstring(L, (char*)stream->next_in, stream->avail_in);
        lua_replace(L, lua_upvalueindex(2));
    }

    /*  "close" the stream/remove finalizer: */
    if ( result == Z_STREAM_END ) {
        /*  Clear-out the metatable so end is not called twice: */
        lua_pushnil(L);
        lua_setmetatable(L, lua_upvalueindex(1));

        /*  nil the upvalue: */
        lua_pushnil(L);
        lua_replace(L, lua_upvalueindex(1));

        /*  Close the stream: */
        lz_assert(L, end(stream), stream, __FILE__, __LINE__);

        lua_pushboolean(L, 1);
    } else {
        lua_pushboolean(L, 0);
    }
    lua_pushinteger(L, stream->total_in);
    lua_pushinteger(L, stream->total_out);
    return 4;
}
Exemplo n.º 4
0
static void settabsb (lua_State *L, const char *k, int v) {
  lua_pushboolean(L, v);
  lua_setfield(L, -2, k);
}
Exemplo n.º 5
0
static int mh_length (lua_State* l) {
menu* m = lua_touserdata(l,1);
if (m->sub) lua_pushinteger(l, GetMenuItemCount(m->menu));
else lua_pushboolean(l,FALSE);
return 1;
}
Exemplo n.º 6
0
// mysdb :close()
static int api_close( lua_State *L) {
    sdb_close( lua_sdb_checktable( L, 1));
    lua_pushboolean( L, 1);
    return 1;
}
Exemplo n.º 7
0
	static int GetScrolling( T* p, lua_State *L ){ lua_pushboolean( L, p->GetScrolling() ); return 1; }
Exemplo n.º 8
0
static int lgetopt_long_t(lua_State *l, func_t func)
{
  const char *optstring = NULL;
  int result = 1; /* assume success */
  int argc, ch, idx;
  char **argv = NULL;
  int error_func = 0;

  int numargs = lua_gettop(l);
  if ((numargs != 2 && numargs != 3 && numargs != 4) ||
      lua_type(l,1) != LUA_TSTRING ||
      lua_type(l,2) != LUA_TTABLE ||
      (numargs >= 3 && 
       (lua_type(l,3) != LUA_TTABLE && 
	lua_type(l,3) != LUA_TNIL))) {
    ERROR("usage: getopt.long(optionstring, longopts[, resulttable[, errorfunc]])");
  }
  if (numargs == 4 &&
      lua_type(l,4) != LUA_TFUNCTION && 
      lua_type(l,4) != LUA_TNIL) {
    ERROR("usage: getopt.long(optionstring, longopts[, resulttable[, errorfunc]])");
  }
  if (numargs == 4 && lua_type(l,4) == LUA_TFUNCTION) {
    // We can't copy the error function - but we can make a
    // registry pointer.
    error_func = luaL_ref(l, LUA_REGISTRYINDEX);
  }

  optstring = lua_tostring(l, 1);

  /* Construct fake argc/argv from the magic lua 'arg' table. */
  lua_getglobal(l, "arg");
  construct_args(l, lua_gettop(l), &argc, &argv);
  lua_pop(l, 1);

  /* Construct a longopts struct from the one given. */
  char **bound_variable_name = NULL;
  int *bound_variable_value = NULL;
  struct option *longopts = build_longopts(l, 2, 
					   &bound_variable_name,
					   &bound_variable_value);

  /* Parse the options and store them in the Lua table. */
  idx = -1; /* initialize idx to -1 so we can tell whether or not it's
	     * updated by getopt_long (or whatever func() is) */

  while ((ch=func(argc, argv, optstring, longopts, &idx)) > -1) {
    char buf[2] = { ch, 0 };

    if (ch == '?' || ch == ':') {
      /* This is a special "got a bad option" character. Don't put it 
       * in the table of results; just record that there's a failure.
       * The getopt call will have emitted an error to stderr. */

      if (error_func) {
	lua_rawgeti(l, LUA_REGISTRYINDEX, error_func);
	lua_pushstring(l, buf);
	lua_call(l, 1, 0); // 1 argument, 0 results. Not protecting against errors.
      }

      result = 0;
      break;
    }

    if (idx == -1) {
      /* If idx == -1, then it wasn't updated by the library call;
       * that happens if it matches a short option. We'll have to dig
       * through and find it ourself.
       */

      struct option *l = longopts;
      int i = 0;
      while (l[i].name) {
	if (l[i].val != 0 && l[i].val == ch) {
	  idx = i;
	  if (l[i].flag != NULL) {
	    /* Fake the longopt "this is a bound variable thing" even
	     * though it was called with a short variable? :/
	     */
	    ch = 0;
	    *l[i].flag = l[i].val;
	  }
	  break;
	}
	i++;
      }
    } else {
      /* If we matched a long option with a val set, but the 'ch' is zero,
       * then we need to dig the character out of the option's "val" field
       * so we can set the captured value appropriately in the return opts. 
       */

      if (longopts[idx].val) {
	buf[0] = longopts[idx].val;
	if (longopts[idx].val <= 9) {
	  /* Coerce to a character, rather than an integer */
	  buf[0] += '0';
	}
      }
    }

    /* Call any available callbacks for this element, if we found the
     * element in the longopts struct list. */
    if (idx != -1) {
      _call_callback(l, 2, &longopts[idx]);
    }

    /* Save the values in the user-specified return table. */
    if (buf[0] && numargs >= 3 && lua_type(l,3) == LUA_TTABLE) {
      if (optarg) {
	lua_pushstring(l, optarg);
      } else {
	lua_pushboolean(l, 1);
      }
      lua_setfield(l, 3, buf);
    }

    if (ch == 0) {
      /* This is the special "bound a variable" return value. Perform
       * the bind. */
      set_lua_variable(l, bound_variable_name[idx], bound_variable_value[idx]);
    }

    idx = -1;
  }

  /* Since the default behavior of many (but not all) getopt libraries is to 
   * reorder argv so that non-arguments are all at the end (unless 
   * POSIXLY_CORRECT is set or the options string begins with a '+'), we'll
   * go do that now. We do it by modifying the existing global table, which 
   * will leave index [-1] in place if it's set (as it sometimes is). */

  lua_getglobal(l, "arg");
  int i;
  for (i=0; i<argc; i++) {
    lua_pushinteger(l, i);
    lua_pushstring(l, argv[i]);
    lua_rawset(l, -3);
  }

  free_longopts(longopts, bound_variable_name, bound_variable_value);
  free_args(argc, argv);

  if (error_func) {
    luaL_unref(l, LUA_REGISTRYINDEX, error_func);
  }

  /* Return 1 item on the stack (boolean) */
  lua_pushboolean(l, result);

  return 1; /* # of arguments returned on stack */
}
Exemplo n.º 9
0
static int lgetopt_std(lua_State *l)
{
  const char *optstring = NULL;
  int result = 1; /* assume success */
  int argc, ch;
  char **argv = NULL;

  int numargs = lua_gettop(l);
  if (numargs != 2 ||
      lua_type(l,1) != LUA_TSTRING ||
      lua_type(l,2) != LUA_TTABLE) {
    ERROR("usage: getopt.std(optionstring, resulttable)");
  }

  optstring = lua_tostring(l, 1);

  /* Construct fake argc/argv from the magic lua 'arg' table. */
  lua_getglobal(l, "arg");
  construct_args(l, lua_gettop(l), &argc, &argv);
  lua_pop(l, 1);

  /* Parse the options and store them in the Lua table. */
  while ((ch=getopt(argc, argv, optstring)) > -1) {
    char buf[2] = { ch, 0 };

    if (ch == '?') {
      /* This is the special "got a bad option" character. Don't put it 
       * in the table of results; just record that there's a failure.
       * The getopt call will have emitted an error to stderr. */

      result = 0;
      continue;
    }
    
    if (optarg) {
      lua_pushstring(l, optarg);
    } else {
      lua_pushboolean(l, 1);
    }
    lua_setfield(l, 2, buf);
  }

  /* Since the default behavior of many (but not all) getopt libraries is to 
   * reorder argv so that non-arguments are all at the end (unless 
   * POSIXLY_CORRECT is set or the options string begins with a '+'), we'll
   * go do that now. We do it by modifying the existing global table, which 
   * will leave index [-1] alone if it's set (as it sometimes is). */

  lua_getglobal(l, "arg");
  int i;
  for (i=0; i<argc; i++) {
    lua_pushinteger(l, i);
    lua_pushstring(l, argv[i]);
    lua_rawset(l, -3);
  }

  free_args(argc, argv);

  /* Return 1 item on the stack (boolean) */
  lua_pushboolean(l, result);

  return 1; /* # of arguments returned on stack */
}
Exemplo n.º 10
0
// If we're not using lua, need to define Use_function in a way to always call the C++ function
int use_function::call(player *player_instance, item *item_instance, bool active, point pos) const
{
    if (function_type == USE_FUNCTION_NONE) {
        if (player_instance != NULL && player_instance->is_player()) {
            add_msg(_("You can't do anything interesting with your %s."), item_instance->tname().c_str());
        }
    } else if (function_type == USE_FUNCTION_CPP) {
        // If it's a C++ function, simply call it with the given arguments.
        iuse tmp;
        return (tmp.*cpp_function)(player_instance, item_instance, active, pos);
    } else if (function_type == USE_FUNCTION_ACTOR_PTR) {
        return actor_ptr->use(player_instance, item_instance, active, pos);
    } else {
#ifdef LUA

        // We'll be using lua_state a lot!
        lua_State *L = lua_state;

        // If it's a lua function, the arguments have to be wrapped in
        // lua userdata's and passed on the lua stack.
        // We will now call the function f(player, item, active)

        update_globals(L);

        // Push the lua function on top of the stack
        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_function);

        // TODO: also pass the player object, because of NPCs and all
        //       I guess

        // Push the item on top of the stack.
        int item_in_registry;
        {
            item **item_userdata = (item **) lua_newuserdata(L, sizeof(item *));
            *item_userdata = item_instance;

            // Save a reference to the item in the registry so that we can deallocate it
            // when we're done.
            item_in_registry = luah_store_in_registry(L, -1);

            // Set the metatable for the item.
            luah_setmetatable(L, "item_metatable");
        }

        // Push the "active" parameter on top of the stack.
        lua_pushboolean(L, active);

        // Call the iuse function
        int err = lua_pcall(L, 2, 1, 0);
        lua_report_error( L, err, "iuse function" );

        // Make sure the now outdated parameters we passed to lua aren't
        // being used anymore by setting a metatable that will error on
        // access.
        luah_remove_from_registry(L, item_in_registry);
        luah_setmetatable(L, "outdated_metatable");

        return lua_tointeger(L, -1);

#else

        // If LUA isn't defined and for some reason we registered a lua function,
        // simply do nothing.
        return 0;

#endif

    }
    return 0;
}
Exemplo n.º 11
0
/*
	Call().

*/
int32 Call( lua_State *_pState, const char *_pFunc, const char *_pSig, ... )
{
	ASSERT( _pState != NULL );

	uint32	stackSizeIn = static_cast<uint32>(lua_gettop( _pState ));
	if( stackSizeIn != 0 )
	{
		g_Log->Error( "Lua stack not empty..." );
		return 0;
	}

	int delta = 0;

	va_list	pArg;

	//try
	{
		//	Number of arguments and results.
		int	narg, nres;

		//	Get function.
		lua_getglobal( _pState, _pFunc );

		//	Push arguments.
		narg = 0;

		char	*pBinarySource = NULL;
		int32	binaryLen = 0;

		//	Gimme args.
		va_start( pArg, _pSig );

		while( *_pSig )
		{
			//	Push arguments.
			switch( *_pSig++ )
			{
				case 'd':  //	Double argument.
						lua_pushnumber( _pState, va_arg( pArg, fp8 ) );
						break;

				case 'i':  //	Int argument.
						lua_pushinteger( _pState, va_arg( pArg, int32 ) );
						break;

				case 'b':  //	Bool argument.
						lua_pushboolean( _pState, va_arg( pArg, int32 ) != 0 );
						break;

				case 'x':	//	Binary string argument. Next argument MUST be an integer. (which will be skipped)
						pBinarySource = va_arg( pArg, char * );
						binaryLen = va_arg( pArg, int32 );
						lua_pushlstring( _pState, pBinarySource, static_cast<size_t>(binaryLen) );
						_pSig++;
						break;

				case 's':	//	String argument.
						lua_pushstring( _pState, va_arg( pArg, char * ) );
						break;

				case '>':
						goto endwhileLabel;

				default:
				{
					g_Log->Error( "Invalid option (%c)", *(_pSig - 1) );
					return 0;
				}
			}

			//printf( "stack: %d", lua_gettop( _pState ) );

			narg++;
			luaL_checkstack( _pState, 1, "Too many arguments" );

		}	endwhileLabel:

		//	Do the call.
		nres = (int)strlen( _pSig );  //	Number of expected results.

		//LuaCall( _pState, narg, nres );
		//int	status = lua_pcall( _pState, narg, nres, 0 );
		int status = docall( _pState, narg, 0 );

		reportLua( _pState, status );

		//	Retrieve results.
		nres = -nres;	//	Stack index of first result.

		while( *_pSig )	//	Get results.
		{
			switch( *_pSig++ )
			{
				case 'd':	//	Double result.
						if( !lua_isnumber( _pState, nres ) )
							g_Log->Error( "Wrong result type, expected double" );
						else
							*va_arg( pArg, fp8 *) = lua_tonumber( _pState, nres );

						break;


				case 'b':	//	Bool result.
						if( !lua_isboolean( _pState, nres ) )
							g_Log->Error( "Wrong result type, expected bool" );
						else
							*va_arg( pArg, bool *) = lua_toboolean( _pState, nres ) != 0;

						break;

				case 'i':	//	Int result.
						if( !lua_isnumber( _pState, nres ) )
							g_Log->Error( "Wrong result type, expected integer" );
						else
							*va_arg( pArg, int32 *) = (int32)lua_tonumber( _pState, nres );

						break;

				case 's':	//	String result.
						if( !lua_isstring( _pState, nres ) )
							g_Log->Error( "Wrong result type, expected string" );
						else
							*va_arg( pArg, const char **) = lua_tostring( _pState, nres );

						break;

				default:
				{
					g_Log->Error( "Invalid option (%c)", *(_pSig - 1) );
					break;
				}
			}

			nres++;
		}

		/*
			HACK!
			Pop delta from stack, keeping this function from raceing away!.
		*/
		delta = lua_gettop( _pState ) - static_cast<int>(stackSizeIn);
	}
	/*catch( Base::CException &_e )
	{
		va_end( pArg );

		//	Make sure to clean up stack in case of errors.
		delta = lua_gettop( _pState ) - stackSizeIn;
		if( delta != 0 )
			lua_pop( _pState, delta );

		g_Log->Warning( "%s", _e.Text().c_str() );
		//_e.ReportCatch();
		return 0;
	}*/

	va_end( pArg );

	return( delta );
}
Exemplo n.º 12
0
/*
 * Returns: processors_load_average (number), is_per_cpu (boolean)
 */
static int
sys_loadavg (lua_State *L)
{
  double loadavg;
#ifndef _WIN32
  const int res = 0;

  if (getloadavg(&loadavg, 1) == 1) {
    const int is_per_cpu = 1;
#else
  const int res = getloadavg(&loadavg);

  if (!res) {
    const int is_per_cpu = 0;
#endif
    lua_pushnumber(L, (lua_Number) loadavg);
    lua_pushboolean(L, is_per_cpu);
    return 2;
  }
  return sys_seterror(L, res);
}

/*
 * Arguments: [number_of_files (number)]
 * Returns: number_of_files (number)
 */
static int
sys_limit_nfiles (lua_State *L)
{
#ifndef _WIN32
  const int narg = lua_gettop(L);
  struct rlimit rlim;

  rlim.rlim_max = 0;
  getrlimit(RLIMIT_NOFILE, &rlim);
  lua_pushinteger(L, rlim.rlim_max);

  if (narg != 0) {
    const int n = lua_tointeger(L, 1);

    rlim.rlim_cur = rlim.rlim_max = n;
    if (setrlimit(RLIMIT_NOFILE, &rlim))
      return sys_seterror(L, 0);
  }
  return 1;
#else
  (void) L;

  lua_pushinteger(L, -1);
  return 1;
#endif
}

/*
 * Arguments: string
 * Returns: number
 */
static int
sys_toint (lua_State *L)
{
  const char *s = lua_tostring(L, 1);
  int num = 0, sign = 1;

  if (s) {
    switch (*s) {
    case '-': sign = -1;
    case '+': ++s;
    }
    while (*s >= '0' && *s <= '9')
      num = (num << 3) + (num << 1) + (*s++ & ~'0');
  }
  lua_pushinteger(L, sign * num);
  return 1;
}

/*
 * Arguments: error_handler (function), function, any ...
 * Returns: status (boolean), any ...
 */
static int
sys_xpcall (lua_State *L)
{
  const int status = lua_pcall(L, lua_gettop(L) - 2, LUA_MULTRET, 1);

  lua_pushboolean(L, !status);
  lua_insert(L, 2);
  return lua_gettop(L) - 1;
}


#include "isa/fcgi/sys_fcgi.c"
#include "mem/sys_mem.c"
#include "thread/sys_thread.c"

#ifndef _WIN32
#include "sys_unix.c"
#else
#include "win32/sys_win32.c"
#endif

#include "sys_file.c"
#include "sys_date.c"
#include "sys_env.c"
#include "sys_evq.c"
#include "sys_fs.c"
#include "sys_log.c"
#include "sys_proc.c"
#include "sys_rand.c"


static luaL_Reg sys_lib[] = {
  {"strerror",		sys_strerror},
  {"nprocs",		sys_nprocs},
  {"loadavg",		sys_loadavg},
  {"limit_nfiles",	sys_limit_nfiles},
  {"toint",		sys_toint},
  {"xpcall",		sys_xpcall},
  DATE_METHODS,
  ENV_METHODS,
  EVQ_METHODS,
  FCGI_METHODS,
  FD_METHODS,
  FS_METHODS,
  LOG_METHODS,
  PROC_METHODS,
  RAND_METHODS,
#ifndef _WIN32
  UNIX_METHODS,
#endif
  {NULL, NULL}
};


/*
 * Arguments: ..., sys_lib (table)
 */
static void
createmeta (lua_State *L)
{
  const int top = lua_gettop(L);
  const struct meta_s {
    const char *tname;
    luaL_Reg *meth;
    int is_index;
  } meta[] = {
    {DIR_TYPENAME,		dir_meth,	0},
    {EVQ_TYPENAME,		evq_meth,	1},
    {FD_TYPENAME,		fd_meth,	1},
    {PERIOD_TYPENAME,		period_meth,	1},
    {PID_TYPENAME,		pid_meth,	1},
    {LOG_TYPENAME,		log_meth,	0},
    {RAND_TYPENAME,		rand_meth,	0},
  };
  int i;

  for (i = 0; i < (int) (sizeof(meta) / sizeof(struct meta_s)); ++i) {
    luaL_newmetatable(L, meta[i].tname);
    if (meta[i].is_index) {
      lua_pushvalue(L, -1);  /* push metatable */
      lua_setfield(L, -2, "__index");  /* metatable.__index = metatable */
    }
    luaL_setfuncs(L, meta[i].meth, 0);
    lua_pop(L, 1);
  }

  /* Predefined file handles */
  luaL_getmetatable(L, FD_TYPENAME);
  {
    const char *std[] = {"stdin", "stdout", "stderr"};

    for (i = 3; i--; ) {
#ifndef _WIN32
      const fd_t fd = i;
#else
      const fd_t fd = GetStdHandle(i == 0 ? STD_INPUT_HANDLE
       : (i == 1 ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE));
#endif
      lua_pushstring(L, std[i]);
      lua_boxinteger(L, fd);
      lua_pushvalue(L, -3);  /* metatable */
      lua_pushboolean(L, 1);
      lua_rawseti(L, -2, (int) ((lua_Integer) fd));  /* don't close std. handles */
      lua_setmetatable(L, -2);
      lua_rawset(L, top);
    }
  }
  lua_settop(L, top);
}


LUALIB_API int
luaopen_sys (lua_State *L)
{
  luaL_register(L, LUA_SYSLIBNAME, sys_lib);
  createmeta(L);

  signal_init();

#ifdef _WIN32
  luaopen_sys_win32(L);
#endif
  luaopen_sys_mem(L);
  luaopen_sys_thread(L);

  return 1;
}
Exemplo n.º 13
0
int32_t MoveEventScript::luaCallFunction(lua_State* L)
{
	//callFunction(...)
	MoveEvent* event = MoveEventScript::event;
	if(!event)
	{
		error(__FUNCTION__, "MoveEvent not set!");
		lua_pushboolean(L, false);
		return 1;
	}

	if(event->getEventType() == MOVE_EVENT_EQUIP || event->getEventType() == MOVE_EVENT_DE_EQUIP)
	{
		ScriptEnviroment* env = getEnv();
		bool boolean = popBoolean(L);
		slots_t slot = (slots_t)popNumber(L);

		Item* item = env->getItemByUID(popNumber(L));
		if(!item)
		{
			error(__FUNCTION__, getError(LUA_ERROR_ITEM_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
		}

		Player* player = env->getPlayerByUID(popNumber(L));
		if(!player)
		{
			error(__FUNCTION__, getError(LUA_ERROR_PLAYER_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
		}

		if(event->getEventType() != MOVE_EVENT_EQUIP)
			lua_pushboolean(L, MoveEvent::DeEquipItem(event, player, item, slot, boolean));
		else
			lua_pushboolean(L, MoveEvent::EquipItem(event, player, item, slot, boolean));

		return 1;
	}
	else if(event->getEventType() == MOVE_EVENT_STEP_IN)
	{
		ScriptEnviroment* env = getEnv();
		Item* item = env->getItemByUID(popNumber(L));
		if(!item)
		{
			error(__FUNCTION__, getError(LUA_ERROR_ITEM_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
		}

		Creature* creature = env->getCreatureByUID(popNumber(L));
		if(!creature)
		{
			error(__FUNCTION__, getError(LUA_ERROR_CREATURE_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
		}

		lua_pushboolean(L, MoveEvent::StepInField(creature, item));
		return 1;
	}
	else if(event->getEventType() == MOVE_EVENT_ADD_ITEM)
	{
		ScriptEnviroment* env = getEnv();
		Item* item = env->getItemByUID(popNumber(L));
		if(!item)
		{
			error(__FUNCTION__, getError(LUA_ERROR_ITEM_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
		}

		lua_pushboolean(L, MoveEvent::AddItemField(item));
		return 1;
	}

	error(__FUNCTION__, "callFunction not available for current event.");
	lua_pushboolean(L, false);
	return 1;
}
Exemplo n.º 14
0
static int
lua_dirp(lua_State *L)
{
  lua_pushboolean(L, dirp(L, 1));
  return 1;
}
Exemplo n.º 15
0
inline int32 CLuaSpell::tookEffect(lua_State* L)
{
    DSP_DEBUG_BREAK_IF(m_PLuaSpell == nullptr);
    lua_pushboolean(L, m_PLuaSpell->tookEffect());
    return 1;
}
Exemplo n.º 16
0
void	LuaWrapper::pushBoolean(bool bValue)					{	lua_pushboolean(m_luaState, bValue);		}
Exemplo n.º 17
0
static int luaB_rawequal (lua_State *L) {
  luaL_checkany(L, 1);
  luaL_checkany(L, 2);
  lua_pushboolean(L, lua_rawequal(L, 1, 2));
  return 1;
}
Exemplo n.º 18
0
static int lua_likwid_getPowerInfo(lua_State* L)
{
    
    int i;
    if (topology_isInitialized == 0)
    {
        topology_init();
        topology_isInitialized = 1;
        cpuinfo = get_cpuInfo();
        cputopo = get_cpuTopology();
    }
    if ((topology_isInitialized) && (cpuinfo == NULL))
    {
        cpuinfo = get_cpuInfo();
    }
    if ((topology_isInitialized) && (cputopo == NULL))
    {
        cputopo = get_cpuTopology();
    }
    if (power_isInitialized == 0)
    {
        power_hasRAPL = power_init(0);
        if (power_hasRAPL)
        {
            power_isInitialized = 1;
            power = get_powerInfo();
        }
        else
        {
            return 0;
        }
    }


    lua_newtable(L);
    lua_pushstring(L,"hasRAPL");
    lua_pushboolean(L,power_hasRAPL);
    lua_settable(L,-3);
    lua_pushstring(L,"baseFrequency");
    lua_pushnumber(L,power->baseFrequency);
    lua_settable(L,-3);
    lua_pushstring(L,"minFrequency");
    lua_pushnumber(L,power->minFrequency);
    lua_settable(L,-3);
    lua_pushstring(L,"powerUnit");
    lua_pushnumber(L,power->powerUnit);
    lua_settable(L,-3);
    lua_pushstring(L,"timeUnit");
    lua_pushnumber(L,power->timeUnit);
    lua_settable(L,-3);
    
    lua_pushstring(L,"turbo");
    lua_newtable(L);
    lua_pushstring(L,"numSteps");
    lua_pushunsigned(L,power->turbo.numSteps);
    lua_settable(L,-3);
    lua_pushstring(L,"steps");
    lua_newtable(L);
    for(i=0;i<power->turbo.numSteps;i++)
    {
        lua_pushunsigned(L,i+1);
        lua_pushnumber(L,power->turbo.steps[i]);
        lua_settable(L,-3);
    }
    lua_settable(L,-3);
    lua_settable(L,-3);

    lua_pushstring(L,"domains");
    lua_newtable(L);
    for(i=0;i<NUM_POWER_DOMAINS;i++)
    {
        lua_pushstring(L,power_names[i]);
        lua_newtable(L);

        lua_pushstring(L, "ID");
        lua_pushnumber(L, power->domains[i].type);
        lua_settable(L,-3);
        lua_pushstring(L, "energyUnit");
        lua_pushnumber(L, power->domains[i].energyUnit);
        lua_settable(L,-3);
        lua_pushstring(L,"supportStatus");
        if (power->domains[i].supportFlags & POWER_DOMAIN_SUPPORT_STATUS)
        {
            lua_pushboolean(L, 1);
        }
        else
        {
            lua_pushboolean(L, 0);
        }
        lua_settable(L,-3);
        lua_pushstring(L,"supportPerf");
        if (power->domains[i].supportFlags & POWER_DOMAIN_SUPPORT_PERF)
        {
            lua_pushboolean(L, 1);
        }
        else
        {
            lua_pushboolean(L, 0);
        }
        lua_settable(L,-3);
        lua_pushstring(L,"supportPolicy");
        if (power->domains[i].supportFlags & POWER_DOMAIN_SUPPORT_POLICY)
        {
            lua_pushboolean(L, 1);
        }
        else
        {
            lua_pushboolean(L, 0);
        }
        lua_settable(L,-3);
        lua_pushstring(L,"supportLimit");
        if (power->domains[i].supportFlags & POWER_DOMAIN_SUPPORT_LIMIT)
        {
            lua_pushboolean(L, 1);
        }
        else
        {
            lua_pushboolean(L, 0);
        }
        lua_settable(L,-3);
        if (power->domains[i].supportFlags & POWER_DOMAIN_SUPPORT_INFO)
        {
            lua_pushstring(L,"supportInfo");
            lua_pushboolean(L, 1);
            lua_settable(L,-3);
            lua_pushstring(L,"tdp");
            lua_pushnumber(L, power->domains[i].tdp);
            lua_settable(L,-3);
            lua_pushstring(L,"minPower");
            lua_pushnumber(L, power->domains[i].minPower);
            lua_settable(L,-3);
            lua_pushstring(L,"maxPower");
            lua_pushnumber(L, power->domains[i].maxPower);
            lua_settable(L,-3);
            lua_pushstring(L,"maxTimeWindow");
            lua_pushnumber(L, power->domains[i].maxTimeWindow);
            lua_settable(L,-3);
        }
        else
        {
            lua_pushstring(L,"supportInfo");
            lua_pushboolean(L, 0);
            lua_settable(L,-3);
        }

        lua_settable(L,-3);
    }
    lua_settable(L,-3);
    

    return 1;
}
Exemplo n.º 19
0
//----------------------------------------------------------------//
void MOAILuaState::Push ( bool value ) {

	lua_pushboolean ( this->mState, value ? 1 : 0 );
}
Exemplo n.º 20
0
static int lua_likwid_checkProgram(lua_State* L)
{
    lua_pushboolean(L, program_running);
    return 1;
}
Exemplo n.º 21
0
/* HGE_initialize.h */
static int
lua_hge_initialize_video(lua_State* L)
{
    lua_pushboolean(L, HGE_initialize_video());
    return 1;
}
Exemplo n.º 22
0
int CLuaFunctionDefs::GetCTime ( lua_State* luaVM )
{
    // table getRealTime( [int seconds = current], bool localTime = true )
    time_t timer;
    time ( &timer );
    bool bLocalTime = true;
    CScriptArgReader argStream ( luaVM );

    if ( argStream.NextCouldBeNumber () )
    {
        argStream.ReadNumber ( timer );
        if ( timer < 0 )
        {
            argStream.SetCustomError ( "seconds cannot be negative" );
        }
    }

    if ( argStream.NextIsBool () )
        argStream.ReadBool ( bLocalTime );

    tm * time;
    if ( bLocalTime )
        time = localtime ( &timer );
    else
        time = gmtime ( &timer );

    if ( time == NULL )
        argStream.SetCustomError ( "seconds is out of range" );

    if ( argStream.HasErrors () )
    {
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
        lua_pushboolean ( luaVM, false );
        return 1;
    }

    CLuaArguments ret;
    ret.PushString ( "second" );
    ret.PushNumber ( time->tm_sec );
    ret.PushString ( "minute" );
    ret.PushNumber ( time->tm_min );
    ret.PushString ( "hour" );
    ret.PushNumber ( time->tm_hour );
    ret.PushString ( "monthday" );
    ret.PushNumber ( time->tm_mday );
    ret.PushString ( "month" );
    ret.PushNumber ( time->tm_mon );
    ret.PushString ( "year" );
    ret.PushNumber ( time->tm_year );
    ret.PushString ( "weekday" );
    ret.PushNumber ( time->tm_wday );
    ret.PushString ( "yearday" );
    ret.PushNumber ( time->tm_yday );
    ret.PushString ( "isdst" );
    ret.PushNumber ( time->tm_isdst );
    ret.PushString ( "timestamp" );
    ret.PushNumber ( (double) timer );

    ret.PushAsTable ( luaVM );

    return 1;
}
Exemplo n.º 23
0
static int mh_index (lua_State* l) {
menu* m = lua_touserdata(l,1);
if (lua_isnumber(l,2)) {
if (!m->sub) return 0;
int n = lua_tointeger(l,2);
if (n==0) n=-1;
if (n<0) n += GetMenuItemCount(m->menu);
else n--;
MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_ID | MIIM_SUBMENU;
if (!GetMenuItemInfo(m->menu, n, TRUE, &mii)) return 0;
menu x;
x.sub = mii.hSubMenu!=0;
x.origin = m->origin;
x.parent = m->menu;
x.position = n;
if (mii.hSubMenu!=0) x.menu = mii.hSubMenu;
else x.command = mii.wID;
lua_settop(l,0);
lua_pushfulluserdata(l, &x, sizeof(x), "menuhandle");
return 1;
}
const char* nm = luaL_checkstring(l,2);
if (streq(nm, "checked")) {
if (m->sub) luaL_error(l, "unsupported operation");
MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STATE | MIIM_FTYPE;
if (!GetMenuItemInfo(m->parent, m->command, FALSE, &mii)) return 0;
lua_pushboolean(l, 0!=(mii.fState&MFS_CHECKED));
return 1;
}
else if (streq(nm, "radio")) {
if (m->sub) luaL_error(l, "unsupported operation");
MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_FTYPE;
if (!GetMenuItemInfo(m->parent, m->command, FALSE, &mii)) return 0;
lua_pushboolean(l, 0!=(mii.fType&MFT_RADIOCHECK));
return 1;
}
else if (streq(nm, "enabled")) {
if (m->sub) luaL_error(l, "unsupported operation");
MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STATE;
if (!GetMenuItemInfo(m->parent, m->command, FALSE, &mii)) return 0;
lua_settop(l,0);
lua_pushboolean(l, 0==(mii.fState&MFS_DISABLED));
return 1;
}
else if (streq(nm, "text")) {
const wchar_t* wc = mh_getLabel(m);
const char* mbc = strcvt(wc, CP_UTF16, CP_UTF8, NULL);
lua_pushstring(l, mbc);
free(mbc); 
free(wc);
return 1;
}
else if (streq(nm, "name")) {
const char* menuName = GetMenuName(m->parent, m->position);
lua_settop(l,0);
lua_pushstring(l,menuName);
return 1;
}
else if (streq(nm, "accelerator")) {
int f, k;
if (!(m->sub) && findAccelerator(m->command, &f, &k)) {
const wchar_t* wkn = getKeyName(f,k,0);
const char* kn = strcvt(wkn, CP_UTF16, CP_UTF8, NULL);
lua_pushstring(l,kn);
free(kn);
free(wkn);
return 1;
}
return 0;
}
else if (streq(nm, "onAction")) {
if (m->sub) return 0;
if (m->command>=IDM_CUSTOMCOMMAND) lua_pushluafunction(l, *getCustomCommand(m->command - IDM_CUSTOMCOMMAND));
else {
lua_pushinteger(l, m->command);
lua_pushcclosure(l, mh_commandclosure, 1);
}
return 1;
}
else if (streq(nm, "builtIn")) {
if (m->sub) return 0;
lua_pushboolean(l, m->command<IDM_CUSTOMCOMMAND);
return 1;
}
else if (streq(nm, "parent")) {
menu x;
x.sub = TRUE;
x.parent = GetParentMenu(m->parent, m->origin, &(x.position));
x.menu = m->parent;
x.origin = m->origin;
if (!x.parent) return 0;
lua_settop(l,0);
lua_pushfulluserdata(l, &x, sizeof(x), "menuhandle");
return 1;
}
else if (streq(nm, "parentHandle")) {
lua_pushlightuserdata(l, m->parent);
return 1;
}
else if (streq(nm, "handle") || streq(nm, "command")) {
if (m->sub) lua_pushlightuserdata(l, m->command);
else lua_pushinteger(l, m->command);
return 1;
}
//SUITE
else if (luaL_getmetafield(l, 1, nm)) return 1;
else if (m->sub) {
MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_ID | MIIM_SUBMENU | MIIM_DATA;
for (int i=0, n=GetMenuItemCount(m->menu); i<n; i++) {
if (!GetMenuItemInfo(m->menu, i, TRUE, &mii)) continue;
if (mii.dwItemData && streq(nm, mii.dwItemData)) {
menu x;
x.sub = mii.hSubMenu!=0;
x.parent = m->menu;
x.origin = m->origin;
x.position = i;
if (mii.hSubMenu!=0) x.menu = mii.hSubMenu;
else x.command = mii.wID;
lua_settop(l,0);
lua_pushfulluserdata(l, &x, sizeof(x), "menuhandle");
return 1;
}}}
return 0;
}
Exemplo n.º 24
0
/**
 * @brief serializer.new() Lua binding.
 * @param L stack
 * @param reg methods to register
 * @param parent parent serializer to inherit configuration
 * @return new serializer
 */
struct luaL_serializer *
luaL_newserializer(struct lua_State *L, const char *modname, const luaL_Reg *reg)
{
	luaL_checkstack(L, 1, "too many upvalues");

	/* Create new module */
	lua_newtable(L);

	/* Create new configuration */
	struct luaL_serializer *serializer = (struct luaL_serializer *)
			lua_newuserdata(L, sizeof(*serializer));
	luaL_getmetatable(L, LUAL_SERIALIZER);
	lua_setmetatable(L, -2);
	memset(serializer, 0, sizeof(*serializer));

	for (; reg->name != NULL; reg++) {
		/* push luaL_serializer as upvalue */
		lua_pushvalue(L, -1);
		/* register method */
		lua_pushcclosure(L, reg->func, 1);
		lua_setfield(L, -3, reg->name);
	}

	/* Add cfg{} */
	lua_newtable(L); /* cfg */
	lua_newtable(L); /* metatable */
	lua_pushvalue(L, -3); /* luaL_serializer */
	lua_pushcclosure(L, luaL_serializer_cfg, 1);
	lua_setfield(L, -2, "__call");
	lua_setmetatable(L, -2);
	/* Save configuration values to serializer.cfg */
	for (int i = 0; OPTIONS[i].name != NULL; i++) {
		int *pval = (int *) ((char *) serializer + OPTIONS[i].offset);
		*pval = OPTIONS[i].defvalue;
		switch (OPTIONS[i].type) {
		case LUA_TBOOLEAN:
			lua_pushboolean(L, *pval);
			break;
		case LUA_TNUMBER:
			lua_pushinteger(L, *pval);
			break;
		default:
			assert(false);
		}
		lua_setfield(L, -2, OPTIONS[i].name);
	}
	lua_setfield(L, -3, "cfg");

	lua_pop(L, 1);  /* remove upvalues */

	luaL_pushnull(L);
	lua_setfield(L, -2, "NULL");
	lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_array_metatable_ref);
	lua_setfield(L, -2, "array_mt");
	lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_map_metatable_ref);
	lua_setfield(L, -2, "map_mt");

	if (modname != NULL) {
		/* Register module */
		lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
		lua_pushstring(L, modname); /* add alias */
		lua_pushvalue(L, -3);
		lua_settable(L, -3);
		lua_pop(L, 1); /* _LOADED */
	}

	return serializer;
}
Exemplo n.º 25
0
static int env_closed (lua_State *L) {
  lodbc_env *env = (lodbc_env *)lutil_checkudatap (L, 1, LODBC_ENV);
  luaL_argcheck (L, env != NULL, 1, LODBC_PREFIX "environment expected");
  lua_pushboolean(L, env->flags & LODBC_FLAG_DESTROYED);
  return 1;
}
Exemplo n.º 26
0
/***
sign x509_req object

@function sign
@tparam evp_pkey pkey private key which to sign x509_req object
@tparam number|string|evp_md md message digest alg used to sign
@treturn boolean result true for suceess
*/
static LUA_FUNCTION(openssl_csr_sign)
{
  X509_REQ * csr = CHECK_OBJECT(1, X509_REQ, "openssl.x509_req");
  EVP_PKEY *pubkey = X509_REQ_get_pubkey(csr);
  if (auxiliar_getclassudata(L, "openssl.evp_pkey", 2))
  {
    EVP_PKEY *pkey = CHECK_OBJECT(2, EVP_PKEY, "openssl.evp_pkey");
    const EVP_MD* md = get_digest(L, 3, "sha256");
    int ret = 1;
    if (pubkey == NULL)
    {
      BIO* bio = BIO_new(BIO_s_mem());
      if ((ret = i2d_PUBKEY_bio(bio, pkey)) == 1)
      {
        pubkey = d2i_PUBKEY_bio(bio, NULL);
        if (pubkey)
        {
          ret = X509_REQ_set_pubkey(csr, pubkey);
          EVP_PKEY_free(pubkey);
        }
        else
        {
          ret = 0;
        }
      }
      BIO_free(bio);
    }
    else
    {
      EVP_PKEY_free(pubkey);
    }
    if (ret == 1)
      ret = X509_REQ_sign(csr, pkey, md);
    return openssl_pushresult(L, ret);
  }
  else if (lua_isstring(L, 2))
  {
    size_t siglen;
    unsigned char* sigdata = (unsigned char*)luaL_checklstring(L, 2, &siglen);
    const EVP_MD* md = get_digest(L, 3, NULL);
    ASN1_BIT_STRING *sig = NULL;
    X509_ALGOR *alg = NULL;

    luaL_argcheck(L, pubkey != NULL, 1, "has not set public key!!!");

    X509_REQ_get0_signature(csr, (const ASN1_BIT_STRING **)&sig, (const X509_ALGOR **)&alg);
    /* (pkey->ameth->pkey_flags & ASN1_PKEY_SIGPARAM_NULL) ? V_ASN1_NULL : V_ASN1_UNDEF, */
    X509_ALGOR_set0((X509_ALGOR *)alg, OBJ_nid2obj(EVP_MD_pkey_type(md)), V_ASN1_NULL, NULL);

    ASN1_BIT_STRING_set((ASN1_BIT_STRING *)sig, sigdata, siglen);
    /*
    * In the interests of compatibility, I'll make sure that the bit string
    * has a 'not-used bits' value of 0
    */
    sig->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
    sig->flags |= ASN1_STRING_FLAG_BITS_LEFT;
    lua_pushboolean(L, 1);
    return 1;
  }
  else
  {
    int inl;
    unsigned char* tosign = NULL;
    luaL_argcheck(L, pubkey != NULL, 1, "has not set public key!!!");

    inl = i2d_re_X509_REQ_tbs(csr, &tosign);
    if (inl > 0 && tosign)
    {
      lua_pushlstring(L, (const char*)tosign, inl);
      OPENSSL_free(tosign);
      return 1;
    }
    return openssl_pushresult(L, 0);
  }
}
Exemplo n.º 27
0
		// bool	GetVisible				()
		static int	GetVisible			(lua_State *L) { PROFILE
			lua_pushboolean(L,checkudata_alive(L)->GetVisible());
			return 1;
		}
Exemplo n.º 28
0
inline int32 CLuaSpell::canTargetEnemy(lua_State* L)
{
    DSP_DEBUG_BREAK_IF(m_PLuaSpell == nullptr);
    lua_pushboolean(L, m_PLuaSpell->canTargetEnemy());
    return 1;
}
Exemplo n.º 29
0
static void setboolfield (lua_State *L, const char *key, int value) {
  if (value < 0)  /* undefined? */
    return;  /* does not set field */
  lua_pushboolean(L, value);
  lua_setfield(L, -2, key);
}
Exemplo n.º 30
0
// Call a function on a remote server
int CLuaFunctionDefs::CallRemote ( lua_State* luaVM )
{
    CScriptArgReader argStream ( luaVM );
    if ( !argStream.NextIsFunction ( 1 ) && !argStream.NextIsFunction ( 2 ) )
    {
        // Call type 1
        //  bool callRemote ( string host [, string queueName ][, int connectionAttempts = 10, int connectTimeout = 10000 ], string resourceName, string functionName, callback callbackFunction, [ arguments... ] )
        SString strHost; SString strQueueName; uint uiConnectionAttempts; uint uiConnectTimeoutMs; SString strResourceName; SString strFunctionName; CLuaFunctionRef iLuaFunction; CLuaArguments args;

        argStream.ReadString ( strHost );
        if ( argStream.NextIsString () )
            MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_QUEUE_NAME, "'queue name' is being used" );
        argStream.ReadIfNextIsString ( strQueueName, CALL_REMOTE_DEFAULT_QUEUE_NAME );
        if ( argStream.NextIsNumber () )
            MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECTION_ATTEMPTS, "'connection attempts' is being used" );
        argStream.ReadIfNextIsNumber ( uiConnectionAttempts, 10 );
        if ( argStream.NextIsNumber () )
            MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECT_TIMEOUT, "'connect timeout' is being used" );
        argStream.ReadIfNextIsNumber ( uiConnectTimeoutMs, 10000 );
        argStream.ReadString ( strResourceName );
        argStream.ReadString ( strFunctionName );
        argStream.ReadFunction ( iLuaFunction );
        argStream.ReadLuaArguments ( args );
        argStream.ReadFunctionComplete ();

        if ( !argStream.HasErrors () )
        {
            CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
            if ( luaMain )
            {
                g_pGame->GetRemoteCalls ()->Call ( strHost, strResourceName, strFunctionName, &args, luaMain, iLuaFunction, strQueueName, uiConnectionAttempts, uiConnectTimeoutMs );
                lua_pushboolean ( luaVM, true );
                return 1;
            }
        }
    }
    else
    {
        // Call type 2
        //  bool callRemote ( string URL [, string queueName ][, int connectionAttempts = 10, int connectTimeout = 10000 ], callback callbackFunction, [ arguments... ] )
        SString strURL; SString strQueueName; uint uiConnectionAttempts; uint uiConnectTimeoutMs; CLuaFunctionRef iLuaFunction; CLuaArguments args;

        argStream.ReadString ( strURL );
        if ( argStream.NextIsString () )
            MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_QUEUE_NAME, "'queue name' is being used" );
        argStream.ReadIfNextIsString ( strQueueName, CALL_REMOTE_DEFAULT_QUEUE_NAME );
        if ( argStream.NextIsNumber () )
            MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECTION_ATTEMPTS, "'connection attempts' is being used" );
        argStream.ReadIfNextIsNumber ( uiConnectionAttempts, 10 );
        if ( argStream.NextIsNumber () )
            MinServerReqCheck ( argStream, MIN_SERVER_REQ_CALLREMOTE_CONNECT_TIMEOUT, "'connect timeout' is being used" );
        argStream.ReadIfNextIsNumber ( uiConnectTimeoutMs, 10000 );
        argStream.ReadFunction ( iLuaFunction );
        argStream.ReadLuaArguments ( args );
        argStream.ReadFunctionComplete ();

        if ( !argStream.HasErrors () )
        {
            CLuaMain * luaMain = m_pLuaManager->GetVirtualMachine ( luaVM );
            if ( luaMain )
            {
                g_pGame->GetRemoteCalls ()->Call ( strURL, &args, luaMain, iLuaFunction, strQueueName, uiConnectionAttempts, uiConnectTimeoutMs );
                lua_pushboolean ( luaVM, true );
                return 1;
            }
        }
    }

    if ( argStream.HasErrors () )
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}