Скрипт на кодовый замок. Открывается при наборе правильной комбинации из 4 цифр (2914).
Scn aaaaMaormerSeyfOnScript
Short Popitka Short Button1 Short Button2 Short Button3 Short Button4 Short CombiRight Short ChestOpen Short DoOnce
Begin OnActivate if ( ChestOpen == 2 ) Activate else Set chestopen to 1 set Popitka to 0 set CombiRight to 0 endIf end
Begin GameMode if (ChestOpen == 1) if (Popitka == 0) MessageBox,"Введите первую цифру кода","0","1","2","3","4","5","6","7","8","9" Set Popitka to 1 endif endif
if (Popitka == 1) set button1 to Getbuttonpressed if button1 == -1 return else Set Popitka to 2 endif endif
if (Popitka == 2) MessageBox,"Введите вторую цифру кода","0","1","2","3","4","5","6","7","8","9" Set Popitka to 3 endif
if (Popitka == 3) set button2 to Getbuttonpressed if button2 == -1 return else Set Popitka to 4 endif endif
if (Popitka == 4) MessageBox,"Введите третью цифру кода","0","1","2","3","4","5","6","7","8","9" Set Popitka to 5 endif
if (Popitka == 5) set button3 to Getbuttonpressed if button3 == -1 return else Set Popitka to 6 endif endif
if (Popitka == 6) MessageBox,"Введите четвертую цифру кода","0","1","2","3","4","5","6","7","8","9" Set Popitka to 7 endif
if (Popitka == 7) set button4 to Getbuttonpressed if button4 == -1 return else Set Popitka to 8 endif endif
if (Popitka == 8) if button1 == 2 Set CombiRight to CombiRight + 1 endif if button2 == 9 Set CombiRight to CombiRight + 1 endif if button3 == 1 Set CombiRight to CombiRight + 1 endif if button4 == 4 Set CombiRight to CombiRight + 1 endif
if (Popitka == 8) && (CombiRight == 4) Set ChestOpen to 2 set Popitka to 0 return endif
if (Popitka == 8) && (CombiRight <= 3) MessageBox"Код неверен." Set Popitka to 0 Set ChestOpen to 0 endif
elseif (chestopen == 0) return elseif (chestopen == 2) if Doonce == 0 set doonce to 1 Activate return endif else return endif end
Интересный и полезный прием - создание скрипта, содержащего одни переменные. Скрипт - объектный, объявленные в нем переменные могут использоваться в других скриптах. (что-то вроде глобальной переменной, но менее капризно)
Скрипт переменных. Навешан, например, на сундук с REF ID aaaMRDreamMercyChestRef
Scn aaaMRVarScr
Short doonce Short Da Short HitVar Short Larchik Short Summa
При необходимости использовать переменную из этого скрипта, в нужном месте другого скрипта эта переменная запишется как, например, aaaMRDreamMercyChestRef.doonce Пример - см.ниже.
Ларчик, выдающий деньги. (карманный банкомат )
Scn aaaMRLarecScr
Short Var Short Button Short Alarm Short Maxim
Begin OnEquip If aaaMRDreamMercyChestRef.Summa == 100000 Set aaaMRDreamMercyChestRef.Larchik to 1 Set Var to -1 else MessageBox "Постарайтесь не жадничать. Какая сумма Вам нужна?", "1 септим", "10 септимов", "100 септимов", "1000 септимов", "10000 септимов", "100000 септимов" Set Var to 1 endif end
Begin GameMode If Var == 1 Set Button to GetButtonPressed if ( Button == 0 ) If aaaMRDreamMercyChestRef.Summa+1<=100000 Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+1 Player.AddItem gold001 1 else Set Maxim to 100000-aaaMRDreamMercyChestRef.Summa Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+Maxim Player.AddItem gold001 Maxim Set Var to -1 endif elseif ( Button == 1 ) If aaaMRDreamMercyChestRef.Summa+10<=100000 Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+10 Player.AddItem gold001 10 else Set Maxim to 100000-aaaMRDreamMercyChestRef.Summa Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+Maxim Player.AddItem gold001 Maxim Set Var to -1 endif elseif ( Button == 2 ) If aaaMRDreamMercyChestRef.Summa+100<=100000 Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+100 Player.AddItem gold001 100 else Set Maxim to 100000-aaaMRDreamMercyChestRef.Summa Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+Maxim Player.AddItem gold001 Maxim Set Var to -1 endif elseif ( Button == 3 ) If aaaMRDreamMercyChestRef.Summa+1000<=100000 Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+1000 Player.AddItem gold001 1000 else Set Maxim to 100000-aaaMRDreamMercyChestRef.Summa Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+Maxim Player.AddItem gold001 Maxim Set Var to -1 endif elseif ( Button == 4 ) If aaaMRDreamMercyChestRef.Summa+10000<=100000 Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+10000 Player.AddItem gold001 10000 else Set Maxim to 100000-aaaMRDreamMercyChestRef.Summa Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+Maxim Player.AddItem gold001 Maxim Set Var to -1 endif elseif ( Button == 5 ) If aaaMRDreamMercyChestRef.Summa+100000<=100000 Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+100000 Player.AddItem gold001 100000 else Set Maxim to 100000-aaaMRDreamMercyChestRef.Summa Set aaaMRDreamMercyChestRef.Summa to aaaMRDreamMercyChestRef.Summa+Maxim Player.AddItem gold001 Maxim Set Var to -1 endif Endif Endif