mtasa-blue
mtasa-blue copied to clipboard
setTrainSpeed vs getTrainSpeed
Describe the bug
When you use setTrainSpeed( ) you are able to set it to a positive or negative number.
When using getTrainSpeed( ) it will not return a negative number. When the speed is set below 0 getTrainSpeed() will only return 0.
To be able to make a train that is reversible and have all cars match the engine speed this function must return the negative value that was set to the train using setTrainSpeed( )
Steps to reproduce
create train set speed to a negative value using setTrainSpeed( ) output value using getTrainSpeed( ) to see only a 0.
Version
No response
Additional context
No response
Relevant log output
No response
Security Policy
- [X] I have read and understood the Security Policy and this issue is not security related.
Can be fixed via script for temporary. Use getTrainDirection and custom function to calculate train speed. Didn't test this, but should be work:
function getTrainSpeedCustom(train)
return (getTrainDirection(train) and -getTrainSpeed(train) or getTrainSpeed(train))
end
Can be fixed via script for temporary. Use getTrainDirection and custom function to calculate train speed. Didn't test this, but should be work:
function getTrainSpeedCustom(train) return (getTrainDirection(train) and -getTrainSpeed(train) or getTrainSpeed(train)) end
does not work and it can't in this case. getTrainDirection simply tells you what way the train is facing. setTrainSpeed(train,1) would make the train travel clockwise around the map regardless of which way the train faces. setTrainSpeed(train,-1) would make the train travel counter clockwise around the map regardless of which way the train faces.
also when the speed is set below 0 getTrainSpeed(train) only returns 0 not a positive value
So #2741 won't be right too. Does Train have gearbox with 'Reverse' shift? This will not work? https://wiki.multitheftauto.com/wiki/GetVehicleCurrentGear