Remote function

From Dark Signs Online
Jump to navigationJump to search

Remote functions are functions that have to connect to an internet server, to send and/or receive data, before returning a value.

To wait for the function to finish connecting and return the value properly, you must use the WAIT FOR function.

      WAIT FOR $var

For example:

      $ip = 102.142.61.88
      
      $var = ping($ip)
      WAIT FOR $var
      
      //continue...


The variable contains the value "[loading]" while waiting for the function to complete.

On the other hand, if you are using the function to send information only, and don't care what data is returned, there is no need to WAIT for it.


Additionally, remote functions, unlike most other functions, can only be used on a line by themselves.

This is correct:

      $var = ping(1.1.1.1)

This is incorrect:

      $var = ping(1.1.1.1)ping(1.1.1.2)

The following is also incorrect:

      IF ping(1.1.1.1) = 1 THEN
      //do something
      END IF

This is much better:

      $ping = ping(1.1.1.1)
      WAIT FOR $ping
      IF $ping = 1 THEN
      //do something
      END IF