User Tools

Site Tools


scripting:scriptedosd

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
scripting:scriptedosd [2012/04/05 21:17] mitscripting:scriptedosd [2025/05/28 16:34] (current) – external edit 127.0.0.1
Line 4: Line 4:
 <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 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> </note>
 +
 +For details of all the OSD commands and parameters available see the [[scripting:reference:scriptedosd|Reference section]]
  
 ===== ScriptedOSD Example ===== ===== ScriptedOSD Example =====
Line 13: Line 15:
  
    osdcreate(OSDLIST,"Main","Hello World"    osdcreate(OSDLIST,"Main","Hello World"
-   osdadditem(OSDTEXT, "", "How would you like to respond")  +   osdadditem(TEXT, "", "How would you like to respond")  
-   osdadditem(OSDBUTTON, "Option1", "Positively")  +   osdadditem(BUTTON, "Option1", "Positively")  
-   osdadditem(OSDBUTTON, "Option2", "Negatively"+   osdadditem(BUTTON, "Option2", "Negatively"
    osdactivate()     osdactivate() 
  
Line 21: Line 23:
 Event( "OSDSelect", "Main:Option1" Event( "OSDSelect", "Main:Option1"
  
-   osdcreate(OSDLIST,"Congrats","You responded positively")  +   *notify %PLAYER% You responded positively
-   osdadditem(OSDEXITBUTTON, "Exit", "Ok")  +
-   osdactivate() +
  
  
-Event( "OSDSELECT", "Main:Option2"+Event( "OSDSelect", "Main:Option2"
  
-   osdcreate(OSDLIST,"Congrats","You responded negatively")  +   *notify %PLAYER% You responded negatively
-   osdadditem(OSDEXITBUTTON, "Exit", "Ok")  +
-   osdactivate() +
  
 </codedoc> </codedoc>
Line 36: Line 34:
 <note> <note>
 The second parameter of the OSDCreate function 'names' your OSD screen, and is important when dealing with the OSDSELECT response The second parameter of the OSDCreate function 'names' your OSD screen, and is important when dealing with the OSDSELECT response
-</note> +</note>  
-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.+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''
 + 
 +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. 
 +<codedoc>    
 +   osdcreate(OSDLOWER,"Main","Big Button")  
 +   osdaddat(BUTTON, 200, 0, 200, 100, "Press", "Press me!")  
 +   osdactivate()  
 +</codedoc> 
  
-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)