Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - madk

Pages: 1 [2] 3 4 ... 21
16
Utilities and 3rd Party Applications / Re: PyDwarf 1.1.0: Chalcedony
« on: January 22, 2016, 03:48:20 pm »
One question though, or suggestion for the documentation. I'm a definitely Python newbie, I've dabbled enough to know the syntax but I've never developed anything serious with it. I understand how to call scripts through manager.py well enough, so I think the documentation is great there, btw :)

Thanks so much for your interest!

Developing the scripts that come with PyDwarf was a lot of trial and error for me, too, though I like to think I usually got things right the first time. (I didn't.)

To test scripts, in a console located at PyDwarf's root directory I ran python, then import raws, pydwarf; df = pydwarf.df(raws) - that pydwarf.df command should load your settings from your configuration files, though you can also manually specify settings by passing them as arguments to that function. Then I'd call one of my scripts using syntax like this: print pydwarf.scripts.pineapple.noexotic(df), or maybe I'd just step through some code manually. (You can pass named arguments to your script when you run it that way, I should mention.) And then I'd print information to the console that ought to have been changed by the script so I could check up on how things were working. I could also run df.reset() and then run it all over again, perhaps after making some manual changes to the raws to see how the script contended with them. (But you'll have to restart the python console and start over again if you make changes to your script. As inconvenient as this is, I couldn't find another reliable way to reload modified scripts!)

For example, on one occasion that I was testing a script this way, my console looked something like this:

Code: [Select]
>>> import raws, pydwarf; df = pydwarf.df(raws)
>>> print df.getobj('CREATURE:TIGER').list(range=12, skip=False)
[CREATURE:TIGER]
    [DESCRIPTION:A huge, striped predator.  It is found in almost any climate on a lone hunt for its prey.]
    [NAME:tiger:tigers:tiger]
    [CASTE_NAME:tiger:tigers:tiger]
    [CHILD:3][GENERAL_CHILD_NAME:tiger cub:tiger cubs]
    [CREATURE_TILE:'T'][COLOR:6:0:1]
    [PETVALUE:200]
    [PET_EXOTIC]
    [MOUNT_EXOTIC]
    [TRAINABLE]
>>> print pydwarf.scripts.pineapple.noexotic(df)
SUCCESS: Replaced 303 PET_EXOTIC and 150 MOUNT_EXOTIC tokens.
>>> print len(df.all(value_in=['PET_EXOTIC', 'MOUNT_EXOTIC']))
0
>>> print df.getobj('CREATURE:TIGER').list(range=12, skip=False)
[CREATURE:TIGER]
    [DESCRIPTION:A huge, striped predator.  It is found in almost any climate on a lone hunt for its prey.]
    [NAME:tiger:tigers:tiger]
    [CASTE_NAME:tiger:tigers:tiger]
    [CHILD:3][GENERAL_CHILD_NAME:tiger cub:tiger cubs]
    [CREATURE_TILE:'T'][COLOR:6:0:1]
    [PETVALUE:200]
    [PET]
    [MOUNT]
    [TRAINABLE]

I turned this into a unit test. You can find that exact snippet, except for the top line with the imports and such, in docs/examples/scripts.pineapple.txt. You can make your own file in that directory containing unit tests for your own scripts, and then run all the tests in that directory using docs/bin/verify.py. I'm not sure whether I actually documented anywhere how this works, but I can summarize:

I copied that console text wholesale, save for the topmost line, and pasted it into that unit test file. Violà, it became an actual unit test where the commands are run and the output I verified here is compared to the output given after, say, I made some changes to the code or to the script. The verify.py script will helpfully let you know whether the test passed or failed and, if it failed, it will tell you where and why. I used this to do some test-driven development, as well as testing code that was already written.

There's some special formatting going on mainly so that the code snippets in these unit test files can also be used in the HTML documentation, but you won't need to worry about that much. It's the three lines you see above every unit test in those files. Your three lines will probably look like this - sans the comments.

Code: [Select]
# The name of the script you're testing goes here
pydwarf.scripts.pineapple.noexotic
# For thoroughness' sake I listed all the API commands I called here in case it was useful in the generated docs, but you can leave this line blank
raws.queryableobj.getobj raws.queryable.all raws.tokenlist.__len__ pydwarf.registrar.__getattr__
# Putting "reset" here, as opposed to a blank line, means the DF directory is reloaded so that the following test has a clean slate to work with. You probably want to do this for every test.
reset

I last worked with this code months ago and my memory is fuzzy and I can almost guarantee I've made some mistakes and terribly mislead you regarding how to best test your scripts. But I hope I've helped answer your question and put you on the right track, and I am more than happy to work with you if you run into any more obstacles.


17
Tilesets and Graphics / Re: [0.40.24v00] Phoebus' Graphic Set
« on: December 17, 2015, 03:49:29 pm »
Don't sweat it, Phoebus. I believe we are all nothing but grateful for the work you've done. You deserve respite.

18
Utilities and 3rd Party Applications / Re: PyDwarf 1.1.0: Chalcedony
« on: December 15, 2015, 07:50:16 am »
Just a PSA that PyDwarf is 100% functional for DF 42.x. It's possible that some mods written for it may be incompatible with raws changes made, and mods depending on other utilities won't work until those have been updated - but PyDwarf itself requires no update.

All of the mods packaged with PyDwarf should work with DF 42.x without any changes, though some depend on DFHack or TWBT also being up-to-date.

19
My apologies if this is an offensive question, but how does this compare to PyDwarf? At a glance, you seem to be doing similar things; I wish I knew more about coding to better understand with the glance before I try and learn all the things, but I don't, hence the question.

Well I'm late to the party.

Rubble is more user friendly :)

I'd say this is the biggest difference: I think mine is the more user-friendly. Really it's just a matter of personal opinion. When I looked into Rubble I felt the syntax was confusing and too unconventional. So I did more or less the same thing, but using Python. Which, besides the flexibility, it generally is considered to be one of the easier programming languages for a newbie to learn.

Maybe Rubble is easier to learn for someone who's used to writing raws, and PyDwarf is easier for someone who's used to writing code.

Also from what I know it's author lives under the misconception that everyone thinks using the command prompt is "easy", it is, but most people don't seem to think so :p

Pft, if you can learn to play Dwarf Fortress then you can work out how to use command prompt. It's not even close to hard.

20
Utilities and 3rd Party Applications / Re: PyDwarf 1.1.0: Chalcedony
« on: September 22, 2015, 07:09:32 am »
PyDwarf v1.1.0: Chalcedony has been released!

Here's a step-by-step tutorial to guide you through your first time configuring and running PyDwarf, and here's another tutorial to help you get started creating your first mod. Also, here's a handy list of scripts with which PyDwarf comes packaged. And here's where all those scripts are actually located, in case you'd like to see what their innards look like.

Here's just a few examples of the mods included with this release of PyDwarf:
Normally you'd be bound to run into compatibility issues when trying to install so many of these mods at once, and you'd surely have to wait for authors to update their mods before reinstalling everything whenever Dwarf Fortress updates. Not so with PyDwarf. PyDwarf is highly capable of avoiding conflicts between mods, and it cares little about which version of Dwarf Fortress you're modifying. Not only does PyDwarf make it much easier for the player to install mods, it also makes it easier for the modder to craft something excellent. Instead of editing text files on your own, PyDwarf allows you to write scripts which edit them for you: What this means for you is an enormous reduction in tedium.

21
DF Modding / Re: Is it worth modding before the next release?
« on: August 10, 2015, 09:13:19 am »
If you were to create your mod using PyDwarf, which is for the greater part version-agnostic, then the update would have a minimal impact on your mod.

22
Utilities and 3rd Party Applications / Re: PyDwarf 1.0.2: Magma Forge
« on: August 07, 2015, 12:58:23 pm »
Haha, "soon".

This is going to be the last major release of PyDwarf so I'm spending a lot of time making the documentation as helpful as I can and hunting down any remaining bugs. How does it go, the last 10% of the code takes 90% of the development time? But this polish is important: I understand that PyDwarf can look like a confusing mess and that's why I'm working hard to make it as accessible and as easy to use as possible. For anyone with any programming experience who wants to get into modding I believe PyDwarf is their best option by far. Included with the next release will be several tutorials for various aspects of PyDwarf, thorough documentation on its more complicated parts, and summaries and example usages for as many functions and methods as I can cover.

Want to help PyDwarf to attain its final form? I can always use help discovering bugs, writing code examples, making sure everything actually makes sense to someone who isn't me.

23
Utilities and 3rd Party Applications / Re: PyDwarf 1.0.2: Magma Forge
« on: July 29, 2015, 07:17:53 am »
I've been hard at work on PyDwarf and a new release is coming soon: Prepare yourself for improved documentation and a GemSet installation script! Many thanks go to dragondeplatino for working with me to get that script working.

24
Is the wolf in a penguin's clothing

25
DF Modding / Re: Fertility modding
« on: July 08, 2015, 08:07:47 am »
Here's a pydwarf script that removes animal men:

Code: [Select]
import pydwarf

@pydwarf.urist(
    name = 'pineapple.noanimalmen',
    version = '1.0.0',
    author = 'Sophie Kirschner',
    description = '''
        Removes all creatures which either have a [APPLY_CREATURE_VARIATION:ANIMAL_PERSON]
        token or have an ID ending in '_MAN'.
    ''',
    arguments = {},
    compatibility = (pydwarf.df_0_3x, pydwarf.df_0_40)
)
def noanimalmen(df):
    # Do the removing
    removed = [removedprop for removedprop in df.allobj('CREATURE').each(
        lambda token: token.removeselfandprops() if token.arg().endswith('_MAN') or token.getprop('APPLY_CREATURE_VARIATION:ANIMAL_PERSON') else None
    ) if removedprop]
   
    # All done!
    if removed:
        return pydwarf.success('Removed %d species of animal men.' % len(removed))
    else:
        return pydwarf.failure('Found no animal men to remove.')

27
Recent mod additions which take advantage of the aforementioned major revision include omniclasm's State of Decay, pkdawson's df-vegan, and two more of umiman's smallthings mods. Expect a new release quite soon!

28
DF Modding / Re: Fertility modding
« on: July 06, 2015, 11:34:53 am »
PyDwarf and Rubble both have mods that automatically handle exactly this, pineapple.orientation in the case of the former and User/Fix/Gays in the latter.

29
DF Modding / Re: [MODDING] CREATURE & ENTITY QUESTIONS THREAD
« on: July 02, 2015, 06:41:04 am »
In entity_default, [AMMO:ITEM_WHATEVER] tokens always appear immediately after the [WEAPON:ITEM_SOMETHING] token they correspond to. Is it really necessary to order the tokens in this way, or can the [AMMO:ITEM_X] tokens appear whereever underneath the entity?

For example, this is what the raws look like:

Code: [Select]
[WEAPON:ITEM_WEAPON_CROSSBOW]
[AMMO:ITEM_AMMO_BOLTS]
[WEAPON:ITEM_WEAPON_BOW]
[AMMO:ITEM_AMMO_ARROWS]

Would there be any difference if one did this instead?

Code: [Select]
[WEAPON:ITEM_WEAPON_CROSSBOW]
[WEAPON:ITEM_WEAPON_BOW]
[AMMO:ITEM_AMMO_ARROWS]
[AMMO:ITEM_AMMO_BOLTS]

30
May I suggest using Pydwarf for helping to alleviate your modularity troubles? It sounds like it could be exactly what you need, and all that's necessary to write mods for it is a basic understanding of Python. And if you decide to try it then I'd be happy to help out where I can.

Pages: 1 [2] 3 4 ... 21