One Hour One Life Forums

a multiplayer game of parenting and civilization building

You are not logged in.

#1 2018-03-25 20:30:02

Mugatu86
Member
Registered: 2018-03-16
Posts: 30

Powershell Script to track your coordinates - Updated

Updates

- April 4th: There was a change in the way the click X,Y log was being sent (relative coordinates), and some changes to current lines in the stdout file, so I am now parsing the line that says "Sending message to server: MOVE". Updated the script in the code block so feel free to use it and overwrite the old one.

Introduction

Hey all, I created a simple powershell script that scans your stdout.txt file for your current map coordinates. It will by default add a timestamp to the coordinate message and keep a running scroll of your position as you run around the world map.

This was designed as a proof of concept of auxiliary information that we can parse using the stdout.txt, and wanted to provide it to the community for feedback. If there's an appetite for this kind of information, it can be incorporated into a windows application that could save favorite coordinates and expose other information such as current hunger, what server your connected on, player nearby alert, and all the other goodies in the stdout.txt log.

Feel free to use and distribute this as you like.

Requirements

- You will need to run this script on a Windows 7 or higher PC with PowerShell
- If you are using MacOS or Linux, you can install PowerShell here: https://github.com/PowerShell/PowerShell

How to Install

- Save the PowerShell script below as a .ps1 file in your OneLife directory.
- Right click on the ps1 file that you created and select "Run with PowerShell"
- The console will wait until you start moving around in game and then it should update

Troubleshooting

- The most common problem seems to be that windows is blocking script execution, to change your policy, run Powershell as an Administrator and enter the command: set-executionpolicy unrestricted (https://www.mssqltips.com/sqlservertip/ … on-policy/)
- If you cannot run the ps1 file, or if you would rather an exe file instead, you can convert the script online using an online converter: http://www.f2ko.de/en/op2e.php.
- Make sure that the exe or script is located in your One life directory
- You can also directly download the converted exe here: https://drive.google.com/file/d/1zeg6mk … sp=sharing
- If you find that it takes a while to read lines, feel free to clear out or delete the stdout.txt file in your onelife directory, as it tends to get big very fast

Om90Lw9.jpg


       
# Settings
    # Set File Location
    $LogLocation = "stdout.txt"

    # Set Loop Delay
	$loopDelayMilliseconds = 500

    #Print with Timestamp
    $timestamp = $true


	while($true){

    #we will be parsing the lines which are similar to: "Sending message to server: MOVE 56611 109507 -1 0 -2 0 -3 0 -4 1#"
    try{ 

    $lastLine = Get-Content -Path $LogLocation | Where-Object {$_ -like "*Sending message to server: MOVE*"} | Select-Object -Last 1
    
    #if the last line has not been processed
    if ($lastLine -ne $lastLineNew ){
        
        #get the coordinates directly after the "Move" text in the last line we retrieved


        $pos = $lastLine.IndexOf("MOVE")
        $coordinates = $lastLine.Substring($pos+5)
        $pos = $coordinates.IndexOf(" ")
        $x = $coordinates.Substring(0, $pos)
        $y = $coordinates.Substring($pos+1)
        $pos = $coordinates.IndexOf(" ")
        $pos = $y.IndexOf(" ")
        $y = $y.Substring(0,$pos+0)
        $coordinates = "X: $x`t Y: $y"

        #check if settings have timestamp enabled
        if ($timestamp = $true){
        
        #get the time
        $time= Get-Date -Format g 

        #add the time to the coordinates
        $coordinates =  "$time `t $coordinates"

        }
       
       #print out the coordinate line to the console
       Write-Host $coordinates 
   

    #update lastline in memory
    $lastLineNew = $lastLine 
    }
    }Catch{
    $lastLineNew = ""

    }Finally{

    #loop through log file
	Start-Sleep -Milliseconds $loopDelayMilliseconds 
    }
}

Last edited by Mugatu86 (2018-04-08 10:56:12)

Offline

#2 2018-03-25 21:56:21

masamune0
Member
Registered: 2018-03-18
Posts: 37

Re: Powershell Script to track your coordinates - Updated

Amazing, good job, I was wondering where the coordinates were, it was simply in stdout.file... And now it will make finding cities back very easily. Since you get the coordinates and can come back easily with it.

Offline

#3 2018-03-26 02:20:30

Mugatu86
Member
Registered: 2018-03-16
Posts: 30

Re: Powershell Script to track your coordinates - Updated

That's exactly why I wanted a way to track where I was on the map - every time I run into a town on my server (Server 1), I jot the coordinates down. Once I have a few I'll map them out on a grid and share it.

Offline

#4 2018-03-26 17:22:25

Thexus
Member
Registered: 2018-03-12
Posts: 144

Re: Powershell Script to track your coordinates - Updated

ono

I installed adobe reader, and it didn't fix it. My indian IT guy-ness ends here.


Discord: Translators' Server, Thexus#3774
Working again on translations, oof

Offline

#5 2018-03-27 02:34:44

Mugatu86
Member
Registered: 2018-03-16
Posts: 30

Re: Powershell Script to track your coordinates - Updated

I forgot windows blocks powershell scripts by default, you simply have to run Powershell as an Admin and type set-executionpolicy unrestricted. More details are here: https://www.mssqltips.com/sqlservertip/ … on-policy/

You can also try to run the script through the powershell ISE (Right click the ps1 script and click Edit, then in the ISE click the Green Play button)

Otherwise, I also updated the original post to include ways of converting the ps1 script to an exe online if that helps.

Reason why I went for PowerShell and not something like auto hotkey is that Powershell is really fast at reading large text files - I can develop a C# application but I am really hesitant to start passing out exe's around, however I may start a GitHub for it if people are interested.

Last edited by Mugatu86 (2018-03-27 02:37:27)

Offline

#6 2018-03-27 06:07:19

Erudaru
Member
Registered: 2018-03-19
Posts: 104

Re: Powershell Script to track your coordinates - Updated

Can this be run on a mac?

Offline

#7 2018-03-27 11:31:37

Mugatu86
Member
Registered: 2018-03-16
Posts: 30

Re: Powershell Script to track your coordinates - Updated

You can install PowerShell on a Mac or Linux OS as it is opened source - just follow the steps here: https://dmitrysotnikov.wordpress.com/20 … -mac-os-x/

Installation files are here: https://github.com/PowerShell/PowerShell

Offline

#8 2018-03-27 13:30:43

masamune0
Member
Registered: 2018-03-18
Posts: 37

Re: Powershell Script to track your coordinates - Updated

I don't know powershell at all and I did it dirty, but I think it is working. Feel free to improve it. I was wondering if I could get the previous server and current server info as you did for the x and y. And you can. So here is the script (used your script and updated it for current/previous server) :

# Settings
    # Set File Location
    $LogLocation = "stdout.txt"

    # Set Loop Delay
    $loopDelayMilliseconds = 500

    #Print with Timestamp
    $timestamp = $true
	
	$previouserver = ""
	$currentserver = ""
	$coordinates = ""
	$oldres =""
	$firstime = 1

	while($true){

    #fetch the last line in the game log which matches the string "curX,Y = "
    #we will be parsing the lines which are similar to: "clickDestX,Y = 65, -148,  mapX,Y = 32, 34, curX,Y = 65, -148"

	$lastLine = Get-Content -Path $LogLocation | Where-Object {$_ -match "curX,Y = "} | Select-Object -Last 1
	$lastLine2 = Get-Content -Path $LogLocation | Where-Object {$_ -match "server address: "} | Select-Object -Last 1
    
    #if the last line has not been processed
    if ($lastLine -ne $lastLineNew -And $lastLine){
        
        #get the third coordinate of the string, seperated by "="
        $pos = $lastLine.IndexOf("=")
        $coordinates = $lastLine.Substring($pos+1)
        $pos = $coordinates.IndexOf("=")
        $coordinates = $coordinates.Substring($pos+1)
        $pos = $coordinates.IndexOf("=")
        $coordinates = $coordinates.Substring($pos+2)
        $pos = $coordinates.IndexOf(",")
        $x = $coordinates.Substring(0, $pos)
        $y = $coordinates.Substring($pos+1)
        $coordinates = "X: $x`t Y: $y"

        #check if settings have timestamp enabled
        if ($timestamp = $true){
        
        #get the time
        $time= Get-Date -Format g 
		

        }
    }
	
#Got server address: server1.onehouronelife.com:8005
#Using custom server address: server3.onehouronelife.com:8005
#clickDestX,Y = -333, -49,  mapX,Y = 33, 32, curX,Y = -334, -49
	if ($lastLine2 -ne $lastLineNew -And $lastLine2){
        
        #get the third coordinate of the string, seperated by "="
        $pos = $lastLine2.IndexOf(":")
        $name = $lastLine2.Substring($pos+1)
        $pos = $name.IndexOf(":")
        $tempServer = $name.Substring(0, $pos)
		if($firstime -eq 1){
			$firstime = 0
			$previouserver = $tempServer
		}
		
		if ($previouserver -ne $currentserver -And $currentserver -ne $tempServer){
			$previouserver = $currentserver
		}
        $currentserver = $tempServer
	}
       
	#print out the coordinate line to the console
	$res =  "$coordinates | Current server : $currentserver | previous server : $previouserver"
	if ($oldres -ne $res){
		Write-Host $res 
	}
	
	$oldres = $res

    #update lastline in memory
    $lastLineNew = $lastLine 
    $lastLineNew = $lastLine2 

	
    #loop through log file
	Start-Sleep -Milliseconds $loopDelayMilliseconds 
	}

Offline

#9 2018-03-28 05:21:13

atributz
Member
Registered: 2018-03-27
Posts: 15

Re: Powershell Script to track your coordinates - Updated

Thexus wrote:

https://cdn.discordapp.com/attachments/ … nknown.png

I installed adobe reader, and it didn't fix it. My indian IT guy-ness ends here.

Run PowerShell from Administrator and enter command

Set-ExecutionPolicy RemoteSigned

and enter Y

Offline

#10 2018-03-29 06:32:18

earthling
Member
Registered: 2018-03-29
Posts: 20

Re: Powershell Script to track your coordinates - Updated

i really tried. but noway, im not able to even understand how its done. your nice atempt of creating an exe still dont work. avira just puts it quarantine and if i put it on whitlist im not even allowed to move it, althogh its my computer it says that i have no rights to do so. so i took it of the whitelist again to delete it. Maybe someone would explain how to use or make an easyier way to use it. i would like to play on some private servers, but there are so little people i need to know where to go.
thx for your effort though.

Offline

#11 2018-03-29 06:41:46

Thexus
Member
Registered: 2018-03-12
Posts: 144

Re: Powershell Script to track your coordinates - Updated

uninstall avira, and install avast


Discord: Translators' Server, Thexus#3774
Working again on translations, oof

Offline

#12 2018-03-30 16:42:56

atributz
Member
Registered: 2018-03-27
Posts: 15

Re: Powershell Script to track your coordinates - Updated

Full scan log file is very simple, but extremely bad in terms of performance especially for weak machines.

So I made a similar tool for tracking coordinates using VB Net. My program is more advanced and keeps track of coordinates much better, including the option when you are carried. It also needs to be moved to the game folder.

Here binary code for windows. https://drive.google.com/open?id=1Y9jh7 … HlF1XXPoOa

Here source in txt file. https://drive.google.com/open?id=100DiK … 96TEzWuvBC


additionally

For convenience, I set up the android smartphone as a second monitor using "spacedesk beta" application. I made the font larger for the console. As a result, I play with a full screen and look at the coordinates on the phone. Perhaps someone will be interested in this option.

Offline

#13 2018-03-30 17:07:07

Mugatu86
Member
Registered: 2018-03-16
Posts: 30

Re: Powershell Script to track your coordinates - Updated

Awesome thank you for this!

Offline

#14 2018-04-03 07:01:48

Zfesty
Member
Registered: 2018-04-03
Posts: 2

Re: Powershell Script to track your coordinates - Updated

atributz wrote:

Full scan log file is very simple, but extremely bad in terms of performance especially for weak machines.

So I made a similar tool for tracking coordinates using VB Net. My program is more advanced and keeps track of coordinates much better, including the option when you are carried. It also needs to be moved to the game folder.

Here binary code for windows. https://drive.google.com/open?id=1Y9jh7 … HlF1XXPoOa

Here source in txt file. https://drive.google.com/open?id=100DiK … 96TEzWuvBC


additionally

For convenience, I set up the android smartphone as a second monitor using "spacedesk beta" application. I made the font larger for the console. As a result, I play with a full screen and look at the coordinates on the phone. Perhaps someone will be interested in this option.


How do you run it on your phone

Offline

#15 2018-04-03 11:39:22

atributz
Member
Registered: 2018-03-27
Posts: 15

Re: Powershell Script to track your coordinates - Updated

Zfesty wrote:

How do you run it on your phone

You must setup and run "spacedesk" on computer and at phone too. The phone will see your computer if it is connected to it via USB or through wifi on the same local network. Then you connect from the phone(in spacedesk app) to the computer. In the computer, configure the second monitor as an extension of the desktop. Then run console utilite and drag it to your phone.

Last edited by atributz (2018-04-03 12:04:35)

Offline

#16 2018-04-06 22:39:59

earlgraytea
Member
Registered: 2018-04-06
Posts: 5

Re: Powershell Script to track your coordinates - Updated

Has anyone gotten this to work on a Mac?

When I ran the script with Powershell it just kept printing error messages that "stdout.txt" doesn't exist. There is a file called log.txt, so I tried setting $LogLocation = "log.txt" but that didn't seem to work either.

Offline

#17 2018-04-06 23:17:13

Zwilnik
Member
Registered: 2018-03-03
Posts: 45

Re: Powershell Script to track your coordinates - Updated

earlgraytea wrote:

Has anyone gotten this to work on a Mac?

When I ran the script with Powershell it just kept printing error messages that "stdout.txt" doesn't exist. There is a file called log.txt, so I tried setting $LogLocation = "log.txt" but that didn't seem to work either.

Run it from the Terminal with > stdout.txt

You’ll need to cd to the game folder or wherever you installed it then ./OneLife_v72.app/contents/MacOS/OneLife > stdout.txt

Or thereabouts smile

Offline

#18 2018-04-07 02:10:29

earlgraytea
Member
Registered: 2018-04-06
Posts: 5

Re: Powershell Script to track your coordinates - Updated

Zwilnik wrote:

Run it from the Terminal with > stdout.txt

You’ll need to cd to the game folder or wherever you installed it then ./OneLife_v72.app/contents/MacOS/OneLife > stdout.txt

Or thereabouts smile

It works! Thank you Zwilnik and Mugatu, this is so cool. big_smile

Offline

#19 2018-04-07 04:55:48

bunny
Member
Registered: 2018-04-06
Posts: 32

Re: Powershell Script to track your coordinates - Updated

Thanks guys <3

Offline

#20 2018-04-07 23:36:19

Zwilnik
Member
Registered: 2018-03-03
Posts: 45

Re: Powershell Script to track your coordinates - Updated

Is it me or are coordinates randomising each time you spawn now? If so I’m guessing the sever is giving you a new 0,0 point each spawn and working your coordinates as an offset so players can’t find one another or previous camps anymore.

Offline

#21 2018-04-07 23:53:39

AstroTitan
Member
Registered: 2018-04-06
Posts: 16

Re: Powershell Script to track your coordinates - Updated

I also noticed something weird about coordinates today. Occasionally I would get a normal looking random high number set, but more often than not I am spawning within (0-100, 0-100) according to coordinates but I am clearly not in the same location. Yes I have a specific official server set as custom address and activated.

So I also came to the conclusion Jason must be trying to break the coordinate system people are currently using. To be fair it was never intended to be part of the game, and it does detract from the deep immersion that seems to be the intended design philosophy behind the game.

I would be fine if coordinates were no longer available on official servers. For the certain subsets of the player base that needs/wants coordinates to play the game, then join a private server with coordinates turned on.

Offline

#22 2018-04-08 00:06:59

Helperguy
Member
Registered: 2018-03-15
Posts: 34

Re: Powershell Script to track your coordinates - Updated

Zwilnik wrote:

Is it me or are coordinates randomising each time you spawn now? If so I’m guessing the sever is giving you a new 0,0 point each spawn and working your coordinates as an offset so players can’t find one another or previous camps anymore.

Yes.
I already knew jason would try to brake the coordinate system, thats why i stopped working on my software this week and only did some softwaretest, to publish my unfinished software today in the other thread:
https://onehouronelife.com/forums/viewtopic.php?id=998

I think we are at a point of development, where OHOL wil split into two communities.

Offline

#23 2018-04-08 10:54:53

Mugatu86
Member
Registered: 2018-03-16
Posts: 30

Re: Powershell Script to track your coordinates - Updated

Updated the script to now parse "Sending message to server: MOVE" commands, as the click command seemed relative. Tested it on Server 1 and 3 and is working as intended.

Offline

#24 2018-04-08 14:48:47

netnei
Member
Registered: 2018-03-10
Posts: 4

Re: Powershell Script to track your coordinates - Updated

Is this broken now?

Offline

#25 2018-04-08 16:46:37

Mugatu86
Member
Registered: 2018-03-16
Posts: 30

Re: Powershell Script to track your coordinates - Updated

netnei wrote:

Is this broken now?

No, I updated the script on the main post to show your true coordinates, rather than the relative ones.

If people are interested, I can have it include both.

Offline

Board footer

Powered by FluxBB