MysticLord |
Posted on 20-08-01, 04:33
|
Post: #1 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
Hello, I am looking for a python script which a user "xibalba" requested and which was graciously provided by the users of I think the first iteration of bboard. The script is referenced in post #416 in this thread (posts per page set at 50, your page-view will vary): https://gamefaqs.gamespot.com/boards/198537-saga-frontier/77194324?page=8#416 Use the python script that opens a single file and splits that file into it's 10 subfiles. The script was used to split M???.ARC files for Saga Frontier into their subfiles. If it can't be recovered and no one has it saved anywhere, I can pick up python in a week or two (I am very lazy) and recreate it, so no worries if it's lost forever. Just thought I would try the simple, obvious solution before I rouse myself. Thanks, MysticLord |
Kawaoneechan |
Posted on 20-08-01, 09:12
|
Draco in Hotpants
Post: #504 of 599 Since: 10-29-18 Last post: 195 days Last view: 4 hours |
Recovered from my personal copy of the archived board:
|
MysticLord |
Posted on 20-08-01, 23:29 (revision 1)
|
Post: #2 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
Thank you. edit Link for posterity https://pastebin.com/qqe5Cvdx |
MysticLord |
Posted on 20-08-21, 01:24
|
Post: #3 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
Sorry for the double-post, feel free to merge it once someone notices me. Could you find another script that xibalba e-begged off you all, which IIRC was something that would write concatenated text in a CSV to a file? I think there were multiple versions posted, for C and Python (not sure which version of Python either). I'll take all of them, if possible. Thank you once again. |
wertigon |
Posted on 20-08-26, 21:36
|
Post: #137 of 205
Since: 11-24-18 Last post: 155 days Last view: 27 days |
Posted by MysticLord Would probably solve this with a one-liner bash script to be honest:
Works like this: * move csv file to stdin (cat) * Select the fields that are desired, and use comma as delimeter (cut) * Remove any commas and other unnecessary characters (sed s///g) * Optional: use > to save output to a text file |
MysticLord |
Posted on 20-08-27, 08:20
|
Post: #4 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
Posted by wertigon Alas, it's for skrub windoze lusers. He used spreadsheets to edit data, concatenated all the hex strings together, and put them in a file intended to be exported as a CSV and written to whatever game files are needed with the Python script. I think there's a command-line tool that lets you import and export entire directories and wildcarded files into a disc image, so it should be possible to edit monster data in SaGa Frontier this way. Format of the CSV was IIRC: [code] filename,address,text-string-representing-hex-bytes file.bin,0,BEEFCAFEB00B1E55 [code] Doesn't matter if you can't find the python script, I can whip it up in a day or two. |
funkyass |
Posted on 20-08-27, 17:02
|
Post: #156 of 202
Since: 11-01-18 Last post: 660 days Last view: 15 days |
https://stackoverflow.com/questions/4441827/windows-command-for-cutting-columns-from-a-text |
MysticLord |
Posted on 20-08-28, 08:11
|
Post: #5 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
While I appreciate your thoughtfulness and effort, my time is better spent picking up a little Python than |
wertigon |
Posted on 20-08-29, 14:08
|
Post: #138 of 205
Since: 11-24-18 Last post: 155 days Last view: 27 days |
Posted by MysticLord In that case:
Gives you the csv file as a Python list, then it's just a matter of looping over the list:
This is the inefficient but simple way to do it. Otherwise, do a text parser for it. :) |
MysticLord |
Posted on 20-09-02, 04:09
|
Post: #9 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
https://python-forum.io/Thread-How-do-I-write-a-single-8-bit-byte-to-a-file Python 3 is apparently far less useful than Python 2 for writing a single byte to a file. Looks like I'm going back to Java. |
funkyass |
Posted on 20-09-02, 05:58 (revision 4)
|
Post: #157 of 202
Since: 11-01-18 Last post: 660 days Last view: 15 days |
nmbr is a string that is 2 characters long, so yeah its not going to write a single byte, especially if you tell it to treat it as an array of utf-8 characters. Cast to an int, and stuff that int into an array:
however, make use of the csv module. you be writing less code code flex:
|
MysticLord |
Posted on 20-09-03, 12:37 (revision 2)
|
Post: #10 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
It turns out that I'm a moron.Posted by 'bowlofred' Final code. Tested, works great. Tested on files padded with 0x00 and 0xFF to ensure that nothing is getting zero padded.
I looked at the CSV package but it seems like overkill given that I'm only using readline() twice and split() once. It's not like it's a complicated or script CSV after all. This is my second screw up with bytes objects, I really need to do my research before I herp a derp in the future. |
funkyass |
Posted on 20-09-03, 16:56
|
Post: #158 of 202
Since: 11-01-18 Last post: 660 days Last view: 15 days |
reading the documentation is the best first step. |
MysticLord |
Posted on 20-09-27, 14:06 (revision 2)
|
Post: #11 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
If this should be moved to a new thread in a different board, I encourage the mods to do so and to give it a witty title. Python 3 is a truly awful programming language. It's a struggle to do things that I could do in minutes in Java, but unfortunately my users are living caricatures of technological illiteracy when it comes to reading the fucking documentation and following clearly written instructions - and generally dysfunctional in a fractal manner - so I'm stuck with Python. I'm trying to dump the spark talents data for Saga Frontier in a format that can be easily copied and pasted into a spreadsheet. It needs to be done because my users to too dumb/lazy/entitled/insane to simply provide the spreadsheets and production documents (assuming they made any to start with lol) they used to make their mods, and I need to make scripts that allow one to extract their changes from their mods so one can understand what changes they made and make informed decisions such as: 1. Do I want to play this? 2. How do I play this? 3. Was he just mashing the keyboard at random when he made these changes? The table is currently organized in a 16x16 table of bytes, where each row is the talent listing (0 - 15) and each column is a set of bit that represents 8 sparkable (or not) skills.
I want to turn it into a 128x16 list, where each column is the talent listing (0 - 15) and each row is a set of sixteen 1 or 0 representing talented or not talented, for all 128 skills.
Note that the above isn't actually correct or exactly how I want it formatted (I don't want commas), but it's close enough for our work and I can easily change the formatting later once it works. Here's the Python 3 code I've written so far:
It reads from SCUS_942.30, which is the Saga Frontier main compiled executable file, but I also ripped the data and commented out the SCUS-reader code at the first few lines of code. It now uses a dummy file that is just the spark talents table, which is here: https://ufile.io/tizyn3fx If you don't have or don't want to download Saga Frontier, use the dummy file above; though any file that is at least 256 bytes long, named sparks.bin (or whatever you change that line of code to), and contains easily identified patterns will do. Here's the output: https://pastebin.com/zATnhKbw Note that I'm using bit flags on each line to ensure I'm not mixing things up that shouldn't be mixed. Those will be replaced with 1s and 0s once I'm sure everything else is working correctly. The first 8 lines print correctly, but every line after that just prints the value I stored when I initialized the array. I wasn't sure if the array initialization was working correctly (it wasn't earlier until I used copy.deepcopy(...)), so i initialized the 2D array I'm storing it in with the effective/human-understandable index of each element within said 2D array. I have no idea why it's only working on one line instead of all lines, and the incredibly helpful people over at the Python.org forums tell me things I've already figured out and which are totally irrelevant to the (previous) issues I have. I could have written this a hundred times over in Java, but Java isn't an option. Note that 8 lines of printed stuff in the output is equivalent to 1 byte of talent data for all 16 spark talent listings. I have no idea why the loop-in-a-loop starting with "while ecntr < 16:" isn't working, and frankly I'm ready to sharpen a pointy stick so I can hunt my users and consume their flesh for sustenance. Assistance will be greatly appreciated and I'm sure the peaceful emanations from my aura will be felt within a 5000 mile radius, calming the nation and preventing the Second American Civil War and the resulting World Wars III and IV. Though if you'd prefer a two-digit amount of US dollars, that works too. |
funkyass |
Posted on 20-09-27, 18:59 (revision 6)
|
Post: #169 of 202
Since: 11-01-18 Last post: 660 days Last view: 15 days |
Its because you are not resetting fcntr at the top of the outer loop. its the reason why for x in range() is perfered for loops of a fixed number
to fix your loops:
|
MysticLord |
Posted on 20-09-27, 22:42
|
Post: #12 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
Posted by funkyass Ahhhh, I feel my sanity returning. Do you have a paypal, gofundme, patreon, or onlyfans (lol) I can donate money to? Or would you prefer I donate $10-$99 to some cause you support? |
funkyass |
Posted on 20-09-27, 23:07
|
Post: #170 of 202
Since: 11-01-18 Last post: 660 days Last view: 15 days |
Posted by MysticLord its a typical brainfart that happens to everyone, i just fixed a similar bug in my own code. Save the reward for a bigger knot. |
wertigon |
Posted on 20-09-27, 23:48 (revision 2)
|
Post: #149 of 205
Since: 11-24-18 Last post: 155 days Last view: 27 days |
Nice attempt, but knowing a thing or two about python, this should take you where you want to go:
There is (almost) always a shorter solution. Anyway, you're welcome, a fun little 10 minute problem for me. :) |
MysticLord |
Posted on 20-11-12, 23:01
|
Post: #15 of 27
Since: 08-01-20 Last post: 1327 days Last view: 1227 days |
Posted by wertigon Recommend me a book? |
wertigon |
Posted on 20-11-15, 10:11
|
Post: #155 of 205
Since: 11-24-18 Last post: 155 days Last view: 27 days |
Posted by MysticLord What I did was pretty much text processing combined with knowledge about low-level programming, so nothing is covered 100%, but as for text processing this book seems to do the trick; https://www.nltk.org/book/ The dead tree version is not updated to Python 3, but otherwise it seems legit. |