Difference between revisions of "Bethesda Tutorial Papyrus Hello World/ru"
imported>Peganoff |
imported>Peganoff |
||
Line 1: | Line 1: | ||
[[Category:Tutorials]] | [[Category:Tutorials]] | ||
[[Category:Solutions]] | [[Category:Solutions]] | ||
{{Tutorial Index | {{Tutorial Index/ru | ||
|series=Скрипты | |series=Скрипты | ||
|chapter=1 | |chapter=1 |
Revision as of 13:37, 30 August 2012
Bethesda Tutorial Papyrus Hello World/ru | |
---|---|
Серия: Скрипты, глава 1 | |
К другим учебникам | |
Предыдущая статья | Следующая статья |
Краткий обзор
Этот урок познакомит с основами Papyrus, скриптового языка Creation Kit.
Вы узнаете:
- Как создать новый скрипт и приделать его к объекту.
- Как заставить ваш скрипт реагировать на события.
Создание скрипта
Первое, что мы сделаем, это создадим новый скрипт и приделаем его к объекту в мире. Запустите Creation Kit и загрузите любую тестовую ячейку на ваш выбор. Я буду использовать MolagBalVoiceCell просто потому, что это хорошая пустая ячейка без каких-либо отвлекающих нас помех.
Давайте поставим объект в ячейку. Используйте WETempActivator из списка Activator. Это просто светящийся столб, который мы использовали в качестве временного объекта в процессе разработки.
Дважды щелкните на объекте, чтобы открыть окно Reference. Перейдите на вкладку Scripts. Здесь вы можете добавить скрипты на любой объект в игре.
Нажмите кнопку Add, чтобы открыть окно "Add Script".
Дважды щелкните "[New Script]" в верхней части списка, чтобы создать новый скрипт. Измените поле Name на "HelloWorldScript" (это будет имя скрипта), и нажмите "OK".
You'll now see that your new script has been added to the pillar's script list:
Hit "OK" to save the changes to the pillar reference. Congratulations! You've just created your first script and attached it to something in the world.
Adding an Event
Of course, your script doesn't do anything yet - it's just an empty shell waiting to be given something to do.
Because this object is an Activator, it can respond to being clicked on ("activated") by the player. So let's tell our script to show us a message when the player clicks on the pillar.
Reopen the pillar's Reference window, and right-click on the HelloWorldScript on the Script tab. Select "Edit Source", which will bring up the script editing window.
Now we need to tell the script to respond to being activated, which means we need to add the OnActivate event to our script. Add the following lines to your script:
Event OnActivate(ObjectReference akActionRef)
endEvent
For now, don't worry about how we knew what syntax to use here when we defined the OnActivate event - we'll go into more detail on that in a later tutorial. For now, let's just see if we can get our script to do something in the game.
At this point, our script is ready to respond to the OnActivate event, so let's tell it to show a simple message box:
Event OnActivate(ObjectReference akActionRef)
Debug.MessageBox("Hello, World!")
endEvent
To explain this last step a bit more, the syntax of the line breaks down as follows:
- Debug.MessageBox("Hello, World!"): This is telling the script that we're calling a function on a different script (in this case the special default Debug script object).
- Debug.MessageBox("Hello, World!"): MessageBox is a function that pops up a message box.
- Debug.MessageBox("Hello, World!"): The parentheses show that we're calling a function; whatever's inside the parentheses is the data that we're passing to the function (in this case, the text that we want to be displayed in the message box).
Save and compile your script by selecting "Save" from the File menu on the script editing window (or CTRL-S). If you typed everything correctly, you should see this:
"Hello, World"
Теперь войдите в игру, чтобы попробовать его. (Убедитесь что: сохранили свой плагин, и он стоит в списке загрузки первым.)
Когда вы в игре, нажмите ~ чтобы вызвать консоль. Введите:
coc MolagBalVoiceCell
для перехода к ячейке. Подойдите к столбу и активируйте его. Вы должны увидеть ваше новое окно сообщений:
Вот и все. Вы сделали объект, который может реагировать на действия игрока! Далее, вы можете узнать,как использовать переменные и условные операторы, чтобы сделать ваш сценарий немного более сложным.
Previous Tutorial | Return to Tutorial Hub | Next Tutorial |
Language: | [[::Bethesda Tutorial Papyrus Hello World/ru|English]] |
---|