Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- importPackage(Packages.jp.ngt.rtm);
- importPackage(Packages.jp.ngt.rtm.render);
- importPackage(Packages.jp.ngt.rtm.entity.train.util);
- importPackage(Packages.jp.ngt.ngtlib.util);
- importPackage(Packages.jp.ngt.rtm.sound);
- importPackage(Packages.jp.ngt.ngtlib.io);
- function onUpdate(su) {
- updateSoundMaker(su);
- updateSoundEffects(su);
- }
- /*
- ## RTM Sound Maker ##
- Version 1.0
- Copyright (c) 2021 hi03
- This software is released under the MIT License.
- http://opensource.org/licenses/mit-license.php
- */
- //Input data
- var Dmain = 'sound_baru';
- var SoundMap = {"2100_00":"train.2100_00","2100_01":"train.2100_01","2100_02":"train.2100_02","2100_03":"train.2100_03","2100_03b":"train.2100_03b","2100_04":"train.2100_04","2100_05":"train.2100_05","2100_06":"train.2100_06","2100_07":"train.2100_07","2100_08":"train.2100_08","2100_09":"train.2100_09","2100_10":"train.2100_10","2100_11":"train.2100_11","2100_12":"train.2100_12","2100_13":"train.2100_13","2100_run01":"train.2100_run01","2100_run02":"train.2100_run02","2100_run03":"train.2100_run03","2100_14":"train.2100_14","2100_15":"train.2100_15","2100_16":"train.2100_16","2100_17":"train.2100_17","2100_18":"train.2100_18","2100_19":"train.2100_19","2100_20":"train.2100_20"};
- var SoundData = [{"soundName":"2100_00","pitchData":[[{"speed":3,"value":0.5,"func":"1"},null,{"speed":28,"value":0.5,"func":"1"},null,null,null,null],[],[{"speed":0,"value":0.5,"func":"1"},null,{"speed":19,"value":0.5,"func":"1"},null]],"volumeData":[[{"speed":3,"value":0,"func":"0"},{"speed":7,"value":0.6,"func":"0.6"},{"speed":28,"value":0,"func":"0"},null,null,null,null,null,null,null],[],[{"speed":0,"value":0,"func":"0"},{"speed":3,"value":1,"func":"1"},{"speed":5,"value":1,"func":"1"},{"speed":19,"value":0,"func":"0"},null,null,null]]},{"soundName":"2100_01","pitchData":[[{"speed":3,"value":0.5,"func":"1"},null,{"speed":28,"value":0.5,"func":"1"},null],[],[{"speed":3,"value":0.5,"func":"1"},null,{"speed":25,"value":0.5,"func":"1"}]],"volumeData":[[{"speed":3,"value":0,"func":"0"},{"speed":27.9,"value":0.8,"func":"0.8"},{"speed":28,"value":0,"func":"0"},null,null,null,null,null,null,null],[],[{"speed":3,"value":0,"func":"0"},{"speed":17,"value":1,"func":"1"},{"speed":24.9,"value":1,"func":"1"},{"speed":25,"value":0,"func":"0"},null,null]]},{"soundName":"2100_02","pitchData":[[null,{"speed":5,"value":0.385,"func":"0.1555*x+0"},{"speed":12,"value":0.93,"func":"0.1555*x+0"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],[],[null,{"speed":5,"value":0.385,"func":"0.1555*x+0"},{"speed":12,"value":0.93,"func":"0.1555*x+0"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]],"volumeData":[[{"speed":5,"value":0,"func":"0"},{"speed":7,"value":1,"func":"1"},{"speed":8,"value":0.3,"func":"0.3"},{"speed":12,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":5,"value":0,"func":"0"},{"speed":7,"value":1,"func":"1"},{"speed":8,"value":0.3,"func":"0.3"},{"speed":12,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]]},{"soundName":"2100_03","pitchData":[[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":2,"value":0.33,"func":"0.3333*x+0"},{"speed":4.2,"value":0.695,"func":"0.3333*x+0"},{"speed":4.3,"value":0.395,"func":"0.1851*x+0"},{"speed":7,"value":0.645,"func":"0.1851*x+0"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]],"volumeData":[[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":2,"value":0,"func":"0"},{"speed":3.5,"value":0.6,"func":"0.6"},{"speed":4.2,"value":0,"func":"0"},{"speed":4.3,"value":0,"func":"0"},{"speed":5.5,"value":0.5,"func":"0.5"},{"speed":7,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]]},{"soundName":"2100_03b","pitchData":[[null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":3,"value":0.375,"func":"0.25*x+0"},{"speed":6,"value":0.75,"func":"0.25*x+0"},null,null,null,null,null,null,null,null,null]],"volumeData":[[null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":3,"value":0,"func":"0"},{"speed":4,"value":0.5,"func":"0.5"},{"speed":6,"value":0,"func":"0"},null,null,null,null,null,null,null,null]]},{"soundName":"2100_04","pitchData":[[{"speed":9,"value":0.36,"func":"0.0806*x+0"},{"speed":24,"value":0.965,"func":"0.0806*x+0"},null,null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":9,"value":0.36,"func":"0.0806*x+0"},{"speed":24,"value":0.965,"func":"0.0806*x+0"},null,null,null,null,null,null,null,null,null,null,null,null]],"volumeData":[[{"speed":9,"value":0,"func":"0"},{"speed":15,"value":1,"func":"1"},{"speed":24,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":9,"value":0,"func":"0"},{"speed":15,"value":1,"func":"1"},{"speed":24,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]]},{"soundName":"2100_05","pitchData":[[null,{"speed":6.5,"value":0.26,"func":"0.0806*x+0"},{"speed":16,"value":0.64,"func":"0.0806*x+0"},null,null,null,null,null,null,null,null],[],[null,{"speed":6.5,"value":0.26,"func":"0.0806*x+0"},{"speed":16,"value":0.64,"func":"0.0806*x+0"},null,null,null,null,null,null,null,null]],"volumeData":[[null,{"speed":6.5,"value":0,"func":"0"},{"speed":10,"value":1,"func":"1"},{"speed":16,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null,null,null,null],[],[null,{"speed":6.5,"value":0,"func":"0"},{"speed":10,"value":1,"func":"1"},{"speed":16,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null,null,null,null]]},{"soundName":"2100_06","pitchData":[[null,null,null,null,null,null,null,null],[],[{"speed":14,"value":0.31,"func":"0.0444*x+0"},{"speed":26,"value":0.575,"func":"0.0444*x+0"},null,null,null,null]],"volumeData":[[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":14,"value":0,"func":"0"},{"speed":23,"value":1,"func":"1"},{"speed":24.9,"value":1,"func":"1"},{"speed":26,"value":0,"func":"0"},null,null,null,null,null,null,null]]},{"soundName":"2100_07","pitchData":[[null,null,null],[],[{"speed":24.9,"value":0.48,"func":"0.0389*x+0"},{"speed":36,"value":0.7,"func":"0.0389*x+0"},null]],"volumeData":[[null,null,null,null,null,null,null,null],[],[{"speed":24.9,"value":0,"func":"0"},{"speed":25,"value":1,"func":"1"},{"speed":30,"value":1,"func":"1"},{"speed":36,"value":0,"func":"0"},null,null,null,null]]},{"soundName":"2100_08","pitchData":[[null,null,null,null],[],[{"speed":24.9,"value":0.48,"func":"0.0389*x+0"},{"speed":40,"value":0.775,"func":"0.0389*x+0"},null,null]],"volumeData":[[null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":24.9,"value":0,"func":"0"},{"speed":25,"value":1,"func":"1"},{"speed":26,"value":1,"func":"1"},{"speed":27,"value":0.4,"func":"0.4"},{"speed":30,"value":0.6,"func":"0.6"},{"speed":31,"value":0.2,"func":"0.2"},{"speed":40,"value":0,"func":"0"},null,null,null,null]]},{"soundName":"2100_09","pitchData":[[null,null,null,null,null],[],[{"speed":28,"value":0.355,"func":"0.0256*x+0"},{"speed":53,"value":0.675,"func":"0.0256*x+0"},null]],"volumeData":[[null,null,null,null,null,null,null,null,null,null,null,null,null],[],[{"speed":28,"value":0,"func":"0"},{"speed":34,"value":1,"func":"1"},{"speed":43,"value":1,"func":"1"},{"speed":53,"value":0,"func":"0"},null,null,null,null]]},{"soundName":"2100_10","pitchData":[[null,null,null,null,null,null,null,null],[],[{"speed":40,"value":0.4,"func":"0.02*x+0"},{"speed":70,"value":0.7,"func":"0.02*x+0"},null,null,null,null,null,null]],"volumeData":[[null,null,null,null,null,null,null,null,null],[],[{"speed":40,"value":0,"func":"0"},{"speed":50,"value":1,"func":"1"},{"speed":60,"value":1,"func":"1"},{"speed":70,"value":0,"func":"0"},null,null,null,null,null]]},{"soundName":"2100_11","pitchData":[[{"speed":57,"value":0.42,"func":"0.0149*x+0"},{"speed":90,"value":0.67,"func":"0.0149*x+0"}],[],[{"speed":57,"value":0.42,"func":"0.0149*x+0"},{"speed":90,"value":0.67,"func":"0.0149*x+0"}]],"volumeData":[[{"speed":57,"value":0,"func":"0"},{"speed":67,"value":1,"func":"1"},{"speed":80,"value":1,"func":"1"},{"speed":90,"value":0,"func":"0"},null,null],[],[{"speed":57,"value":0,"func":"0"},{"speed":67,"value":1,"func":"1"},{"speed":80,"value":1,"func":"1"},{"speed":90,"value":0,"func":"0"},null,null]]},{"soundName":"2100_12","pitchData":[[{"speed":77,"value":0.435,"func":"0.0113*x+0"},{"speed":110,"value":0.62,"func":"0.0113*x+0"}],[],[{"speed":77,"value":0.435,"func":"0.0113*x+0"},{"speed":110,"value":0.62,"func":"0.0113*x+0"}]],"volumeData":[[{"speed":77,"value":0,"func":"0"},{"speed":87,"value":1,"func":"1"},{"speed":100,"value":1,"func":"1"},{"speed":110,"value":0,"func":"0"},null],[],[{"speed":77,"value":0,"func":"0"},{"speed":87,"value":1,"func":"1"},{"speed":100,"value":1,"func":"1"},{"speed":110,"value":0,"func":"0"},null]]},{"soundName":"2100_13","pitchData":[[{"speed":97,"value":0.46,"func":"0.0095*x+0"},{"speed":130,"value":0.615,"func":"0.0095*x+0"}],[],[{"speed":97,"value":0.46,"func":"0.0095*x+0"},{"speed":130,"value":0.615,"func":"0.0095*x+0"}]],"volumeData":[[{"speed":97,"value":0,"func":"0"},{"speed":107,"value":1,"func":"1"},{"speed":120,"value":1,"func":"1"},{"speed":130,"value":0,"func":"0"}],[],[{"speed":97,"value":0,"func":"0"},{"speed":107,"value":1,"func":"1"},{"speed":120,"value":1,"func":"1"},{"speed":130,"value":0,"func":"0"}]]},{"soundName":"2100_run01","pitchData":[[{"speed":61,"value":0.28,"func":"0.0093*x+0"},{"speed":130,"value":0.6,"func":"0.0093*x+0"}],[{"speed":61,"value":0.28,"func":"0.0093*x+0"},{"speed":130,"value":0.6,"func":"0.0093*x+0"}],[{"speed":61,"value":0.28,"func":"0.0093*x+0"},{"speed":130,"value":0.6,"func":"0.0093*x+0"}]],"volumeData":[[{"speed":61,"value":0,"func":"0"},{"speed":85,"value":0.79,"func":"0.79"},{"speed":107.5,"value":1,"func":"1"},{"speed":120,"value":1,"func":"1"},{"speed":130,"value":0,"func":"0"}],[{"speed":61,"value":0,"func":"0"},{"speed":85,"value":0.79,"func":"0.79"},{"speed":107.5,"value":1,"func":"1"},{"speed":120,"value":1,"func":"1"},{"speed":130,"value":0,"func":"0"}],[{"speed":61,"value":0,"func":"0"},{"speed":85,"value":0.79,"func":"0.79"},{"speed":107.5,"value":1,"func":"1"},{"speed":120,"value":1,"func":"1"},{"speed":130,"value":0,"func":"0"}]]},{"soundName":"2100_run02","pitchData":[[{"speed":34,"value":0.25,"func":"0.0149*x+0"},{"speed":90,"value":0.67,"func":"0.0149*x+0"}],[{"speed":34,"value":0.25,"func":"0.0149*x+0"},{"speed":90,"value":0.67,"func":"0.0149*x+0"}],[{"speed":34,"value":0.25,"func":"0.0149*x+0"},{"speed":90,"value":0.67,"func":"0.0149*x+0"}]],"volumeData":[[{"speed":34,"value":0,"func":"0"},{"speed":53,"value":0.8,"func":"0.8"},{"speed":66,"value":1,"func":"1"},{"speed":90,"value":0,"func":"0"}],[{"speed":34,"value":0,"func":"0"},{"speed":53,"value":0.8,"func":"0.8"},{"speed":66,"value":1,"func":"1"},{"speed":90,"value":0,"func":"0"}],[{"speed":34,"value":0,"func":"0"},{"speed":53,"value":0.8,"func":"0.8"},{"speed":66,"value":1,"func":"1"},{"speed":90,"value":0,"func":"0"}]]},{"soundName":"2100_run03","pitchData":[[{"speed":0,"value":0.25,"func":"0.5"},{"speed":20,"value":0.25,"func":"0.5"},{"speed":56,"value":0.7,"func":"0.025*x+0"}],[{"speed":0,"value":0.25,"func":"0.5"},{"speed":20,"value":0.25,"func":"0.5"},{"speed":56,"value":0.7,"func":"0.025*x+0"}],[{"speed":0,"value":0.25,"func":"0.5"},{"speed":20,"value":0.25,"func":"0.5"},{"speed":56,"value":0.7,"func":"0.025*x+0"}]],"volumeData":[[{"speed":0,"value":0,"func":"0"},{"speed":36,"value":1,"func":"1"},{"speed":56,"value":0,"func":"0"}],[{"speed":0,"value":0,"func":"0"},{"speed":36,"value":1,"func":"1"},{"speed":56,"value":0,"func":"0"}],[{"speed":0,"value":0,"func":"0"},{"speed":36,"value":1,"func":"1"},{"speed":56,"value":0,"func":"0"}]]},{"soundName":"2100_14","pitchData":[[null,{"speed":36,"value":0.525,"func":"1.05"},{"speed":40,"value":0.525,"func":"1.05"},null,null,null,null,null,null],[],[{"speed":32,"value":0.5,"func":"1"},null,{"speed":36,"value":0.5,"func":"1"},null,null,null,null,null,null,null,null]],"volumeData":[[null,{"speed":36,"value":0,"func":"0"},{"speed":38,"value":1,"func":"1"},{"speed":40,"value":0,"func":"0"},null,null,null,null,null,null,null],[],[{"speed":32,"value":0,"func":"0"},{"speed":34,"value":1,"func":"1"},{"speed":36,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null,null,null]]},{"soundName":"2100_15","pitchData":[[{"speed":46,"value":0.38,"func":"0.0166*x+0"},{"speed":70,"value":0.58,"func":"0.0166*x+0"},null,null,null,null,null,null],[],[]],"volumeData":[[{"speed":46,"value":0,"func":"0"},{"speed":56,"value":1,"func":"1"},{"speed":60,"value":1,"func":"1"},{"speed":70,"value":0,"func":"0"},null,null,null,null,null,null,null,null],[],[]]},{"soundName":"2100_16","pitchData":[[null,{"speed":40,"value":0.405,"func":"0.0204*x+0"},{"speed":58,"value":0.59,"func":"0.0204*x+0"},null],[],[]],"volumeData":[[null,{"speed":40,"value":0,"func":"0"},{"speed":45,"value":1,"func":"1"},{"speed":48,"value":1,"func":"1"},{"speed":58,"value":0,"func":"0"}],[],[]]},{"soundName":"2100_17","pitchData":[[{"speed":30,"value":0.375,"func":"0.0253*x+0"},{"speed":47,"value":0.59,"func":"0.0253*x+0"}],[],[]],"volumeData":[[{"speed":30,"value":0,"func":"0"},{"speed":40,"value":1,"func":"1"},{"speed":42,"value":1,"func":"1"},{"speed":47,"value":0,"func":"0"},null],[],[]]},{"soundName":"2100_18","pitchData":[[null,{"speed":27.9,"value":0.445,"func":"0.0322*x+0"},{"speed":42,"value":0.675,"func":"0.0322*x+0"}],[],[]],"volumeData":[[{"speed":27.9,"value":0,"func":"0"},{"speed":28,"value":1,"func":"1"},{"speed":32,"value":1,"func":"1"},{"speed":42,"value":0,"func":"0"},null,null],[],[]]},{"soundName":"2100_19","pitchData":[[{"speed":13,"value":0.28,"func":"0.0434*x+0"},{"speed":29,"value":0.625,"func":"0.0434*x+0"},null],[],[]],"volumeData":[[{"speed":13,"value":0,"func":"0"},{"speed":23,"value":1,"func":"1"},{"speed":27.9,"value":1,"func":"1"},{"speed":29,"value":0,"func":"0"},null],[],[]]},{"soundName":"2100_20","pitchData":[[{"speed":38,"value":0.48,"func":"0.0253*x+0"},{"speed":47,"value":0.59,"func":"0.0253*x+0"},null,null,null,null],[],[]],"volumeData":[[{"speed":38,"value":0,"func":"0"},{"speed":44.5,"value":0.5,"func":"0.5"},{"speed":47,"value":0,"func":"0"},null,null,null,null,null,null,null,null,null],[],[]]}];
- //Input data <END>
- var delayTick = 6;
- var fadeTick = 4;
- function updateSoundMaker(su) {
- var entity = su.getEntity();
- var dataMap = entity.getResourceState().getDataMap();
- var speed = su.getSpeed();
- var notch = su.getNotch();
- var notchIndex = 0;
- if (notch === 0) notchIndex = 1;
- if (notch > 0) notchIndex = 2;
- var fadeCnt = dataMap.getInt("fadeCnt");
- if (notchIndex != 1 && fadeCnt < delayTick + fadeTick) fadeCnt ++;
- if (notchIndex == 1 && fadeCnt > 0) fadeCnt --;
- dataMap.setInt("fadeCnt", fadeCnt, 0);
- if((notchIndex != 1 && fadeCnt == delayTick + fadeTick) || (notchIndex == 1 && fadeCnt == 0)) dataMap.setInt("notchIndexF", notchIndex, 0);
- var notchIndexF = dataMap.getInt("notchIndexF");
- var pitData = [];
- var volData = [];
- var soundNameList = [];
- SoundData.forEach(function (layer) {
- soundNameList.push(layer.soundName);
- pitData.push(layer.pitchData);
- volData.push(layer.volumeData);
- });
- soundNameList.forEach(function (name, layerIndex) {
- var pitch = notchIndexF == 1 ? getValue(pitData[layerIndex], speed, notchIndex) * 2 : getValue(pitData[layerIndex], speed, notchIndexF) * 2;
- var volume = 0.0;
- if(fadeCnt > 0 && fadeCnt < delayTick + fadeTick){
- var volN = getValue(volData[layerIndex], speed, 1);
- var volM = notchIndexF == 1 ? getValue(volData[layerIndex], speed, notchIndex) : getValue(volData[layerIndex], speed, notchIndexF);
- if(notchIndex != 1) volume = fadeCnt < delayTick ? volN : (volN * (delayTick + fadeTick - fadeCnt) + volM * (fadeCnt - delayTick)) / fadeTick;
- else volume = fadeCnt > fadeTick ? volM : (volN * (fadeTick - fadeCnt) + volM * fadeCnt) / fadeTick;
- }else{
- volume = getValue(volData[layerIndex], speed, notchIndexF);
- }
- su.playSound(Dmain, SoundMap[name], volume, pitch, true);
- });
- }
- function getValue(data, speed, notchIndex) {//pitchData or volumeData
- var points = data[notchIndex];
- var currentPoint = null;
- var nextPoint = null;
- var value = 0;
- for(var i = 0; i < points.length; i++){
- currentPoint = points[i];
- if (!currentPoint) continue;
- if (i < points.length) nextPoint = points[i + 1];
- if (!nextPoint) {
- value = currentPoint.value;
- break;
- }
- if (currentPoint.speed <= speed && speed <= nextPoint.speed) {
- var x1 = currentPoint.speed;
- var y1 = currentPoint.value;
- var x2 = nextPoint.speed;
- var y2 = nextPoint.value;
- var a = ((y2 - y1) / (x2 - x1));
- var b = ((x2 * y1 - x1 * y2) / (x2 - x1));
- var r = a * speed + b;
- if (r > 1.0) r = 1.0;
- if (r < 0.0) r = 0.0;
- value = r;
- break;
- }
- }
- return value;
- }
- //RTM Sound Maker <END>
- var releaseTick = 7;
- function updateSoundEffects(su){
- var entity = su.getEntity();
- var dataMap = entity.getResourceState().getDataMap();
- var speed = su.getSpeed();
- var releaseNotch = dataMap.getInt("releaseNotch");
- var tickCnt = dataMap.getInt("tickCnt");
- var prevNotch = dataMap.getInt("prevNotch");
- var prevDoorState = dataMap.getInt("prevDoorState");
- var notch = 0;
- if(entity != null) notch = entity.getNotch();
- try {
- var doorState = entity.getVehicleState(TrainState.getStateType(4));
- }
- catch(e){
- var doorState = entity.getTrainStateData(4);
- }
- if((doorState == 1 && prevDoorState == 0) || (doorState == 3 && prevDoorState == 2)){
- su.stopSound('sound_baru', 'train.2100_door_cls_l');
- su.stopSound('sound_baru', 'train.2100_door_opn_l');
- su.playSound('sound_baru', 'train.2100_door_opn_l', 1.0, 1.0, false);
- }
- if((doorState == 0 && prevDoorState == 1) || (doorState == 2 && prevDoorState == 3)){
- su.stopSound('sound_baru', 'train.2100_door_opn_l');
- su.stopSound('sound_baru', 'train.2100_door_cls_l');
- su.playSound('sound_baru', 'train.2100_door_cls_l', 1.0, 1.0, false);
- }
- if((doorState == 2 && prevDoorState == 0) || (doorState == 3 && prevDoorState == 1)){
- su.stopSound('sound_baru', 'train.2100_door_cls_r');
- su.stopSound('sound_baru', 'train.2100_door_opn_r');
- su.playSound('sound_baru', 'train.2100_door_opn_r', 1.0, 1.0, false);
- }
- if((doorState == 0 && prevDoorState == 2) || (doorState == 1 && prevDoorState == 3)){
- su.stopSound('sound_baru', 'train.2100_door_opn_r');
- su.stopSound('sound_baru', 'train.2100_door_cls_r');
- su.playSound('sound_baru', 'train.2100_door_cls_r', 1.0, 1.0, false);
- }
- if(speed < 3.0){
- if(notch > prevNotch && prevNotch < 0){
- if(tickCnt == 0) releaseNotch = notch;
- tickCnt = 1;
- }
- }
- if(tickCnt != 0 && tickCnt <= releaseTick){
- tickCnt++;
- }else if(tickCnt == releaseTick + 1){
- su.stopSound('sound_baru', 'train.2100_air00');
- su.stopSound('sound_baru', 'train.2100_air01');
- su.stopSound('sound_baru', 'train.2100_air02');
- if(notch >= 0){
- if(releaseNotch < -3){
- su.playSound('sound_baru', 'train.2100_air02', 1.0, 1.0, false);
- }else{
- su.playSound('sound_baru', 'train.2100_air00', 1.0, 1.0, false);
- }
- }else if(notch - releaseNotch > 2){
- su.playSound('sound_baru', 'train.2100_air02', 1.0, 1.0, false);
- }else{
- su.playSound('sound_baru', 'train.2100_air01', 1.0, 1.0, false);
- }
- tickCnt = 0;
- }
- su.playSound('sound_baru', 'train.cooler', 1.0, 1.0, true);
- dataMap.setInt("releaseNotch", releaseNotch, 0);
- dataMap.setInt("tickCnt", tickCnt, 0);
- dataMap.setInt("prevNotch", notch, 0);
- dataMap.setInt("prevDoorState", doorState, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement