Bethesda Tutorial Papyrus Hello World/ru

From the CreationKit Wiki
Revision as of 13:33, 30 August 2012 by imported>Peganoff
Jump to navigation Jump to search
Bethesda Tutorial Papyrus Hello World/ru
Скрипты Series, Chapter 1
Return to Tutorial Hub
LeftArrow.png Previous Tutorial Next TutorialRightArrow.png

Краткий обзор

Этот урок познакомит с основами Papyrus, скриптового языка Creation Kit.



Вы узнаете:

  • Как создать новый скрипт и приделать его к объекту.
  • Как заставить ваш скрипт реагировать на события.

Создание скрипта

Первое, что мы сделаем, это создадим новый скрипт и приделаем его к объекту в мире. Запустите Creation Kit и загрузите любую тестовую ячейку на ваш выбор. Я буду использовать MolagBalVoiceCell просто потому, что это хорошая пустая ячейка без каких-либо отвлекающих нас помех.

Давайте поставим объект в ячейку. Используйте WETempActivator из списка Activator. Это просто светящийся столб, который мы использовали в качестве временного объекта в процессе разработки.

Papyrus Tutorial1 Activator.jpg

Дважды щелкните на объекте, чтобы открыть окно Reference. Перейдите на вкладку Scripts. Здесь вы можете добавить скрипты на любой объект в игре.

Papyrus Tutorial1 Ref.jpg


Нажмите кнопку Add, чтобы открыть окно "Add Script".

Papyrus Tutorial1 AddScript.jpg

Дважды щелкните "[New Script]" в верхней части списка, чтобы создать новый скрипт. Измените поле Name на "HelloWorldScript" (это будет имя скрипта), и нажмите "OK".

Papyrus Tutorial1 NewScript.jpg

You'll now see that your new script has been added to the pillar's script list:

Papyrus Tutorial1 Ref WithScript.jpg

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:

Papyrus Tutorial1 CompiledScript.jpg

"Hello, World"

Теперь войдите в игру, чтобы попробовать его. (Убедитесь что: сохранили свой плагин, и он стоит в списке загрузки первым.)

Когда вы в игре, нажмите ~ чтобы вызвать консоль. Введите:

coc MolagBalVoiceCell

для перехода к ячейке. Подойдите к столбу и активируйте его. Вы должны увидеть ваше новое окно сообщений:

Papyrus Tutorial1 HelloWorld.jpg

Вот и все. Вы сделали объект, который может реагировать на действия игрока! Далее, вы можете узнать,как использовать переменные и условные операторы, чтобы сделать ваш сценарий немного более сложным.


LeftArrow.png Previous Tutorial Return to Tutorial Hub Next Tutorial RightArrow.png


Language: [[::Bethesda Tutorial Papyrus Hello World/ru|English]]