Client Script – Ylands

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 31: Line 31:
= Client scripting =
= Client scripting =
=== How to ===
=== How to ===
[[File:Ylands Client Script - toggle1.png|upright=1.0|thumb|right|Switch]]
If client scripting is supported by the Game Logic, it can be toggled by switching the canvas by using the to toggle found in the top bar.  
If client scripting is supported by the Game Logic, it can be toggled by switching the canvas by using the to toggle found in the top bar.  


Note  
==== Note ====
Clients / Server scripts run simultaneously, one does not disable the other.
Clients / Server scripts run simultaneously, one does not disable the other.


=== Variables ===
=== Variables and Custom Instructions ===
Variables and instructions in Client Scripting work same way as in Server one, variables and instructions defined in Global Storages are available globally within the script, however only for Client Scripts. Due to the nature of Serve / Client scripts they are separated.
 
Client Script variables can be exposed as Custom parameters in same way as Server ones and they will appear along them in Object Properties.


=== Client <-> Server events ===
=== Client <-> Server events ===
[[File:Ylands Client Script - event1.png|upright=1.0|thumb|right|Client event]]


= See also =
= See also =

Revision as of 19:06, 17 November 2021

Introduction

Client scripting is new way how to optimize multiplayer games created in Ylands editor. It allows to offload some of the scripting from server and execute it only on the client meaning that these scripts are not subjected to player multiplayer latency (i.e ping). However this advantage is coming with few disadvantages.

Differences

Because the local scripting is not authorized by server, it does not allow to do all the stuff possible with "normal" (server) scripting. Everything done trough Client Scripting stays only on the client, so there are several limitations imposed by this fact.

  • Only handful of Game Logic are supporting Client Scripting
  • Limited script abilities
    • Can only read data from the scene but can't write data to the scene (i.e object color, hit points etc.).
    • Cannot change properties of supported Game Logic.

On the other hand Client Script allows to do many things that are not needed to be authorized by server, because they only matter to the client (player) or stuff which would not be effective in Server script due the latency. It is mostly useful for improving player UI experience.

  • Extensively customize UI on the client.
  • Program simple UI games on the client.
  • Utilize new instructions such as:
    • On Update event, which executes every frame, to create i.e animations.
    • Get Cursor position.
    • Get Screen resolution.
    • And much more.

In order to assure the communication between server and client scripting, there are events that allow to send/listen to messages between those two. For example you can send a final score of 2D UI game to the server to be included in the leaderboard.

Supported Game logic

  • Custom Controls
  • Custom HUD
  • Custom Window
  • Event Listener
  • Global Storage

Client scripting

How to

Switch

If client scripting is supported by the Game Logic, it can be toggled by switching the canvas by using the to toggle found in the top bar.

Note

Clients / Server scripts run simultaneously, one does not disable the other.

Variables and Custom Instructions

Variables and instructions in Client Scripting work same way as in Server one, variables and instructions defined in Global Storages are available globally within the script, however only for Client Scripts. Due to the nature of Serve / Client scripts they are separated.

Client Script variables can be exposed as Custom parameters in same way as Server ones and they will appear along them in Object Properties.

Client <-> Server events

Client event

See also