LibRPC RFC: Difference between revisions
(Created page with "<poem style="border: 2px solid #d6d2c5; background-color: #f2f4e6; padding: 1em;"> This function was added in LibRPC (API 1.2). </poem> {{Welcome| desc='''This method is used to call server functions from npc script using streams as medium.''' Calling RFC will returns function which can be used to call remote functions of server( i.e. functions in squirrel gamemode) when called with their parameters. Note that a single call to RFC(..) will return function and a double ca...") |
No edit summary |
||
Line 5: | Line 5: | ||
desc='''This method is used to call server functions from npc script using streams as medium.''' Calling RFC will returns function which can be used to call remote functions of server( i.e. functions in squirrel gamemode) when called with their parameters. Note that a single call to RFC(..) will return function and a double call RFC(..)(param1, param2, .. ) where param1, param2 are parameters of remote function only will call the remote function. RFC stands for ''Remote Function Call''| | desc='''This method is used to call server functions from npc script using streams as medium.''' Calling RFC will returns function which can be used to call remote functions of server( i.e. functions in squirrel gamemode) when called with their parameters. Note that a single call to RFC(..) will return function and a double call RFC(..)(param1, param2, .. ) where param1, param2 are parameters of remote function only will call the remote function. RFC stands for ''Remote Function Call''| | ||
params=<syntaxhighlight lang="lua">([string]funcname or [userdata])</syntaxhighlight> | params=<syntaxhighlight lang="lua">([string]funcname or [userdata])</syntaxhighlight> | ||
<poem>::funcname : The name of the remote function or userdata returned by [[F]]. (Assuming F is calling a function which will return a function which is our target function)</poem>| | <poem>::funcname : The name of the remote function or userdata returned by [[LibRPC_F|F]]. (Assuming F is calling a function which will return a function which is our target function)</poem>| | ||
example= | example= | ||
<poem> | <poem>Calling 'SetGravity' function of server from npcscripts:</poem><source lang="lua"> | ||
RFC("SetGravity")(0.0) | RFC("SetGravity")(0.0) | ||
</source>| | </source>| |
Revision as of 10:07, 3 May 2023
This function was added in LibRPC (API 1.2).
Description:
This method is used to call server functions from npc script using streams as medium. Calling RFC will returns function which can be used to call remote functions of server( i.e. functions in squirrel gamemode) when called with their parameters. Note that a single call to RFC(..) will return function and a double call RFC(..)(param1, param2, .. ) where param1, param2 are parameters of remote function only will call the remote function. RFC stands for Remote Function Call
Parameters:
([string]funcname or [userdata])
funcname : The name of the remote function or userdata returned by F. (Assuming F is calling a function which will return a function which is our target function)
Return Values:
This will return a function object which can be used as if it is the remote function itself.(except of return values)
Example
Calling 'SetGravity' function of server from npcscripts:
RFC("SetGravity")(0.0)
Related Functions
The following functions may be helpful as they relate to this function in one way or another.
More
Supported parameter types of the closure(function) returned by RFC are:
Numbers/Integers | |
Float | |
String | |
bool | true/false |
Null | null |
Vector | Vector(x,y,z) |
Quaternion | Quaternion(x,y,z,w) |
Userdata returned by F (Function) | F("print")(500) See F |
Array |
The following parameter types are not supported:
Blob |
Class Instances other than Vector or Quaternion |