fix a script Topic is solved

Ask gaming related questions (AHK v1.1 and older)
way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

fix a script

Post by way1000 » 22 May 2022, 21:22

the script works but doesn't support many entries (rows) on "edited item stats.txt"
i need it to work for more than one row on "edited item stats.txt"

it only supports 1 row, i need it for 300 rows


.

Code: Select all

Loop, Read, edited item stats.txt
{
    Array := StrSplit(A_LoopReadLine, "`t")

    Title := Array[1]
    Itemtype := Array[2]
    Multiplier := Array[6]

    GenFile := "item info stat " A_Index ".txt"
    Loop, Read, %itemtype%.txt, %GenFile%
    {
        RegExMatch(A_LoopReadLine, "[a-zA-Z]+", Type)
        RegExMatch(A_LoopReadLine, "\d+\.\d+", Value)
        FileAppend, % ((A_Index > 1) ? "`n" : "") Title " " Type "`t" Round(Value*Multiplier)
    }
}
Attachments
item info stat.txt
(936 Bytes) Downloaded 18 times
edited item stats.txt
(693 Bytes) Downloaded 19 times
Armour.txt
(132 Bytes) Downloaded 19 times

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: fix a script

Post by mikeyww » 23 May 2022, 04:03

Four files were created here.

way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

Re: fix a script

Post by way1000 » 23 May 2022, 08:25

not four files here

can you make it work so it adds up in one file as "item info stat.txt"

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: fix a script

Post by mikeyww » 23 May 2022, 08:38

Are you running the same script that you posted? Do the other files exist in the expected place? Is the script finding those files? What is your working directory, and how do you know? Are there different versions of the text files in the actual working directory? The first question to address is why we get different results. What are your thoughts there? If needed, you can add some lines that will display the values of your variables within the script. That can help.

way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

Re: fix a script

Post by way1000 » 23 May 2022, 11:08

Screenshot_16.png
Screenshot_16.png (108.89 KiB) Viewed 802 times
.


these are all then files i have

way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

Re: fix a script

Post by way1000 » 23 May 2022, 11:12

it has to change either way i don't need many files as a result i only need 1 file

User avatar
Xtra
Posts: 2744
Joined: 02 Oct 2015, 12:15

Re: fix a script  Topic is solved

Post by Xtra » 23 May 2022, 11:48

way1000 wrote:
23 May 2022, 11:12
it has to change either way i don't need many files as a result i only need 1 file
Change
GenFile := "item info stat " A_Index ".txt"
to output as one file:
GenFile := "item info stat.txt"

way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

Re: fix a script

Post by way1000 » 23 May 2022, 12:36

thanks now it works but there's another problem

.
the text is not formatted well

.
here is a messed up file and a wanted result

.
Screenshot_17.png
Screenshot_17.png (95.81 KiB) Viewed 784 times

way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

Re: fix a script

Post by way1000 » 23 May 2022, 17:10

help plz

hehehe...LOL!

i need a genius to fix it!

User avatar
Xtra
Posts: 2744
Joined: 02 Oct 2015, 12:15

Re: fix a script

Post by Xtra » 23 May 2022, 17:38

You have bad file with bad formatting being used.
Figure out why its like that and you should have the result you want.

way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

Re: fix a script

Post by way1000 » 23 May 2022, 19:04

Xtra wrote:
23 May 2022, 17:38
You have bad file with bad formatting being used.
Figure out why its like that and you should have the result you want.
it because after the previous data lines there has to be a new line. new line is "/n" or something every time there is an end in the next one should be a line break

way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

Re: fix a script

Post by way1000 » 23 May 2022, 22:41

help plz

User avatar
Xtra
Posts: 2744
Joined: 02 Oct 2015, 12:15

Re: fix a script

Post by Xtra » 24 May 2022, 03:20

Use a var to know which is the 1st line.

Code: Select all

lineNum := 0

Loop, Read, edited item stats.txt
{
    Array := StrSplit(A_LoopReadLine, "`t")

    Title := Array[1]
    Itemtype := Array[2]
    Multiplier := Array[6]

    GenFile := "item info stat.txt"
    Loop, Read, %itemtype%.txt, %GenFile%
    {
        RegExMatch(A_LoopReadLine, "[a-zA-Z]+", Type)
        RegExMatch(A_LoopReadLine, "\d+\.\d+", Value)
        FileAppend, % (++lineNum = 1 ? "" : "`n") Title " " Type "`t" Round(Value*Multiplier)
    }
}

way1000
Posts: 90
Joined: 20 Jun 2016, 02:19

Re: fix a script

Post by way1000 » 24 May 2022, 08:32

thank you so much!

it works

Post Reply

Return to “Gaming Help (v1)”