### Author Topic: kt0's item scripts: BLAM  (Read 15354 times)

0 Members and 1 Guest are viewing this topic.

#### kt0

• Knight
##### kt0's item scripts: BLAM
« on: March 21, 2009, 11:09:29 PM »
Since Ruthven stole my BLAM on Monday, I've been busy on some new BLAM.

I got tired of dealing with the uber hard to read item tuples so I wrote a pair of scripts to go to and fro.  There's a script that will chug through your item_kinds1.txt file and create a CSV file and a sibling script that will chug through the generated CSV and spit out proper tuples that you can then paste into module_items.py.  For those of you who started out hacking text files like I did, you can now import your item hacks into the module system with relative ease.

For more BLAMmage:  http://www.mbrepository.com/file.php?id=1156

As a test of effectiveness, I ran both scripts on my mod's data, copied the new tuples into module_items.py, compiled everything, and then diffed the results against the old item_kinds1.txt.  The only issues were a bug (!) in the original tuples for itm_plate_covered_round_shield (missing its type) and places where the original code stuffed a zero in damage type but with a proper damage type.

Limitations:
- Tableaus are hard to edit in the CSV file because my handling of them is a hack (sorry).
- A handful of itc_ flags are identical (e.x. itc_pike and itc_greatlance) and I'm far too lazy to parse the name of the item to make them match up.  They're functionally equivalent and you can fix them in the CSV if you so desire.
- It's in Ruby which I'm guessing a lot of y'all don't have installed.  I dislike Python, sorry.  If someone wants to port it, feel free.
- Not exactly user-friendly but user-friendlier than dealing with the unformatted disaster that is module_items.py.

If you use these scripts and find bugs, PM me or email me.
« Last Edit: December 20, 2011, 04:02:03 AM by Caba`drin »

#### Ruthven

• Revs lil' helper
• Baron
• crushie crushie crushie
• Faction: Neutral
• MP nick: irc://Ruthven
##### Re: kt0's item scripts: BLAM
« Reply #1 on: March 22, 2009, 11:03:08 PM »
Hey, I never stole your BLAM, I just disarmed it and it fell apart of it's own accord.

#### Wu-long

• Sergeant Knight at Arms
• Faction: Vaegir
• MP nick: Wulong
##### Re: kt0's item scripts: BLAM
« Reply #2 on: May 29, 2009, 01:40:24 AM »
Why do you dislike python and whats the twos difference?

#### MrRoy

• Language Moderator
##### Re: kt0's item scripts: BLAM
« Reply #3 on: May 29, 2009, 02:09:48 AM »
Why do you dislike python and whats the twos difference?

I think you don't get the point of this script, what it does is it takes the items.txt file, and converts it into tuples so you can edit it with python, in case you edited it and don't feel like converting it yourself into python code.

The point of this is to work with python instead of text files.

#### Wu-long

• Sergeant Knight at Arms
• Faction: Vaegir
• MP nick: Wulong
##### Re: kt0's item scripts: BLAM
« Reply #4 on: May 29, 2009, 02:13:04 AM »
Why do you dislike python and whats the twos difference?

I think you don't get the point of this script, what it does is it takes the items.txt file, and converts it into tuples so you can edit it with python, in case you edited it and don't feel like converting it yourself into python code.

The point of this is to work with python instead of text files.

lol i dont get it but thanks ;p I see nw

#### kt0

• Knight
##### Re: kt0's item scripts: BLAM
« Reply #5 on: May 29, 2009, 04:04:42 AM »
Story time with kt0:

Take a look at the tuple data in module_items.py.  What strikes you about it?  What if you wanted to change every single horse?  What if you wanted to change every single sword?  What if you wanted to compare your modified swords to the original axes?  How hard would these things be?  It would be a disaster!

The way the data is arranged in the module files is a usability nightmare; I got that within minutes of trying to twiddle some values.  I'm not going to wade through that mess to make comprehensive changes and I'd really like to pretend I'm a designer and use a proper spreadsheet.  So I wrote the conversion tools.  I wrote them in Ruby because it's my favorite scripting language and I don't get to use it very often.  This is a common thing to do:  translate something from one form that's not usable to another form that is.  And because I still wanted all the source in the module system, I wrote the bit to turn it all back into tuples as well.  It's not like it's rocket science.

When I work on my mod and need to munge item data, it's a heck of a lot more convenient now.  I have CSV files split by type and can answer most comparison type questions trivially.  Is one handed sword d too much better than one handed sword a?  Easy!  It's three lines up in the CSV!  Furthermore, I never have to hand-hack module_items.py for those things which I have CSVs for (all horses, non-artifact equipment, and projectiles) so I never have a syntax error in them, ever.  So for a relatively large subset of the item data (i.e., the stuff most likely to change), I have eliminated an entire class of problems!

I can hear you now:  "Why would I shell out my hard earned $0.00 for these crappy scripts? What can they do for me?" Well, now you can go from txt files to tuples meaning you can do your item hackery with the unofficial item editor and go right to module system-ready entries. Even text hackers, yes you, can now import all your hard work in item_kinds1.txt to the module system conveniently and easily! All this for$0.00--factory direct to you!

And to think, it's all because I was too lazy to hand-hack the original python tuples in module_items.py.

#### Cyclohexane

• Knight at Arms
• Faction: Neutral
##### Re: kt0's item scripts: BLAM
« Reply #6 on: June 11, 2009, 08:21:53 PM »
Hey kt0,
Your tool looks really cool but I have no idea how to run it.  I downloaded Ruby (push button installer = ruby186-27_rc2.exe) and it seemed to install just fine.

I then downloaded your script but a little screen just pops and and disapears.  I do not know the Ruby code required to tell it where to look for my itemkinds1.txt file.  I am currently trying to run the items2csv.rb file to convert to the .csv (for Excel).

I need instructions, I am completely new at this.
Quote
To use items2csv.rb:
- change source_file to point at your item_kinds1.txt file
- change dest_file to point at the file you want to dump the item data to
- run items2csv.rb from a command line

1.)   How do I change the source_file to point at your item_kinds1.txt file?
2.)   How do I change dest_file to point to the file I want to dump the item data?  I guess I need to create a blank .csv file on my desktop (for example)
3.)   After this is done, do I just type “run items2csv.rb”?

Screen shots would be nice, a picture is worth a thousand words…
Thank you!

#### Mordachai

• Squire
• Faction: Neutral
##### Re: kt0's item scripts: BLAM
« Reply #7 on: June 12, 2009, 12:48:19 AM »
kt0 - this is pretty kick ass.  I'm psyched to gather up some of the text file mods  that folks have done for SoD and apply them to the real code base.  You've saved us all a ton of work.

My hand's killing me this evening, so no go tonight... but soon methinks

#### kt0

• Knight
##### Re: kt0's item scripts: BLAM
« Reply #8 on: June 12, 2009, 02:33:20 AM »
I need instructions, I am completely new at this.
Quote

To use items2csv.rb:
- change source_file to point at your item_kinds1.txt file
- change dest_file to point at the file you want to dump the item data to
- run items2csv.rb from a command line

1.)   How do I change the source_file to point at your item_kinds1.txt file?
2.)   How do I change dest_file to point to the file I want to dump the item data?  I guess I need to create a blank .csv file on my desktop (for example)
3.)   After this is done, do I just type “run items2csv.rb”?

Screen shots would be nice, a picture is worth a thousand words…
Thank you!
I'll try to walk you through it step by step.  If that doesn't work, I'll start taking screen shots for you.

Make sure you have the module system installed and make sure you know where it lives.

1) First, you need to edit the two scripts to point at the data you want to work on.  Right click on the files and choose "edit".  If you've got Ruby installed correctly, they should pop open in a Ruby editor (mine open in SciTE), otherwise use notepad or your favorite text editor.

2) Find items2csv.rb.  Near the top of the file you'll find this kind of stuff:
(click to show/hide)
Those are full paths. The source_fiile is your item_kinds1.txt.  The dest_file is where you want the resultant csv to be written.  You can pop that open in Excel or OpenOffice Calc (what I use) for easier editing if you so desire.

3) Find csv2tuples.rb.  Near the top of the file you'll find this kind of stuff:
(click to show/hide)
This is the same sort of deal as in 2) except the source_file is the same csv file the other script writes out so the paths should be the same.  The tableau_src file is the ID_tableau_materials.py from the module system.  It needs to point at the one in your particular module system.  The dest_file in this case, is the file you want your tuples to go do.  Avoid the temptation to make this your module_items.py.

4) If you're in XP, click on the Start menu, choose Run, and then type in cmd.  This will pull up a DOS like window where we'll do fun stuff.

5) Run the first script by typing the red stuff into the cmd window (your path will probably be different than mine):
(click to show/hide)
and hit Enter.  If the script runs correctly, it'll say "Output file left in X" where X is what you set as dest_file.  If there's an error, you've probably got one or more paths entered incorrectly.

6) Run the second script in a similar way:
(click to show/hide)

If everything completed properly, you'll now have a python file with tuples for your items that you can copy & paste into module_items.py as necessary.

Hope that helps!

#### lukaszirn

• Recruit
• Faction: Nord
##### Re: kt0's item scripts: BLAM
« Reply #9 on: June 12, 2009, 06:41:32 AM »
kto has done it again guys...I would give a standing ovation if I could, now get to work on a troops one
Rongar knows everything
Here, take this: '!'. You forgot to put that at the end your first sentence!

#### Cyclohexane

• Knight at Arms
• Faction: Neutral
##### Re: kt0's item scripts: BLAM
« Reply #10 on: June 15, 2009, 05:59:49 PM »

I'll try to walk you through it step by step.  If that doesn't work, I'll start taking screen shots for you.

Thank you,
I am going to add a ton of OSP items to the mod I'm working on and once I get them all added and working properly, I will definately be using your tool.  I'll post the results when I get to it (probably a couple of weeks due to RL).

#### Cyclohexane

• Knight at Arms
• Faction: Neutral
##### Re: kt0's item scripts: BLAM
« Reply #11 on: June 29, 2009, 04:38:45 AM »
I got both of your scripts to work and generated each file.  I'm still new so I'm learning the next step.  I have python installed and set the environmental variable and I guess I need to open the module_items.py and paste the newly added items.  I guess I need the newest .py file for the mod I am working on (CLICK HERE and HERE).  Then run the build module to generate the new files?

#### kt0

• Knight
##### Re: kt0's item scripts: BLAM
« Reply #12 on: June 29, 2009, 05:11:24 AM »
Sounds like you have the right idea.  Before doing any copying and pasting, I'd recommend doing some fresh compiles with the most recent source to get any setup issues ironed out.  Make sure that you can play the newly-compiled module and have all the assets in the right place.  After that you can go about copying & pasting the generated tuples.  Note that your stuff probably goes over the top of some of the existing stuff in module_items.py so you'll want to be careful.

Generally, I only bother copying and pasting the data I care about and leave markers in the existing code so I paste to the right place in the file.  So, for instance, I've hacked out the arena items, the foods, and the trade goods from my CSV files.  I'd also recomment keeping backups of stuff in case something goes terribly wrong and you need to back out of a change.

If you run into problems, let me know.

#### Lyx

• Sergeant
• Mr. "gameplay over realism"
• Faction: Neutral
##### Re: kt0's item scripts: BLAM
« Reply #13 on: June 30, 2009, 05:28:41 PM »
THANK YOU. Damn, the structure of the module system is a nightmare (and i dont mean that i need to know about programming to use it - i am familiar with multiple programming languages - i just dislike the structure of the source files - it would be half as bad if individual things (i.e. item-types) would be in own files instead of dumping everything into a single file. Its not the "system" itself which i dislike, but the way data is "organized").

Anyways, this will save me a lot of work, for exactly the reasons you mentioned. Now, if only i wouldn't need to have 3 different bloated frameworks installed. I already created a minimalist python distro which requires no installation, being 1,2 MB large instead of the 30mb or more of the usual distro. Guess next up i'm gonna do the same for ruby... from a quick look at your script, it seems the only dependency is CSV.

P.S.: IMO, the setup up your little tool could benefit from this too. You could put your scripts into a folder "kt0 item scripts". Then move the configuration vars out into a third script. Then put a minimalist ruby distro into the same folder. Furthermore, make it so that by default the config vars are blank. Then the script checks if the vars are blank, and if yes, the path for txt would default to "..\item_kinds.txt", the path for csv would default to "..\source\item_kinds.csv" and the path for tuples would default to "..\source\item_tuples.py".

Then, just tell people to dump the scriptfolder into the relevant module folder, and have their mod-source in a "source" subdir of that... et voila: Works out of the box, no config - just unpack into correct folder, and you're ready to go.
« Last Edit: June 30, 2009, 05:47:00 PM by Lyx »

#### Lyx

• Sergeant
• Mr. "gameplay over realism"
• Faction: Neutral
##### Re: kt0's item scripts: BLAM
« Reply #14 on: June 30, 2009, 06:27:26 PM »
I've created a 1mb version which works out of the box. No installation. No dependencies. No setup. Anyone want?

(actually, UPXed, its now at 0,4mb. It's just the scripts, ruby binary and csv.rb as dep.)
« Last Edit: June 30, 2009, 07:06:42 PM by Lyx »