Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: output/print list to console  (Read 1447 times)

sunhear

  • Bay Watcher
    • View Profile
output/print list to console
« on: October 22, 2017, 03:10:44 pm »

Everyone,

I am trying to get in to modding. I have down load pydawrf and gotten to the point where I trying to get a simple code to run. The goal of the code is to create a list of all wooden things in my game. The scrips runs with out throwing a error via the management script. However I want the list outputted/printed to console so I can verify it exist. I have not been able to do this. How do I achieve this?

My code is: 

Code: [Select]
import pydwarf

@pydwarf.urist(name = 'stocklist.stocklist',description = 'find all items made of wood')


def inv (df):
    m = 'Meterial:wood' # check spelling
    inv = df.all(m)
    return inv
    return pydwarf.success()


Thanks
Sunhear
Logged

Bearskie

  • Bay Watcher
  • Nyam nyam
    • View Profile
Re: output/print list to console
« Reply #1 on: October 23, 2017, 08:09:06 pm »

You should post it in the pydwarf thread, otherwise I doubt madk will see this.

Try print (inv) instead of return.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: output/print list to console
« Reply #2 on: October 24, 2017, 07:12:17 am »

It seems most of the scripts produced use Lua, so you may have a better chance of getting help using that script language (assuming, of course, you don't have a specific reason for wanting to use pydwarf [which I guess is using Python]).
Logged

Bearskie

  • Bay Watcher
  • Nyam nyam
    • View Profile
Re: output/print list to console
« Reply #3 on: October 25, 2017, 05:07:50 am »

Wait, I just realized that script plain doesn't work. That's basically asking pydwarf to search the raws for all tags [Materiel:wood], which isn't a valid raw token.

Does OP want a complete list of wooden things in his currently-running game? If you want to read info from the game itself, you need to write a dfhack script, not a pydwarf one - the latter only works to edit raws.

sunhear

  • Bay Watcher
    • View Profile
Re: output/print list to console
« Reply #4 on: October 29, 2017, 03:33:45 pm »

what programming langue dose DFhack use? also were can I get a list of valid tokens?
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: output/print list to console
« Reply #5 on: October 29, 2017, 04:28:20 pm »

sunhear

  • Bay Watcher
    • View Profile
Re: output/print list to console
« Reply #6 on: October 29, 2017, 05:30:19 pm »

is there any way to right a python script that can read DF?
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: output/print list to console
« Reply #7 on: October 31, 2017, 02:18:31 pm »

No, and that's a good thing.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: output/print list to console
« Reply #8 on: October 31, 2017, 10:54:20 pm »

Yeah, too many languages in the ecosystem can cause some problems, ruby by itself is a bit of an odd man out

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: output/print list to console
« Reply #9 on: November 01, 2017, 01:35:49 am »

Incidentally, since they're both scripting, do you know what are the general advantages of ruby over lua for dfhack?

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: output/print list to console
« Reply #10 on: November 01, 2017, 02:07:01 am »

The only advantage that I know of is that you get to use Ruby instead of Lua. Ruby is more limited in various ways than Lua.