script1.talk
_______________________________________________________

// Script for Region Check 1.0
// by Oscar (14 APR 2004)

   // This is a more complex example than the Keypad 1.0
   // Please note that you should look at tutorial that examines the lines
   // otherwise it may be too overwhelming
   
   // This script runs automatically after you load the Component
   // You can bypass the script when you hold SHIFT
   
   // Component access to the objects:
      // in order to know which objects belongs to the component
      // three array variables are filled up:menusInBlackBox,   vmgsInBlackBox, moviesInBlackBox
      
      // menusInBlackBox retuns the number of menus in box and
      // menusInBlackBox[1] returns what is the order number relative to project of the first menu in box
      // see this example below:
      /*
print "Number of Menus in this Component: ",menusInBlackBox
for menu=1 to menusInBlackBox
print "Menu #",menu," in Component is a Menu #",menusInBlackBox[menu]," in a whole project"
next menu
*/*/
      // note, the number returned by vmgsInBlackBox[x] is in range 1...255,
      // while all Menu functions uses vmg in range 10001-10255
      // that means you have to add 10000 or use function VMG(vmgsInBlackBox[x])
   


region=1
regionzero=1
input "This is a region code check component.","Allowed Region (1..6)",region,"Region Free players are set to play all regions","CHECK:Allow Region Free",regionzero," ","(c) Oscar 2004"

// terminate script if pressed cancel
if bCancelInput then
   end
endif

// see note in header about componnent
// since it is VMG, we need to use VMG() function to get the correct menu number
commandobject = VMG(vmgsInBlackBox[1])

// remove all precommands
MenuRemovePRECommands(commandobject)

// get region info of player from sprm
MenuAddPRECommand(commandobject,"GPRM1 = SPRM20")

// regions are set as bits, it means region 1 = 1, region2 = 2 region3 = 4; region 4 = 8
regiontab[0] = 0
regiontab[1] = 1
regiontab[2] = 2
regiontab[3] = 4
regiontab[4] = 8
regiontab[5] = 16
regiontab[6] = 32


trace regionzero

// find the PGC of 'Wrong Region' VMG menu (# 2 in component)
// because DVD-lab has first VMG dummy we need to have +1
sPGCWrong = STR(vmgsInBlackBox[2]+1)

// disallow region zero
if (regionzero==0) then
   sLine = "if (GPRM1 == 0) LinkPGCN "+sPGCWrong
   MenuAddPRECommand(commandobject, sLine)
endif

// test the main region   

sLine = "if (GPRM1 != "+ STR(regiontab[region]) +") LinkPGCN "+sPGCWrong
MenuAddPRECommand(commandobject, sLine)

// Set first Play and Title button to our Command object
LinkFPtoMenu(commandobject) // First Play to menu
LinkTBtoMenu(commandobject) // Title Button to menu

// Now try to link end of command object to VTSM or VMG

nVMGc = MenuGetVMGCount()
nVTSMc = MenuGetCount()


if (nVTSMc>0) then
   MenuEndLink(commandobject, 1)
endif

// prefer VMG
// we have right now at least 2 VMGs already (this component) so check for 3 VMG's or more

if (nVMGc>2) then
   MenuEndLink(commandobject, VMG(1))
endif

   



Created with DVD-lab Pro