Tutorial

Displaying a simple message

To send a message in BurningSand 2 you first have to prepare the message. To do so you should at first clear the message using this command:

MESSAGE CLEAR

After that you can begin expanding the message. For example:

MESSAGE ADDTEXT "My favorit number is "

Then the current message will be “My favorit number is ”. Continue by adding a number to the messagen:

MESSAGE ADDNUMBER (3 + 4)

Now the message will be “My favorit number is 7”. Now add a dot:

MESSAGE ADDTEXT "."

Now the message is “My favorit number is 7.”. To send the message use

MESSAGE SEND

Look at the console. You will se the sentence.

Using a message with network support

This tutorial requires advanced programming skills. Here i'll explaine how to write a programm that shuts down your computer on TNTExplosion.

If you want to send a message to another programm you first have to know the MESSAGEID of the programm. So after your programm has connected to BS2 you send the following message:

SET SHUTDOWNHANDLER MESSAGEID

After this you can add the following lines into explosions.bs2:

ON TNTexplosion MESSAGE CLEAR
ON TNTexplosion MESSAGE ADDTEXT "SHUTDOWN WINDOWS"
ON TNTexplosion MESSAGE SEND SHUTDOWNHANDLER

Now listen to every thing you get from BS2. When you recieve the line “SHUTDOWN WINDOWS” simply shutdown windows.

Examples

Using Message to create many elements

 1. REMOVETRIGGER createManyElements 
 2. ON createManyElements SET tmp 0
 3. ON createManyElements WHILE (tmp < 10) createManyElement
 4. REMOVETRIGGER writetime 
 5. ON createManyElement MESSAGE CLEAR
 6. ON createManyElement MESSAGE ADDTEXT "Element Clear manyElement"
 7. ON createManyElement MESSAGE ADDNUMBER tmp
 8. ON createManyElement MESSAGE ADDTEXT " 230 180 0 900 1 1 1 0 Clear 400 TEXT "
 9. ON createManyElement MESSAGE ADDNUMBER tmp
10. ON createManyElement MESSAGE EXEC
11. ON createManyElement SET tmp (tmp + 1)
  1. Removes all actions from createManyElements. So you don't get problems if you run the script more than once.
  2. Sets the variable tmp to 0
  3. Executes createManyElement as long as tmp is smaller than 10. So createManyElement will be called 10 times.
  4. Removes all actions from createManyElement. So you don't get problems if you run the script more than once.
  5. Clears the message.
  6. Adds the text “Element Clear manyElement” to the message.
  7. Adds the number tmp to the message.
  8. Adds the text ” 230 180 0 900 1 1 1 0 Clear 400 TEXT ” to the message.
  9. Adds the number tmp to the message.
  10. Executes the message. This will create an element.
  11. Increases tmp by 1.

The first time createManyElement is called it creates the following message:

 Element Clear manyElement0 230 180 0 900 1 1 1 0 Clear 400 TEXT 0

This message will be executed and the element manyElement0 is being created. The second time createManyElement is called it creates the following message:

 Element Clear manyElement1 230 180 0 900 1 1 1 0 Clear 400 TEXT 1

This message will be executed and the element manyElement1 is being created. …

 
messages.txt · Last modified: 2008/08/08 14:19 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki