Использование скриптов

Материал из CryWiki Russia

(Различия между версиями)
Перейти к: навигация, поиск
(Новая страница: «Script Usage Introduction CryENGINE uses LUA for its scripting language. The Entity System can attach a script proxy to any entity. This appear in the form of a tab...»)
 
Строка 1: Строка 1:
-
Script Usage
+
{{В_процессе_перевода}}
-
Introduction
+
 
 +
 
 +
== Introduction ==
 +
 
CryENGINE uses LUA for its scripting language.
CryENGINE uses LUA for its scripting language.
Строка 14: Строка 17:
Various systems in CryENGINE expose scriptbind functions which allow Lua scripts to call existing code written in C++. The existing scriptbind functions are listed in the reference section.
Various systems in CryENGINE expose scriptbind functions which allow Lua scripts to call existing code written in C++. The existing scriptbind functions are listed in the reference section.
-
How to run scripts
+
 
-
Lua files
+
== How to run scripts ==
 +
 
 +
 
 +
=== Lua files ===
 +
 
Scripts are usually stored in the Game\Scripts directory.
Scripts are usually stored in the Game\Scripts directory.
Строка 22: Строка 29:
Another workflow is creating a script entity as explained in the Structure of a [[Структура скрипта сущности]] topic.
Another workflow is creating a script entity as explained in the Structure of a [[Структура скрипта сущности]] topic.
-
Console
+
 
 +
=== Console ===
 +
 
Script instructions can be executed within the in-game console. This can be done by appending the # character before the instructions.
Script instructions can be executed within the in-game console. This can be done by appending the # character before the instructions.
This functionality is limited to Sandbox or running the launcher in Dev Mode (using the -DEVMODE command-line argument).
This functionality is limited to Sandbox or running the launcher in Dev Mode (using the -DEVMODE command-line argument).
-
Reloading scripts during runtime
+
 
 +
=== Reloading scripts during runtime ===
 +
 
In Sandbox it's always possible to reload entities within the user interface. When selecting a Script Entity, this can be done by clicking on the Reload Script button found in the Rollup Bar.
In Sandbox it's always possible to reload entities within the user interface. When selecting a Script Entity, this can be done by clicking on the Reload Script button found in the Rollup Bar.
Строка 34: Строка 45:
*Script.ReloadScript(filename)
*Script.ReloadScript(filename)
*Script.ReloadScripts()
*Script.ReloadScripts()
-
{{Совет|it's always possible to invoke these functions from the console. The following syntax needs to used.}}Hint:
+
{{Примечание|title=Совет|it's always possible to invoke these functions from the console. The following syntax needs to used.}}
 +
 
#Script.ReloadScript("Scripts\\EntityCommon.lua"
#Script.ReloadScript("Scripts\\EntityCommon.lua"

Текущая версия на 05:49, 31 января 2012

Эта страница страница помечена как находящиеся в процессе перевода.


Содержание

Introduction

CryENGINE uses LUA for its scripting language.

The Entity System can attach a script proxy to any entity. This appear in the form of a table that can include data and functions. The AI System has behaviors and GoalPipes written in scripts. Additionally, several game system such as the Actor, Item System, Vehicle System and the GameRules rely on scripting to extend their functionalities.

Some of the advantages of using scripts are the following:

Fast iteration; scripts can be reloaded within the engine Runtime performance; careful usage of the available resources can result into scripts running nearly as fast as compiled code Easy to use troubleshooting; an embedded LUA debugger can be invoked at any time Most of the engine systems expose ScriptBind functions that can be called with scripts.

Various systems in CryENGINE expose scriptbind functions which allow Lua scripts to call existing code written in C++. The existing scriptbind functions are listed in the reference section.


How to run scripts

Lua files

Scripts are usually stored in the Game\Scripts directory.

The scripts will have to be invoked by calling the LoadScript function from within C++ code. More information can be found TOPIC Integration Between Scripts and C++

Another workflow is creating a script entity as explained in the Structure of a Структура скрипта сущности topic.


Console

Script instructions can be executed within the in-game console. This can be done by appending the # character before the instructions.

This functionality is limited to Sandbox or running the launcher in Dev Mode (using the -DEVMODE command-line argument).


Reloading scripts during runtime

In Sandbox it's always possible to reload entities within the user interface. When selecting a Script Entity, this can be done by clicking on the Reload Script button found in the Rollup Bar.

It's also possible to use the following ScriptBind function to reload scripts.

  • Script.ReloadScript(filename)
  • Script.ReloadScripts()

Совет:
it's always possible to invoke these functions from the console. The following syntax needs to used.


  1. Script.ReloadScript("Scripts\\EntityCommon.lua"