User Tools

Site Tools


scripting:scriptedosd

This is an old revision of the document!


Scripted OSD Overview

The ScriptedOSD system allows you to write scripts on your server that can bring up a window on the client, displaying images, text, buttons etc, which the player is able to interact with.

One common use for ScriptedOSD is in conjunction with the 'Scripted' building type - When the player accesses the building, your script is run and it generates the display window for the building.

ScriptedOSD Example

Here is an example script that activates a dialog on the client.

<codedoc> Event( “Custom”, “HelloWorld” ) {

 osdcreate(OSDLIST,"Main","Hello World") 
 osdadditem(OSDTEXT, "", "How would you like to respond") 
 osdadditem(OSDBUTTON, "Option1", "Positively") 
 osdadditem(OSDBUTTON, "Option2", "Negatively") 
 osdactivate() 

}

Event( “OSDSelect”, “Main:Option1” ) {

 osdcreate(OSDLIST,"Congrats","You responded positively") 
 osdadditem(OSDEXITBUTTON, "Exit", "Ok") 
 osdactivate() 

}

Event( “OSDSELECT”, “Main:Option2” ) {

 osdcreate(OSDLIST,"Congrats","You responded negatively") 
 osdadditem(OSDEXITBUTTON, "Exit", "Ok") 
 osdactivate() 

} </codedoc> The first block - which is run when a custom event called 'HelloWorld' is run (for instance by entering *event {YourName} HelloWorld) - lays out the initial menu of the OSD, a bit of text with two buttons.

The second parameter of the OSDCreate function 'names' your OSD screen, and is important when dealing with the OSDSELECT response

Each 'osdadditem' line adds a line to the display. OSDTEXT is used to put some text on the screen, then OSDBUTTON to add a couple of buttons.

The second two blocks handle the response when the player selects one of the buttons. The second parameter of the event is formatted OSDNAME:OSDBUTTONNAME.

scripting/scriptedosd.1333660665.txt.gz · Last modified: (external edit)