Страница 1 из 1

Как задать имя вагона в скрипте

СообщениеДобавлено: 15.11.2008, 00:52
oleg68
В борьбе с порталами, которые переименовывают вагоны поездов, я решил модифицировать скрипт портала.

Вопрос: портал создает каждый вагон поезда с помошью вызова

Train newTrain = World.CreateTrain(currentVehicleKUID, me, "out_track0", 60.0, true);

При этом созданный вагон получает автоматически сгенерированное имя из имени класса с добавлением уникального числового индекса. Вопрос: можно ли как-нибудь создать вагон с тем именем, которое мне нужно? Или есть ли способ поменять это имя после создания вагона?

Re: Как задать имя вагона в скрипте

СообщениеДобавлено: 15.11.2008, 12:31
Combine
Код: Выделить всё
Train newTrain = World.CreateTrain(currentVehicleKUID, me, "out_track0", 60.0, true);
В АПИ нет такого вызова, с 3м парамером типа float.

По сабжу. А зачем это нужно?

Re: Как задать имя вагона в скрипте

СообщениеДобавлено: 15.11.2008, 12:44
oleg68
Combine писал(а):
Код: Выделить всё
Train newTrain = World.CreateTrain(currentVehicleKUID, me, "out_track0", 60.0, true);
В АПИ нет такого вызова, с 3м парамером типа float.

Есть. Я же не сам это придумал, а взял это из исходников объекта 'Portal'

А вот - выдержка из документации по API:

public native Train World.CreateTrain ( KUID consist[],
Buildable obj,
string trackName,
float position,
bool direction
)

Creates a train consist on the specified track of a Buildable scenery object.

Due to the nature of industry tracks being limited in size, it is advised that this method be used very carefully. You really need to know the length of the consist you are creating as well as the length and orientation of the track section as well to use this method effectively.

This method was intended to be used for purposes like creating a vehicle or two on an industry's track, not creating big consists. You could of course create a big consist if enough track is available, but that's not really what it is meant for.

Parameters:
consist An array of KUIDs of vehicles that make up the train.
obj Buildable object where track to create the train on can be found.
trackName Name of the track to create the train on.
position Position of where the consist is to be started. This is a distance in meters measured from where the track section starts.
direction Orientation of the train consist relative to the direction of the track.

Returns :
Returns a valid Train if the consist was successfully created, null otherwise.
See also:
SceneryWithTrack.GetAttachedTrack(), Industry.HasTrack()



Combine писал(а):По сабжу. А зачем это нужно?

Хотел исправить портал, чтобы он не забывал имена вагонов, которые он должен вернуть. Описание проблемы - см. в http://www.railunion.net/forum12/topic7565.html

Re: Как задать имя вагона в скрипте

СообщениеДобавлено: 15.11.2008, 21:49
agmike
это наверняка зашито где-то в дебрях натива