Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cStation::InitNewStation(stationID)
- // Create a station object depending on station type. Add the station to base and return the station object or null on error.
- {
- if (!AIStation.IsValidStation(stationID))
- {
- DError("Station #"+stationID+" doesn't exist");
- return null;
- }
- local _StationType = cStation.FindStationType(stationID);
- if (_StationType == -1) { DError("Couldn't determine station type use by station #"+stationID); return null; }
- local _Location = AIStation.GetLocation(stationID);
- local _station = null;
- print(_station);
- switch (_StationType)
- {
- case AIStation.STATION_TRAIN:
- _station = cStationRail();
- _station.s_SubType = AIRail.GetRailType(_Location); // set rail type the station use
- _station.s_MaxSize = INSTANCE.main.carrier.rail_max;
- for (local zz=0; zz < 23; zz++) _station.s_TrainSpecs.AddItem(zz,-1); // create special cases for train usage
- for (local zz=7; zz < 11; zz++) _station.s_TrainSpecs.SetValue(zz,0);
- _station.s_TrainSpecs.SetValue(0,1+2); // enable IN && OUT for the new station
- _station.s_Tiles = cTileTools.FindStationTiles(_Location);
- _station.s_Radius = AIStation.GetCoverageRadius(_StationType);
- _station.GetRailStationMiscInfo();
- break;
- case AIStation.STATION_DOCK: // TODO: do boat
- _station = cStationWater();
- break;
- case AIStation.STATION_BUS_STOP:
- print("bus");
- case AIStation.STATION_TRUCK_STOP:
- print("truck");
- print("station ? "+_station);
- _station = cStationRoad();
- //_station = "hell";
- print("station ? "+_station);
- _station.s_MaxSize = INSTANCE.main.carrier.road_max;
- _station.s_Tiles = cTileTools.FindStationTiles(_Location);
- _station.s_Size = _station.s_Tiles.Count();
- _station.s_SubType = AIRoad.ROADTYPE_ROAD;
- if (AIRoad.HasRoadType(_Location, AIRoad.ROADTYPE_TRAM)) _station.s_SubType = AIRoad.ROADTYPE_TRAM;
- print("ailist="+(_station.s_Tiles instanceof AIList));
- print("s_tile="+_station.s_Tiles+" empty="+_station.s_Tiles.IsEmpty());
- // foreach (loc, _dummy in _station.s_Tiles) { _station.s_Tiles.SetValue(loc, AIRoad.GetRoadStationFrontTile(loc)); } // keeping it comment
- local grrr = AIList();
- grrr.AddList(_station.s_Tiles);
- foreach (_stupidloc, _stupiddummy in grrr) { print("trigger bug"); } // commenting out this line it stop at bugme(), but if i kept it uncomment, it stop at print("after station... position
- _station.s_Radius = AIStation.GetCoverageRadius(_StationType);
- print("break station ? "+_station);
- break;
- case AIStation.STATION_AIRPORT:
- _station = cStationAir();
- _station.s_MaxSize = 1000; // airport size is limited by airport avaiability
- _station.s_Tiles = cTileTools.FindStationTiles(_Location);
- _station.s_Size = _station.s_Tiles.Count();
- _station.s_SubType = AIAirport.GetAirportType(_Location);
- _station.s_Radius = AIAirport.GetAirportCoverageRadius(_station.s_SubType);
- _station.s_Depot = AIAirport.GetHangarOfAirport(_Location);
- break;
- }
- // now common properties
- print("after station ? "+_station); // <- bug it stop here with _station doesn't exist error
- print("tiles count "+_station.s_Tiles.Count());
- bugme();
- uncomment version result :
- dbg: [script] [1] [P] bus
- dbg: [script] [1] [P] truck
- dbg: [script] [1] [P] station ? (null : 0x(nil))
- dbg: [script] [1] [P] station ? (instance : 0x0xa961168)
- dbg: [script] [1] [P] ailist=true
- dbg: [script] [1] [P] s_tile=(instance : 0x0xc60c110) empty=false
- dbg: [script] [1] [P] trigger bug
- dbg: [script] [1] [P] break station ? (instance : 0x0xa961168)
- dbg: [script] [1] [S] Your script made an error: the index '_station' does not exist
- dbg: [script] [1] [S]
- dbg: [script] [1] [S] *FUNCTION [InitNewStation()] TheDictator/class/cstation.nut line [220]
- and line comment result :
- dbg: [script] [1] [P] bus
- dbg: [script] [1] [P] truck
- dbg: [script] [1] [P] station ? (null : 0x(nil))
- dbg: [script] [1] [P] station ? (instance : 0x0xcedee70)
- dbg: [script] [1] [P] ailist=true
- dbg: [script] [1] [P] s_tile=(instance : 0x0xcedee20) empty=false
- dbg: [script] [1] [P] break station ? (instance : 0x0xcedee70)
- dbg: [script] [1] [P] after station ? (instance : 0x0xcedee70)
- dbg: [script] [1] [P] tiles count 1
- dbg: [script] [1] [S] Your script made an error: the index 'bugme' does not exist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement