Skip to content

Commit 2c3e5ed

Browse files
committed
Update: auto attach trailer
1 parent 416bcbd commit 2c3e5ed

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ ETS2 and ATS on Windows x64
1212
* Step 1: Press Alt+F12 to save the coordinates of [freecam](https://steamcommunity.com/sharedfiles/filedetails/?id=171359712)
1313
* Step 2: Make a quicksave in game and reload it 5 seconds later
1414

15+
## Changelog
16+
* Remove refueling
17+
* Auto attach the trailer when it's detached
18+
1519
## License
1620
[LICENSE](LICENSE)
1721

main.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727

2828
func main() {
2929
if !isFile("SII_Decrypt.exe") {
30-
handleError(errors.New("SII_Decrypt.exe does not exist!"))
30+
handleError(errors.New("SII_Decrypt.exe does not exist"))
3131
}
3232

3333
err := addDocumentsPathToWatchList()
@@ -149,7 +149,8 @@ func isDir(path string) bool {
149149
}
150150

151151
func decryptSii(filePath string) (bool, error) {
152-
cmd := exec.Command("SII_Decrypt.exe", filePath)
152+
pwd, _ := os.Getwd()
153+
cmd := exec.Command(filepath.Join(pwd, "SII_Decrypt.exe"), filePath)
153154
buf, err := cmd.Output()
154155
if err != nil {
155156
if exitErr, ok := err.(*exec.ExitError); ok {
@@ -325,8 +326,16 @@ func parseCamsCoordinate(cams []string) (string, string) {
325326
}
326327

327328
func editSii(siiArray []string, location string, rotation string) (string, error) {
329+
attachTrailer := 0
328330
for i := range siiArray {
329-
if strings.HasPrefix(siiArray[i], " truck_placement:") {
331+
if strings.HasPrefix(siiArray[i], " assigned_trailer: _nameless") {
332+
attachTrailer = 1
333+
} else if strings.HasPrefix(siiArray[i], " assigned_trailer_connected: false") && attachTrailer == 1 {
334+
attachTrailer = 2
335+
siiArray[i] = " assigned_trailer_connected: true"
336+
} else if strings.HasPrefix(siiArray[i], " nav_node_position:") && attachTrailer == 2 {
337+
siiArray[i] = " nav_node_position: (0, 0, 0)"
338+
} else if strings.HasPrefix(siiArray[i], " truck_placement:") {
330339
siiArray[i] = " truck_placement: " + `(` + location + `) (` + rotation + `)`
331340
} else if strings.HasPrefix(siiArray[i], " trailer_placement:") {
332341
siiArray[i] = ` trailer_placement: (0, 0, 0) (` + rotation + `)`
@@ -346,8 +355,6 @@ func editSii(siiArray []string, location string, rotation string) (string, error
346355
siiArray[i] = " wheels_wear: 0"
347356
} else if strings.HasPrefix(siiArray[i], " wheels_wear[") {
348357
siiArray[i] = ""
349-
} else if strings.HasPrefix(siiArray[i], " fuel_relative:") {
350-
siiArray[i] = " fuel_relative: 1"
351358
}
352359
}
353360
return strings.Join(siiArray, "\n"), nil

0 commit comments

Comments
 (0)