Difference between revisions of "Bethesda Tutorial Papyrus Hello World/ru"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Peganoff
imported>Peganoff
Line 15: Line 15:
* Как заставить ваш скрипт реагировать на события.
* Как заставить ваш скрипт реагировать на события.


=Creating a Script=
=Создание скрипта=
The first thing we're going to do is to create a new script and attach it to an object in the world. Run the Creation Kit and load up a test cell of your choice. I'll be using MolagBalVoiceCell simply because it's a nice empty cell without any clutter to distract us.
Первое, что мы сделаем, это создадим новый скрипт и приделаем его к объекту в мире. Запустите Creation Kit и загрузите любую тестовую ячейку на ваш выбор. Я буду использовать  MolagBalVoiceCell просто потому, что это хорошая пустая ячейка без каких-либо отвлекающих нас помех.


Let's put an object in the cell - use '''WETempActivator''' from the Activator list. It's a simple glowing pillar that we used as a temporary object during development.
Давайте поставим объект в ячейку. Используйте '''WETempActivator''' из списка Activator. Это просто светящийся столб, который мы использовали в качестве временного объекта в процессе разработки.


[[Image:Papyrus Tutorial1 Activator.jpg|300px]]
[[Image:Papyrus Tutorial1 Activator.jpg|300px]]


Double-click on the object to open the Reference window. Switch to the Scripts tab. This is where you can add scripts to any object in the game.
Дважды щелкните на объекте, чтобы открыть окно Reference. Перейдите на вкладку Scripts. Здесь вы можете добавить скрипты на любой объект в игре.


[[Image:Papyrus Tutorial1 Ref.jpg]]
[[Image:Papyrus Tutorial1 Ref.jpg]]




Click the Add button to bring up the "Add script" window.
Нажмите кнопку Add, чтобы открыть окно "Add Script".


[[Image:Papyrus Tutorial1 AddScript.jpg]]
[[Image:Papyrus Tutorial1 AddScript.jpg]]

Revision as of 13:27, 30 August 2012

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

Double-click "[New Script]" at the top of the list to create your new script. Change the Name field to "HelloWorldScript" (this will be the script's name), and hit "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]]