Jump to content
Sign in to follow this  
Shadow72

Shadow's Text Scripting Cheat Sheet

Recommended Posts

Variables Within Functions

function MyFunction() {
	let myVariable = 7;
}

 

Increment/Decrement Integer

let i = 7;

// Increments the integer i
i += 1;

// Decrements the integer i
i -= 1;

 

For Loops

for(let i = 0; i < 100; i += 1) {
                       
	
}

 

Intellisense For Custom Functions

// Add directly above your function. The format is ([Paramater Name]: [Parameter Type]) using commas to seperate if you have more than one paramater.
/** @type {(player: YCharacter, inputString: string)} */
function MyFunction(player, inputString) {

}

 

Get/Set Game Storage Variables

// Get Game Storage Variable
// "MyVariable" = the name of the game storage variable
YServerData.getServerVariable(player, YServerDataScope.Game, "MyVariable");

// Set Game Storage Variable
// "MyVariable" = the name of the game storage variable
// 7 = the value you want to set the variable to
YServerData.setServerVariable(this.YPlayer, YServerDataScope.Game, "MyVariable", 7);

// If your game is a part of a game set replace YServerDataScope.Game with YServerDataScope.GameSet

 

Getting A Specific Object In The World

// For getting game logic
// 52 = the id of the game logic
YWorld.GetLogic(52);

// For getting entities
// 75 = the id of the entity(not the entity type id)
YWorld.GetEntity(75);

 

Show Warning

// Show warning to everyone
YUi.showWarning("Test");

// Show warning to a specific player
YUi.showWarning(player, "Test");

 

  • Like 7
  • Thanks 1

Share this post


Link to post
Share on other sites

This is great, thank you so much. Do the devs plan to do some kind of wiki, with all this stuff in it ?

Share this post


Link to post
Share on other sites

Hi,

there will be something official from us. However, it will take time to make it. At the moment we have full API exposed on https://scripting.ylands.com/ with tutorial how to set Visual Studio Code so it will autocomplete what you write.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Would auto completion file you provide work with notepad ++ ?

Share this post


Link to post
Share on other sites

never mind, I am using Visual. Your step by step installation and set up was really smooth, thanks.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×