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 5 ... 21
31
Where did you put that text, specifically? What isn't working? Is the reaction not showing up in the smelter?

For one, having [IS_METAL] in the inorganic and not having [FUEL] in the reaction may result in unintended behavior. I believe you would also omit "ore" from [STATE_NAME_ADJ] for the inorganic. And the convention, as far as I know, is to have separate inorganic entries for the ore and the bars. But I don't think any of that would break things completely?

The most obvious error, though, would be if you haven't added a [PERMITTED_REACTION:CRYOCYTE_MAKEING] (sic) underneath [ENTITY:MOUNTAIN] along with the other similar tokens in the entity_default.txt file.

32
Coming in the next release: A major revising of the way PyDwarf handles files will provide modders with the ability to add or modify DFHack scripts, to work together with stonesense, to tinker with DF init settings and with speechfiles, and to add images for use with graphics packs or even just new tilesets, and still loads more. All of this with the ease and flexibility of Python!

33
Here's the second release, v1.0.1: Strange Mood. Mostly it adds a lot of documentation and fixes/improves stuff that was already there.

I'm still trying to gain traction for PyDwarf! I believe the best way to do this is to add more mods. If you have a mod you'd like to see rewritten for PyDwarf, please let me know and I'll work with you to get it done. PyDwarf is very good at this sort of thing! Mods that might previously have been limited to a small range of Dwarf Fortress versions, and might have been troublesome to merge with other mods, can now be written in such a way that compatibility becomes almost a non-issue.

Changelog:
Spoiler (click to show/hide)

34
Utilities and 3rd Party Applications / Re: PyDwarf 1.0.0: A New Hope
« on: June 07, 2015, 08:51:07 am »
Finally put out a first release! https://github.com/pineapplemachine/PyDwarf/releases

A list of scripts included with the current release:
Spoiler (click to show/hide)

36
Generally "token" is used to refer to a lexeme with attached meta-data (location in the file, type, ect).

Quote from: Wikipedia
A lexeme is a string of characters which forms a syntactic unit.[2]

Some authors (for example, [1], [2]), just call this a token, using 'token' interchangeably to represent (a) the string being tokenized, and also (b) the token datastructure resulting from putting this string through the tokenization process.

http://en.wikipedia.org/wiki/Lexical_analysis#Lexeme

Personally I've never heard someone actually refer to them as lexemes.

37
OK, although that doesn't really address my question because you started with NONE and went to ALL, I see from your example that I could accomplish what I would be looking for with a slice.

Your example does bring up another question though - what about growths with multiple GROWTH_PRINTs? ... There are 4 growth prints which vary only in their args. Can I change the color (args 2-4 inclusive 0-based) of the 2nd GROWTH_PRINT without touching the others?

I'm not sure I understand what you mean, then. Can you provide some sort of pseudocode example of what you would expect to be able to do?

As for multiple GROWTH_PRINTs, they could be handled like this:

Code: [Select]
>>> pomegranate = df.getobj('PLANT:POMEGRANATE')
>>> print pomegranate
[PLANT:POMEGRANATE]
>>> growths = pomegranate.allprop('GROWTH_PRINT')
>>> print growths
[
                [GROWTH_PRINT:0:6:2:0:0:0:209999:1],
                [GROWTH_PRINT:0:6:6:0:1:210000:239999:1],  autumn color
                [GROWTH_PRINT:0:6:4:0:1:240000:269999:1],
                [GROWTH_PRINT:0:6:4:0:0:270000:300000:1],
                [GROWTH_PRINT:5:5:4:0:1:60000:119999:2],
                [GROWTH_PRINT:'%':'%':4:0:1:120000:200000:3]]
>>> growths[1].args[2] = 'some value'
>>> growths[1].args[3] = 'some other value'
>>> growths[1].args[4] = 'some other value again'
>>> print growths
[
                [GROWTH_PRINT:0:6:2:0:0:0:209999:1],
                [GROWTH_PRINT:0:6:some value:some other value:some other value a
gain:210000:239999:1],  autumn color
                [GROWTH_PRINT:0:6:4:0:1:240000:269999:1],
                [GROWTH_PRINT:0:6:4:0:0:270000:300000:1],
                [GROWTH_PRINT:5:5:4:0:1:60000:119999:2],
                [GROWTH_PRINT:'%':'%':4:0:1:120000:200000:3]]

It might be helpful to see PyDwarf's querying functionality as a bunch of methods that look for tokens in a linked list, starting with some particular token, that match some particular conditions, and ceasing to accumulate matching tokens on some condition. Because that's exactly what it is. All of the querying methods are built on top of a generalized query method that takes filter objects and an iterable collection of tokens as arguments. For example, the method allprop as used in the above code starts from the current token and returns everything with a value of 'GROWTH_PRINT' until it encounters the next token with a value of 'PLANT'. And each of the token objects in the list returned can be operated on in any way from adding more tokens before or after, removing the token, or accessing/modifying its attributes e.g. its arguments.

If you navigate a terminal to your PyDwarf directory, try entering python and entering the same commands as above. (Don't forget to import raws and df = raws.dir(path="..."). You will need to change the path in raws.dir(path="...") to refer to actual raws on your machine.) Screw around with them as you see fit, and the workings should become more apparent.

Well, if that's the definition then that's the definition, but it's an extraordinarily unhelpful one for performing lexical analysis.

Given the raws snippet [CREATURE:DWARF] a lexical scanner would break it down into these elements: '[', 'CREATURE', ':', 'DWARF', ']'. These are formally called lexemes, but are typically referred to as tokens in the context of lexical scanners. In no context that I know of would tokens conventionally refer to 'CREATURE' and 'DWARF' only. The term I've most frequently seen to refer to the tags/tokens in raws is token, for example this wiki page. The first item in the list delimited by colons represents the purpose of the token, and value seemed to me a reasonable term to use. The others elaborate on the first in much the same way as arguments passed to some procedure.

38
Are the arguments identified only by their index? How would one go about, say, setting all the time ranges in all GROWTH_PRINT tags to ALL? Or is the range identified as a single "range-type" argument, even though it's got a semicolon in?

As an effort to make PyDwarf itself as version-agnostic as possible, there is very little implicit handling of anything. None so far of arguments: Everything separated by a colon is a separate argument as far as PyDwarf is concerned, neither does PyDwarf try to discern names or purposes for arguments; they are identified only by their indexes. Here's an example of how to do what you're thinking of:

Code: [Select]
>>> import raws
>>> df = raws.dir(path="raw")
>>> quarrybush = df.getobj('PLANT:BUSH_QUARRY')
>>> growthprint = quarrybush.get('GROWTH_PRINT')
>>> print growthprint
[GROWTH_PRINT:0:6:7:0:0:NONE]
>>> print growthprint.args
['0', '6', '7', '0', '0', 'NONE']
>>> growthprint.args[4] = 'ALL'
>>> growthprint.args[5] = '1'
>>> print growthprint
[GROWTH_PRINT:0:6:7:0:ALL:1]
>>> print growthprint.args
['0', '6', '7', '0', 'ALL', '1']

On nomenclature: "token", "value", "args" seemed to me like the most appropriate terms, coming from my experience with parsers.

39
Hey madk,

Does this support changing individual tokens within tags?

Could you elaborate? I always understood the terms "token" and "tag" to be synonymous when speaking of the raws.

Do you mean changing the arguments of a token? i.e. a token being like [VALUE:ARGUMENT_0:ARGUMENT_1:...:ARGUMENT_n]? If so then absolutely. A raws.token object has a value attribute, corresponding to the first item in the list delimited by colons, and an args attribute which is a list of all the other items. There are also helper methods like token.nargs(), token.getarg(), and token.setarg() for things like convenience and input sanitization.

41
DF Modding / Re: Community Mods and utilities list.
« on: June 01, 2015, 03:07:05 am »
Would you add PyDwarf to the list? It's a tool in the vein of ModBase and Rubble but it aims to be friendlier and more comprehensive. Essentially its purpose is to provide capable querying and modification of raws to modders, and easy management and use of modders' scripts by players.

42
There's a tutorial now! And I've generally gone through a lot effort to make PyDwarf more accessible to users and modders.

https://github.com/pineapplemachine/PyDwarf/blob/master/tutorial.md

43
I wrote a PyDwarf script which is able to fairly intelligently merge modified raws provided the DF versions all line up. (Understanding changes based on disparate vanilla raws would be a highly nontrivial problem.) It should be listed as the first script to run and given, as an argument, paths to each file or directory that should be merged and applied.

https://github.com/pineapplemachine/PyDwarf/blob/master/scripts/pineapple/pydwarf.diff.py

44
I'm interested in helping modders to rewrite their mods using PyDwarf. If you have a mod you'd like to end up in the official repo, please let me know! I'll work with you closely to make sure everything gets done smoothly.

45
Scripts are already allowed to take whatever arguments that Python will allow them to take, though there's not currently a mechanism for allowing *args. (But that's okay, because it's exactly the same thing to just pass a list or other iterable as a named argument.) I don't believe it's practical to have an "uninstall" functionality - making the changes is much easier than reversing them. Instead the user would be expected to keep backups, and if they decide they want to remove some mod or change the load order they would need to re-run the manager with the updated settings.

I understand the documentation is shitty - I'm working on that - but it you might look into how it works before speculating about how to change it. You may find that many of the things you're asking for are there already.

For me, concern regarding ease-of-use is more to do with making it so that users won't need to have programming knowledge to use the mod manager. Eventually I'd like this to mean having easy ini or ini-like configuration files as an option, perhaps even a more graphical interface that could abstract aspects of configuration and management. For usability from the perspective of modders, I believe what I have is a solid foundation. There are improvements I want to make but the essentials are present if not a little buggy in places. Also worth nothing that it's my on the todo list to write diff-based mod functionality into PyDwarf as a mod itself that accepts existing diff-based mods as input and merges them as best it can. (I believe this would actually be simple compared to the querying functionality that's at the core of PyDwarf.)

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