RFC: Difference between revisions
(Created page with "<poem style="border: 2px solid #d6d2c5; background-color: #f9f4e6; padding: 1em;"> This function was added in v1.6 beta and will not work on previous versions. </poem>") |
No edit summary |
||
(23 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<poem style="border: 2px solid #d6d2c5; background-color: # | <poem style="border: 2px solid #d6d2c5; background-color: #f2f4e6; padding: 1em;"> | ||
This function was added in v1.6 beta and will not work on previous versions. | This function was added in v1.6 beta and will not work on previous versions. | ||
</poem> | </poem> | ||
<poem style="border: 2px solid #d6d2c5; background-color: #f9f3e6; padding: 1em;"> | |||
This function belongs to server scripts and not npcscripts. | |||
</poem> | |||
<poem style="border: 2px solid #d6d2c5; background-color: #f9f3e6; padding: 1em;"> | |||
The library [[LibRPC]] must be loaded with the npc for Remote Calls to work. | |||
</poem> | |||
<poem style="border: 2px solid #d6d2c5; background-color: #ffff00; padding: 1em;"> | |||
The second parameter of the type userdata was added in v1.6 beta2 and will not work in v1.6 beta | |||
</poem> | |||
<poem style="border: 2px solid #d6d2c5; background-color: #e4ace8; padding: 1em;"> | |||
'''Since v1.6 beta4, npcscripts also have function of same name- [[LibRPC_RFC|RFC]]''' | |||
</poem> | |||
{{Welcome| | |||
desc='''This method is used to call npcscript functions from server script using streams as medium.''' Calling RFC will returns function which can be used to call remote functions of npcscripts( i.e. functions in npcscripts: StartRecordingPlayback, SendDeathInfo, .. ) 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">(npcid, [string]funcname or [userdata])</syntaxhighlight> | |||
<poem>::npcid : The ID of the target npc on whose environment the function will be searched. | |||
::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>| | |||
example= | |||
<poem>Server Side</poem><source lang="lua"> | |||
StartPlayback <- RFC(0, "StartRecordingPlayback"); //creates a function object locally. Not yet communicate with npc. | |||
StartPlayback(1,"runtolake"); //will search and execute StartRecordingPlayback(1, "runtolake") on npcscript.(of NPC with ID 0 ) | |||
//You can also do this in one line | |||
RFC(0,"print")("Hello how are you"); //will print the text: 'Hello how are you' on npc console(console can be shown by ShowNPCConsole() ) of npc with ID 0. | |||
</source>| | |||
retvals= This will return a function object which can be used as if it is the remote function itself.(except of return values) | |||
|relfuncs= | |||
*[[F]]| | |||
}} | |||
==More== | |||
Supported parameter types of the closure(function) returned by RFC are: | |||
{{RFCParamTypes}} |
Latest revision as of 18:46, 7 May 2023
This function was added in v1.6 beta and will not work on previous versions.
This function belongs to server scripts and not npcscripts.
The library LibRPC must be loaded with the npc for Remote Calls to work.
The second parameter of the type userdata was added in v1.6 beta2 and will not work in v1.6 beta
Since v1.6 beta4, npcscripts also have function of same name- RFC
Description:
This method is used to call npcscript functions from server script using streams as medium. Calling RFC will returns function which can be used to call remote functions of npcscripts( i.e. functions in npcscripts: StartRecordingPlayback, SendDeathInfo, .. ) 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:
(npcid, [string]funcname or [userdata])
npcid : The ID of the target npc on whose environment the function will be searched.
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
Server Side
StartPlayback <- RFC(0, "StartRecordingPlayback"); //creates a function object locally. Not yet communicate with npc. StartPlayback(1,"runtolake"); //will search and execute StartRecordingPlayback(1, "runtolake") on npcscript.(of NPC with ID 0 ) //You can also do this in one line RFC(0,"print")("Hello how are you"); //will print the text: 'Hello how are you' on npc console(console can be shown by ShowNPCConsole() ) of npc with ID 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 |