User Tools

Site Tools


scripting:scriptedosd

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
scripting:scriptedosd [2012/03/23 02:19] – created mitscripting:scriptedosd [2025/05/28 16:34] (current) – external edit 127.0.0.1
Line 1: Line 1:
-===== Scripted OSD =====+===== 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. 
 +<note tip>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.
 +</note>
  
 +For details of all the OSD commands and parameters available see the [[scripting:reference:scriptedosd|Reference section]]
  
-Temporary notes:+===== ScriptedOSD Example ===== 
 + 
 +Here is an example script that activates a dialog on the client.
  
 <codedoc> <codedoc>
-Event( "Custom", "SmokeACigar" ) +Event( "Custom", "HelloWorld" ) 
  
-   *soundeffect 18  +   osdcreate(OSDLIST,"Main","Hello World")  
-   osdcreate(OSDLIST,"Main","You just smoked a cigar")  +   osdadditem(TEXT, "", "How would you like to respond")  
-   osdadditem(OSDTEXT, "", "Do you feel good?")  +   osdadditem(BUTTON, "Option1", "Positively")  
-   osdadditem(OSDBUTTON, "Option1", "It made me feel good")  +   osdadditem(BUTTON, "Option2", "Negatively"
-   osdadditem(OSDBUTTON, "Option2", "No. Bleh! I hate cigars!"+
    osdactivate()     osdactivate() 
  
Line 18: Line 23:
 Event( "OSDSelect", "Main:Option1" Event( "OSDSelect", "Main:Option1"
  
-   osdcreate(OSDLIST,"Congrats","You feel good?")  +   *notify %PLAYER% You responded positively
-   osdadditem(OSDBUTTON, "Option1", "Yay for the cigar smoker.")  +
-   osdactivate() +
  
  
-Event( "OSDSELECT", "Main:Option2"+Event( "OSDSelect", "Main:Option2"
  
-   osdcreate (OSDLIST,"YOU SUCK!" )  +   *notify %PLAYER% You responded negatively
-   osdadditem(OSDBUTTON, "Option1", "You suck anyway. Click here and get out mah face." )  +
-   osdactivate() +
  
 </codedoc> </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. 
 +<note>
 +The second parameter of the OSDCreate function 'names' your OSD screen, and is important when dealing with the OSDSELECT response
 +</note> 
 +Each 'osdadditem' line adds a line to the display. TEXT is used to put some text on the screen, then BUTTON 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''.
  
-the first bit of this lays out the initial menu of the OSD for the use of the cigars. the 'Custom' Event on the start just specifies the event your running for the action, which you want the same identifier as in your CustomEvent identifier was set.  +If you want to control the layout of your OSD more directly, you use **osdaddat** rather than osdadditem, providing X,Y, width and height for each item.  
- +e.g. 
-"mainis a label for the parser to identify menuand the bit after that is a title for the menu.  +<codedoc>    
- +   osdcreate(OSDLOWER,"Main","Big Button" 
-Each 'osdadditem' line adds a line to the menu for the player to click on to activate. You can name them whatever they want. Option1 and Option2 are just made for example. +   osdaddat(BUTTON, 200, 0, 200, 100, "Press", "Press me!" 
 +   osdactivate()  
 +</codedoc>
  
-OSDTEXT is to put some text above the buttons (or below, depending on where you lay it in the script)  
  
-When the player clicks option1 or option2, it kicks an event trigger. when the event trigger for Main:Option1 is set, the event is called, and you can make it do whatever you want that you could normally do in script. 
  
scripting/scriptedosd.1332469144.txt.gz · Last modified: (external edit)