This is a documentation for Board Game Arena: play board games online !

Khác biệt giữa bản sửa đổi của “SandboxScripts”

Từ Board Game Arena
Bước tới điều hướng Bước tới tìm kiếm
(Created page with " This is the reference of functions you can call from your Sandbox scripts.")
 
Không có tóm lược sửa đổi
Dòng 1: Dòng 1:


This is the reference of functions you can call from your Sandbox scripts.
This is the reference of functions you can call from your Sandbox scripts.
= Lua programming language =
Lua is a very simple & generic script language, very close from C or PHP.
If you are familiar with most used languages, you can learn Lua basic structures in few minutes (for example from this page : https://awesome.naquadah.org/wiki/The_briefest_introduction_to_Lua).
Using Lua, you can write scripts to automate moves for your Sandbox games & provide rules reinforcement.
= Sandbox Scripts Hello World =
From Sandbox editor "interface view" tab, select an element, and access to its property (top right icon).
Go to "Scripts (advanced)" section.
In front of "When this element is clicked", enter "onMyClick".
Close the window. Go to "script view" tab.
Enter the following :
function onMyClick(id)
    addToBgaLog("Hello world! I just clicked on element "..id)
end
Save & publish your project, starts a test session, click on the previous element : your message appears in the log on the right!
= Functions you can use in your Lua Sandbox scripts=
==addToBgaLog( txt )==

Phiên bản lúc 15:12, ngày 12 tháng 12 năm 2016

This is the reference of functions you can call from your Sandbox scripts.

Lua programming language

Lua is a very simple & generic script language, very close from C or PHP.

If you are familiar with most used languages, you can learn Lua basic structures in few minutes (for example from this page : https://awesome.naquadah.org/wiki/The_briefest_introduction_to_Lua).

Using Lua, you can write scripts to automate moves for your Sandbox games & provide rules reinforcement.


Sandbox Scripts Hello World

From Sandbox editor "interface view" tab, select an element, and access to its property (top right icon).

Go to "Scripts (advanced)" section.

In front of "When this element is clicked", enter "onMyClick".

Close the window. Go to "script view" tab.

Enter the following :

function onMyClick(id)
   addToBgaLog("Hello world! I just clicked on element "..id)
end

Save & publish your project, starts a test session, click on the previous element : your message appears in the log on the right!


Functions you can use in your Lua Sandbox scripts

addToBgaLog( txt )