Author Topic: Counters with different variables?  (Read 1662 times)

Bumble B

  • Jr. Member
  • **
  • Posts: 64
    • Bumble B Gaming
Counters with different variables?
« on: December 27, 2018, 06:17:01 AM »
ok I'll try to break it down as much s I can but here is the outline of the script I've been battling with  over the last 6 months or so.

Basically I want to be able to count the amount of say "Water Worlds" and "Terra-formable Water Worlds" as 2 different things but written to the same .txt file.

i.e. If I scan a non terraformable water world it shows as "Water Worlds: 12" but if its terraformable  it shown as "Water Worlds: 12 (2)"

From what I've seen and researched Terraformable bodies are: High Metal Content, Water Worlds & Rocky Bodies

here is the code I have came up with but I'm not sure if the new changes in Elite 3.3 have changed a few things or not. I know some of the terms it looks for has changed but I want to get the basics of my script down.

The following script is just for Water Worlds which I would just C&P for the other types of terra formables

Thanks for any help on this, hopfully get this script up and running in time for Distant Worlds 2 next month :D

Code: [Select]
Begin Text Compare : [EDDI body scanned bodyclass] Equals 'Water world'
    Set decimal [>Bee Body Water world]to [>Bee Body Water world] plus 1.00000 (round to 0 decimal places) (save value to profile)
    Set decimal [>Bee Body ALL Water world]to [>Bee Body ALL Water world] plus 1.00000 (round to 0 decimal places) (save value to profile)
    Begin Text Compare : [EDDI body scanned terraformstate] Contains 'Terra'
        Set decimal [>Bee Body Water world Terraformable]to [>Bee Body Water world Terraformable] plus 1.00000 (round to 0 decimal places) (save value to profile)
    End Condition
    Begin Decimal Compare : [>Bee Body Water world Terraformable] Is Greater Than 0
        Write (overwrite), 'Water World: {DEC:>Bee Body Water world} ({DEC:>Bee Body Water world Terraformable})' to file '%USERPROFILE%\Documents\EDDI2\Exploration\Bodies\WaterWor...
        Write (overwrite), 'ALL Water Worlds: {DEC:>Bee Body ALL Water world} ({DEC:>Bee Body Water world Terraformable})' to file '%USERPROFILE%\Documents\EDDI2\Exploration\Bodies...
    Else
        Write (overwrite), 'Water World: {DEC:>Bee Body Water world}' to file '%USERPROFILE%\Documents\EDDI2\Exploration\Bodies\WaterWorld.txt'
        Write (overwrite), 'ALL Water Worlds: {DEC:>Bee Body ALL Water world}' to file '%USERPROFILE%\Documents\EDDI2\Exploration\Bodies\ALL Water.txt'
    End Condition
End Condition

--
CMDR Bumble B รถ7
ASUS P6TD Deluxe, Intel i7 960 @ 3.2GHz, 12Gb G.Skill, Windows 7 SP1 (64bit), ASUS Geforce GTX 970 Strix (4Gb), ThrustMaster T-Flight HOTAS X, Cosair Void RGB USB Gaming Headset, TrackIR, EDDI, Voice Attack, ED Engineer

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Counters with different variables?
« Reply #1 on: December 27, 2018, 11:19:58 AM »
You're already saving the values to the profile natively, which is going to be the simplest method of storing and retrieving data, by far.

If what you want is literally to just write both values to the same text file, there's nothing stopping you from doing so(you can use both tokens in a single line).

However, if you're looking to store and retrieve values to and from a text file, that's a whole lot more involved, especially if you want use arbitrary amounts of arbitrary-typed variables(and you would, instead of writing a custom format for literally every usage case).
You could look into ini libraries, if you want to keep it somewhat human-readable, or xml(which is natively supported in .NET), but any solution you pick would require at least an inline function to work(I'm not saying you couldn't put something together entirely out of actions and tokens, but that'd be a nightmare to build, let alone maintain).

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Counters with different variables?
« Reply #2 on: December 27, 2018, 12:36:54 PM »
Extending what Pfeil is commenting - reading for a formatted text file however you like is definitely possible with an inline function. There's a wealth of knowledge on the interewebs about how to read from (and if you want, write to) a text file using .NET.

My development focus right now is a profile that can read and write text files. To get you started, here are some of the links I saved as references:

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-write-to-a-text-file
https://stackoverflow.com/questions/22135262/get-total-number-of-non-blank-lines-from-text-file
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/file-system/how-to-read-a-text-file-one-line-at-a-time
https://stackoverflow.com/questions/6321998/how-to-open-file-txt-with-using-openfiledialog-in-c

The trick will be structuring everything so that it can weather updates (both to EDDI and the game itself). Again, this is certainly possible.