INICIO Train Simulator Escenario - Actividades Limitar velocidad composicion en todo el escenario

Se ha llevado a cabo la migración total de los datos al nuevo sistema del foro, durante los próximos días se realizarán diversos trabajos internos, por ello los nuevos registros están desactivados y algunas funciones pueden presentar problemas. Rogamos disculpéis las molestias. (October 04, 2024) x

Limitar velocidad composicion en todo el escenario

Limitar velocidad composicion en todo el escenario

 
  • 0 voto(s) - 0 Media
 
obispo rojo
Senior Member
311
06-03-2014, 07:33 PM
#1
Saludos compañer@s forer@s.

He visto en algún escenario, que aunque la velocidad de la ruta sea por ejemplo de 180 km, la composicion al rebasar una velocidad determinada, pongamos 120, sale una ventana con un mensaje en el que avisa que la velocidad máxima permitida de esa composición es de 120 km/h.

Estoy preparando un escenario y por ubicación en el tiempo (año donde se realiza el escenario), me encuentro que la ruta tiene tramos de 200 km/h y por hacerlo más real, queria limitar la velocidad máxima de la composición.

Alguien me puede ayudar a realizar esta acción.

Gracias por anticipado y un cordial saludo a tod@s.

obispo rojo
06-03-2014, 07:33 PM #1

Saludos compañer@s forer@s.

He visto en algún escenario, que aunque la velocidad de la ruta sea por ejemplo de 180 km, la composicion al rebasar una velocidad determinada, pongamos 120, sale una ventana con un mensaje en el que avisa que la velocidad máxima permitida de esa composición es de 120 km/h.

Estoy preparando un escenario y por ubicación en el tiempo (año donde se realiza el escenario), me encuentro que la ruta tiene tramos de 200 km/h y por hacerlo más real, queria limitar la velocidad máxima de la composición.

Alguien me puede ayudar a realizar esta acción.

Gracias por anticipado y un cordial saludo a tod@s.


Bermudez
Posting Freak
5,321
06-03-2014, 07:38 PM
#2
Es algo complicadillo, ya que si no me equivoco, se hace mediante LUA scripting.

Un saludo. ?



Mi PC: Intel Core i5-2400 @3.10GHz - 16GB RAM @1333MHz - nVIDIA GTX 1060 6GB - 1TB SSD + 1TB HDD



[url]https://FerroSim.es[/url]
Bermudez
06-03-2014, 07:38 PM #2

Es algo complicadillo, ya que si no me equivoco, se hace mediante LUA scripting.


Un saludo. ?



Mi PC: Intel Core i5-2400 @3.10GHz - 16GB RAM @1333MHz - nVIDIA GTX 1060 6GB - 1TB SSD + 1TB HDD



[url]https://FerroSim.es[/url]

obispo rojo
Senior Member
311
06-03-2014, 07:41 PM
#3
Gracias Bermudez por la respuesta, ya me temia yo que esto no era cosa de pinchar aqui y poner numeritos.
Muy agradecido, pensaremos que poder hacer más real el escenario.
Saludos

obispo rojo
06-03-2014, 07:41 PM #3

Gracias Bermudez por la respuesta, ya me temia yo que esto no era cosa de pinchar aqui y poner numeritos.
Muy agradecido, pensaremos que poder hacer más real el escenario.
Saludos


AEC
Posting Freak
1,008
06-03-2014, 10:03 PM
#4
El amigo Francesc SV te podra ilustrar sobre el tema ya que el ya ha conseguido realizarlo. Te confirmo que es mediante script LUA.

¡Un saludo! [Smile
AEC
06-03-2014, 10:03 PM #4

El amigo Francesc SV te podra ilustrar sobre el tema ya que el ya ha conseguido realizarlo. Te confirmo que es mediante script LUA.


¡Un saludo! [Smile

el_pinchos
Posting Freak
792
06-04-2014, 08:10 AM
#5
Una vez que se sabe programar LUA, el script necesario para limitar las velocidades es bastante sencillo. Yo tengo un escenario en el Workshop de TS2014 donde utilicé un script para limitar las velocidades en dos fases, una a 25 mph y otra a 50 mph. La sección de limitación es más o menos así:

Código:

function OnEvent ( event )

if event == "inicio_25" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end
    
    if event == "fin_25" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "inicio_50" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end
    
    if event == "fin_50" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end

if event == "pasas_de_25" then -- Trigger at reached 30mph
                
        -- show html briefing '30mph Reached'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 25 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
    if event == "pasas_de_50" then -- Trigger at reached 10mph
            
        -- show html briefing 'Stopped'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 50 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
end

function TestCondition ( condition )

    if condition == "SpeedCondition1" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 11.623 then -- 25mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_25", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...
    
    if condition == "SpeedCondition2" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 22.799 then -- 50mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_50", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...    
    
end

A simple vista parece muy complicado, pero a ojos de un programador es bastante sencillo. Solo es cuestión de tener un poco de práctica en programación.

Un saludo, J.

[img]http://steamsignature.com/status/spanish...635776.png[/img]

Pulsa 'F5' para actualizar. Mi perfil completo en STEAM
el_pinchos
06-04-2014, 08:10 AM #5

Una vez que se sabe programar LUA, el script necesario para limitar las velocidades es bastante sencillo. Yo tengo un escenario en el Workshop de TS2014 donde utilicé un script para limitar las velocidades en dos fases, una a 25 mph y otra a 50 mph. La sección de limitación es más o menos así:

Código:

function OnEvent ( event )

if event == "inicio_25" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end
    
    if event == "fin_25" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "inicio_50" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end
    
    if event == "fin_50" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end

if event == "pasas_de_25" then -- Trigger at reached 30mph
                
        -- show html briefing '30mph Reached'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 25 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
    if event == "pasas_de_50" then -- Trigger at reached 10mph
            
        -- show html briefing 'Stopped'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 50 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
end

function TestCondition ( condition )

    if condition == "SpeedCondition1" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 11.623 then -- 25mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_25", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...
    
    if condition == "SpeedCondition2" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 22.799 then -- 50mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_50", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...    
    
end

A simple vista parece muy complicado, pero a ojos de un programador es bastante sencillo. Solo es cuestión de tener un poco de práctica en programación.


Un saludo, J.

[img]http://steamsignature.com/status/spanish...635776.png[/img]

Pulsa 'F5' para actualizar. Mi perfil completo en STEAM

AEC
Posting Freak
1,008
06-04-2014, 09:44 AM
#6
¿Eso va dentro de la funcion Update() o el OnEvent se declara en el editor?
Muchas gracias por compartir el trabajo, Pinchos. :ok:

¡Un saludo! [Smile
AEC
06-04-2014, 09:44 AM #6

¿Eso va dentro de la funcion Update() o el OnEvent se declara en el editor?
Muchas gracias por compartir el trabajo, Pinchos. :ok:


¡Un saludo! [Smile

el_pinchos
Posting Freak
792
06-04-2014, 09:58 AM
#7
El script de escenario funciona solo con las funciones de declaración de eventos ('OnEvent ( event ) '), y declaración de condiciones ('TestCondition ( condition )'). Los eventos se indican como 'triggers' en el editor de escenarios o se toman en el mismo script en la función de condiciones.

Los eventos 'inicio_25', 'fin_25', 'inicio_50', 'fin_50' son tomados del editor de escenarios, mientras que los nombrados 'pasas_de_25' y 'pasas_de_50' son tomados de la funciones de condiciones.

En el script de este escenario hay además eventos para cámaras cinemáticas y meteorología especial, aunque estas propiedades se definen solamente en la función de eventos y se toman de los 'triggers' del editor de escenarios:

Código:

FALSE = 0
TRUE = 1

-- condition return values
CONDITION_NOT_YET_MET = 0
CONDITION_SUCCEEDED = 1
CONDITION_FAILED = 2

-- Message types
MT_INFO = 0            -- large centre screen pop up
MT_ALERT = 1        -- top right alert message

MSG_TOP = 1
MSG_VCENTRE = 2
MSG_BOTTOM = 4
MSG_LEFT = 8
MSG_CENTRE = 16
MSG_RIGHT = 32

MSG_SMALL = 0
MSG_REG = 1
MSG_LRG = 2

------------------------------------------------
-- Fn OnEvent
--         event - name of the event
--        return - TRUE/FALSE if event handled
function OnEvent ( event )

-- Instruction triggers
---------------------------

    if event == "camera_start" then
            
        SysCall ( "CameraManager:ActivateCamera", "cam_1", 0 );
        SysCall ( "ScenarioManager:LockControls");
        return TRUE;
            
    end
    
    if event == "camera_end" then
            
        SysCall ( "CameraManager:CabCamera", 0 );
        SysCall ( "ScenarioManager:UnlockControls");
        return TRUE;
            
    end
    
    if event == "inicio_25" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end
    
    if event == "fin_25" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "inicio_50" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end
    
    if event == "fin_50" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "snow" then
    
        SysCall("WeatherController:SetCurrentWeatherEventChain", "TheStormChain");
        return TRUE;
    
    end -- if event == "StormStart"


-- Timed triggers
---------------------------
    
    if event == "pasas_de_25" then -- Trigger at reached 30mph
                
        -- show html briefing '30mph Reached'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 25 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
    if event == "pasas_de_50" then -- Trigger at reached 10mph
            
        -- show html briefing 'Stopped'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 50 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
end -- function OnEvent ( event )

------------------------------------------------
-- Fn TestCondition
--        condition - name of the condition
--        return state of the condition
function TestCondition ( condition )

    if condition == "SpeedCondition1" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 11.623 then -- 25mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_25", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...
    
    if condition == "SpeedCondition2" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 22.799 then -- 50mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_50", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...    
    
end -- function TestCondition ( condition )

Un saludo, J.

[img]http://steamsignature.com/status/spanish...635776.png[/img]

Pulsa 'F5' para actualizar. Mi perfil completo en STEAM
el_pinchos
06-04-2014, 09:58 AM #7

El script de escenario funciona solo con las funciones de declaración de eventos ('OnEvent ( event ) '), y declaración de condiciones ('TestCondition ( condition )'). Los eventos se indican como 'triggers' en el editor de escenarios o se toman en el mismo script en la función de condiciones.

Los eventos 'inicio_25', 'fin_25', 'inicio_50', 'fin_50' son tomados del editor de escenarios, mientras que los nombrados 'pasas_de_25' y 'pasas_de_50' son tomados de la funciones de condiciones.

En el script de este escenario hay además eventos para cámaras cinemáticas y meteorología especial, aunque estas propiedades se definen solamente en la función de eventos y se toman de los 'triggers' del editor de escenarios:

Código:

FALSE = 0
TRUE = 1

-- condition return values
CONDITION_NOT_YET_MET = 0
CONDITION_SUCCEEDED = 1
CONDITION_FAILED = 2

-- Message types
MT_INFO = 0            -- large centre screen pop up
MT_ALERT = 1        -- top right alert message

MSG_TOP = 1
MSG_VCENTRE = 2
MSG_BOTTOM = 4
MSG_LEFT = 8
MSG_CENTRE = 16
MSG_RIGHT = 32

MSG_SMALL = 0
MSG_REG = 1
MSG_LRG = 2

------------------------------------------------
-- Fn OnEvent
--         event - name of the event
--        return - TRUE/FALSE if event handled
function OnEvent ( event )

-- Instruction triggers
---------------------------

    if event == "camera_start" then
            
        SysCall ( "CameraManager:ActivateCamera", "cam_1", 0 );
        SysCall ( "ScenarioManager:LockControls");
        return TRUE;
            
    end
    
    if event == "camera_end" then
            
        SysCall ( "CameraManager:CabCamera", 0 );
        SysCall ( "ScenarioManager:UnlockControls");
        return TRUE;
            
    end
    
    if event == "inicio_25" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end
    
    if event == "fin_25" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "inicio_50" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end
    
    if event == "fin_50" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "snow" then
    
        SysCall("WeatherController:SetCurrentWeatherEventChain", "TheStormChain");
        return TRUE;
    
    end -- if event == "StormStart"


-- Timed triggers
---------------------------
    
    if event == "pasas_de_25" then -- Trigger at reached 30mph
                
        -- show html briefing '30mph Reached'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 25 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
    if event == "pasas_de_50" then -- Trigger at reached 10mph
            
        -- show html briefing 'Stopped'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 50 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
end -- function OnEvent ( event )

------------------------------------------------
-- Fn TestCondition
--        condition - name of the condition
--        return state of the condition
function TestCondition ( condition )

    if condition == "SpeedCondition1" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 11.623 then -- 25mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_25", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...
    
    if condition == "SpeedCondition2" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 22.799 then -- 50mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_50", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...    
    
end -- function TestCondition ( condition )


Un saludo, J.

[img]http://steamsignature.com/status/spanish...635776.png[/img]

Pulsa 'F5' para actualizar. Mi perfil completo en STEAM

AEC
Posting Freak
1,008
06-04-2014, 11:49 AM
#8
el_pinchos El script de escenario funciona solo con las funciones de declaración de eventos ('OnEvent ( event ) '), y declaración de condiciones ('TestCondition ( condition )'). Los eventos se indican como 'triggers' en el editor de escenarios o se toman en el mismo script en la función de condiciones.

Los eventos 'inicio_25', 'fin_25', 'inicio_50', 'fin_50' son tomados del editor de escenarios, mientras que los nombrados 'pasas_de_25' y 'pasas_de_50' son tomados de la funciones de condiciones.

En el script de este escenario hay además eventos para cámaras cinemáticas y meteorología especial, aunque estas propiedades se definen solamente en la función de eventos y se toman de los 'triggers' del editor de escenarios:

Código:

FALSE = 0
TRUE = 1

-- condition return values
CONDITION_NOT_YET_MET = 0
CONDITION_SUCCEEDED = 1
CONDITION_FAILED = 2

-- Message types
MT_INFO = 0            -- large centre screen pop up
MT_ALERT = 1        -- top right alert message

MSG_TOP = 1
MSG_VCENTRE = 2
MSG_BOTTOM = 4
MSG_LEFT = 8
MSG_CENTRE = 16
MSG_RIGHT = 32

MSG_SMALL = 0
MSG_REG = 1
MSG_LRG = 2

------------------------------------------------
-- Fn OnEvent
--         event - name of the event
--        return - TRUE/FALSE if event handled
function OnEvent ( event )

-- Instruction triggers
---------------------------

    if event == "camera_start" then
            
        SysCall ( "CameraManager:ActivateCamera", "cam_1", 0 );
        SysCall ( "ScenarioManager:LockControls");
        return TRUE;
            
    end
    
    if event == "camera_end" then
            
        SysCall ( "CameraManager:CabCamera", 0 );
        SysCall ( "ScenarioManager:UnlockControls");
        return TRUE;
            
    end
    
    if event == "inicio_25" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end
    
    if event == "fin_25" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "inicio_50" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end
    
    if event == "fin_50" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "snow" then
    
        SysCall("WeatherController:SetCurrentWeatherEventChain", "TheStormChain");
        return TRUE;
    
    end -- if event == "StormStart"


-- Timed triggers
---------------------------
    
    if event == "pasas_de_25" then -- Trigger at reached 30mph
                
        -- show html briefing '30mph Reached'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 25 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
    if event == "pasas_de_50" then -- Trigger at reached 10mph
            
        -- show html briefing 'Stopped'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 50 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
end -- function OnEvent ( event )

------------------------------------------------
-- Fn TestCondition
--        condition - name of the condition
--        return state of the condition
function TestCondition ( condition )

    if condition == "SpeedCondition1" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 11.623 then -- 25mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_25", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...
    
    if condition == "SpeedCondition2" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 22.799 then -- 50mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_50", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...    
    
end -- function TestCondition ( condition )
De acuerdo, muchisimas gracias. :maestro: Yo de momento solo me habia mirado los scripts del material rodante.
Igual que me he fijado que aqui escribes SysCall y no simplemente Call como en los trenes.

¡Un saludo! [Smile
AEC
06-04-2014, 11:49 AM #8

el_pinchos El script de escenario funciona solo con las funciones de declaración de eventos ('OnEvent ( event ) '), y declaración de condiciones ('TestCondition ( condition )'). Los eventos se indican como 'triggers' en el editor de escenarios o se toman en el mismo script en la función de condiciones.

Los eventos 'inicio_25', 'fin_25', 'inicio_50', 'fin_50' son tomados del editor de escenarios, mientras que los nombrados 'pasas_de_25' y 'pasas_de_50' son tomados de la funciones de condiciones.

En el script de este escenario hay además eventos para cámaras cinemáticas y meteorología especial, aunque estas propiedades se definen solamente en la función de eventos y se toman de los 'triggers' del editor de escenarios:

Código:

FALSE = 0
TRUE = 1

-- condition return values
CONDITION_NOT_YET_MET = 0
CONDITION_SUCCEEDED = 1
CONDITION_FAILED = 2

-- Message types
MT_INFO = 0            -- large centre screen pop up
MT_ALERT = 1        -- top right alert message

MSG_TOP = 1
MSG_VCENTRE = 2
MSG_BOTTOM = 4
MSG_LEFT = 8
MSG_CENTRE = 16
MSG_RIGHT = 32

MSG_SMALL = 0
MSG_REG = 1
MSG_LRG = 2

------------------------------------------------
-- Fn OnEvent
--         event - name of the event
--        return - TRUE/FALSE if event handled
function OnEvent ( event )

-- Instruction triggers
---------------------------

    if event == "camera_start" then
            
        SysCall ( "CameraManager:ActivateCamera", "cam_1", 0 );
        SysCall ( "ScenarioManager:LockControls");
        return TRUE;
            
    end
    
    if event == "camera_end" then
            
        SysCall ( "CameraManager:CabCamera", 0 );
        SysCall ( "ScenarioManager:UnlockControls");
        return TRUE;
            
    end
    
    if event == "inicio_25" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end
    
    if event == "fin_25" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition1" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "inicio_50" then
    
        SysCall ( "ScenarioManager:BeginConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end
    
    if event == "fin_50" then
    
        SysCall ( "ScenarioManager:EndConditionCheck", "SpeedCondition2" );
        
        return TRUE;
        
    end -- if event...
    
    if event == "snow" then
    
        SysCall("WeatherController:SetCurrentWeatherEventChain", "TheStormChain");
        return TRUE;
    
    end -- if event == "StormStart"


-- Timed triggers
---------------------------
    
    if event == "pasas_de_25" then -- Trigger at reached 30mph
                
        -- show html briefing '30mph Reached'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 25 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
    if event == "pasas_de_50" then -- Trigger at reached 10mph
            
        -- show html briefing 'Stopped'
        SysCall ( "ScenarioManager:ShowMessage", "Penalty Brake. Remember: max speed permited is 50 MPH" );
        SysCall ( "PlayerEngine:SetControlValue", "Regulator", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "Reverser", 0, 0.0);
        SysCall ( "PlayerEngine:SetControlValue", "TrainBrakeControl", 0, 1.0);
        --return TRUE;
            
    end -- if event == "SpeedReached" then
    
end -- function OnEvent ( event )

------------------------------------------------
-- Fn TestCondition
--        condition - name of the condition
--        return state of the condition
function TestCondition ( condition )

    if condition == "SpeedCondition1" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 11.623 then -- 25mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_25", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...
    
    if condition == "SpeedCondition2" then
    
        speed = SysCall ( "PlayerEngine:GetSpeed" );
        
        if speed > 22.799 then -- 50mph
        
            SysCall ( "ScenarioManager:TriggerDeferredEvent", "pasas_de_50", 0.1 );
            return CONDITION_NOT_YET_MET;
        
        end -- if speed...
    
    end -- if condition...    
    
end -- function TestCondition ( condition )
De acuerdo, muchisimas gracias. :maestro: Yo de momento solo me habia mirado los scripts del material rodante.
Igual que me he fijado que aqui escribes SysCall y no simplemente Call como en los trenes.


¡Un saludo! [Smile

obispo rojo
Senior Member
311
06-04-2014, 03:25 PM
#9
Estimados compañeros.

Solo daros las gracias por estas respuestas, que a un "aprendiz" como yo, le animan a enciscarme en esto de los escenarios.

Os pondria miles de [Smile y otros miles de :maestro: porque sois verdaderos genios.

De verdad, muchisimas gracias, creo que vuestros comentarios ayudaran a muchos creadores.

Un cordial saludo.

Obispo Rojo

obispo rojo
06-04-2014, 03:25 PM #9

Estimados compañeros.

Solo daros las gracias por estas respuestas, que a un "aprendiz" como yo, le animan a enciscarme en esto de los escenarios.

Os pondria miles de [Smile y otros miles de :maestro: porque sois verdaderos genios.

De verdad, muchisimas gracias, creo que vuestros comentarios ayudaran a muchos creadores.

Un cordial saludo.

Obispo Rojo


 
  • 0 voto(s) - 0 Media
Usuarios navegando en este tema:
 1 invitado(s)
Usuarios navegando en este tema:
 1 invitado(s)