Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 165 166 [167] 168 169 ... 242

Author Topic: DFHack 50.11-r6  (Read 795499 times)

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2490 on: July 14, 2020, 10:09:40 pm »

However, this question made me think of the project that Myk is taking on to make a Quickfort-like utility:
http://www.bay12forums.com/smf/index.php?topic=176889.0
https://github.com/DFHack/dfhack/issues/499
It might be worth looking at these to make sure you're not duplicating effort, or to see if you might be able to help out.

I was thinking of doing it for AutoFort:
http://www.bay12forums.com/smf/index.php?topic=176774.0

The exported data will probably be way different, since it's going to be used to proc-gen a fort layout. Maybe he could create a quickfort blueprint for import, though.
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2491 on: July 19, 2020, 05:46:55 pm »

Is there some way to determine the lowest valid z-level of a map block? Or do we just have to check if there's a map block at each given location?

For example, on one embark the eerie glowing pits were located on z=1. On another, they were on z=6, with no valid map blocks from z=1 to z=5.
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2492 on: July 19, 2020, 07:03:50 pm »

Is there some way to determine the lowest valid z-level of a map block? Or do we just have to check if there's a map block at each given location?

For example, on one embark the eerie glowing pits were located on z=1. On another, they were on z=6, with no valid map blocks from z=1 to z=5.
I think you just have to check whether each block is allocated or not. (For reference, there are also some sky blocks at higher z-levels that aren't allocated by default until you build in them.)
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2493 on: July 20, 2020, 01:14:38 am »

Thanks. One last question:
In many lua scripts I see the lines "--@module = true" and "if not dfhack_flags.module then". What is the point of these?
« Last Edit: July 20, 2020, 01:17:03 am by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2494 on: July 20, 2020, 01:39:47 am »

Thanks. One last question:
In many lua scripts I see the lines "--@module = true" and "if not dfhack_flags.module then". What is the point of these?

Lua has "modules" which are like script-library. We (i.e. dfhack team) has extended this functionality to scripts. Thus a script can be used as a module but it needs to know if it should just run the functionality (e.g. teleport a unit to cursor) or give the functions (e.g. if you are making a building or a spell that teleports creatures). More info here

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2495 on: July 20, 2020, 02:12:04 am »

Lua has "modules" which are like script-library. We (i.e. dfhack team) has extended this functionality to scripts. Thus a script can be used as a module but it needs to know if it should just run the functionality (e.g. teleport a unit to cursor) or give the functions (e.g. if you are making a building or a spell that teleports creatures). More info here

Still a bit unclear to me. Does this mean that putting these lines allows the function definitions to be used by other scripts without executing the main function? Similar to Python's if __name__ == "__main__"?
« Last Edit: July 20, 2020, 02:19:42 am by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2496 on: July 20, 2020, 02:24:02 am »

Lua has "modules" which are like script-library. We (i.e. dfhack team) has extended this functionality to scripts. Thus a script can be used as a module but it needs to know if it should just run the functionality (e.g. teleport a unit to cursor) or give the functions (e.g. if you are making a building or a spell that teleports creatures). More info here

Still a bit unclear to me. Does this mean that putting these lines allows the function definitions to be used by other scripts without executing the main function? Similar to Python's if __name__ == "__main__"?

As far as I understand it's the same as Python's if __name__ == "__main__".

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2497 on: July 20, 2020, 02:32:04 am »

Okay, thanks!
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

Atomic Chicken

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2498 on: July 20, 2020, 09:16:45 am »

Thanks. One last question:
In many lua scripts I see the lines "--@module = true" and "if not dfhack_flags.module then". What is the point of these?

"--@ module = true" permits the script to be used as a module, which basically means that other scripts can call functions from it via "reqscript".

Consider the following snippet from "resurrect-adv.lua", which calls the "heal()" function of "full-heal.lua":
Code: (resurrect-adv.lua) [Select]
local fullHeal = reqscript('full-heal')
...
fullHeal.heal(adventurer, true)

If "full-heal.lua" lacked "--@ module = true", the above code would fail at the reqscript line with the error "full-heal: Cannot be used as a module."

"dfhack_flags.module" is set when the script is being called through reqscript. It's added to module-enabled scripts to prevent unnecessary code from running when they are being used as modules (if omitted, the whole script would run as if it had been called from console).

For example:
Code: [Select]
if not dfhack_flags.module then
  print("foo")
end
Prevents "foo" from being printed during a reqscript call.

Code: [Select]
if dfhack_flags.module then
  return
end
print("foo")
An alternative way to do the above.

"moduleMode" is sometimes used instead of "dfhack_flags.module"; they do the same thing as far as I'm aware.
« Last Edit: July 20, 2020, 09:20:14 am by Atomic Chicken »
Logged
As mentioned in the previous turn, the most exciting field of battle this year will be in the Arstotzkan capitol, with plenty of close-quarter fighting and siege warfare.  Arstotzka, accordingly, spent their design phase developing a high-altitude tactical bomber. 

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2499 on: July 20, 2020, 09:36:03 am »

Yeah, dfhack_flags.module and moduleMode do basically the same thing. The latter was older, and was kept for compatibility with existing scripts.

Either way, though, you should prefer reqscript() for importing other scripts. It will ensure that the script has the "--@ module = true" flag set before attempting to execute the script, which usually means that a script was written to handle being imported by other scripts. Not all scripts handle this - e.g. if you tried to load https://github.com/DFHack/scripts/blob/master/devel/all-bob.lua with script_environment, it would actually execute the script before returning the script's environment. (This is similar to attempting to import a Python file that doesn't guard its entrypoint with "if __name__ == '__main__'".)

There are also a couple other flags available in dfhack_flags sometimes - some are only used internally, but enable and enable_state are documented.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Iä! RIAKTOR!

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2500 on: July 20, 2020, 01:59:40 pm »

I have an idea. Changed Catsplosion script can make male creatures pregnant, but male cannot give birth. But male creature can lay eggs! So will this work for monogendered creature breeding? Who can test?
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2501 on: July 21, 2020, 07:13:42 pm »

You can also transform male creatures to a female caste during the pregnancy, though I think that ruins the "monogendered" criterion.

Iä! RIAKTOR!

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2502 on: July 23, 2020, 10:01:37 am »

You can also transform male creatures to a female caste during the pregnancy, though I think that ruins the "monogendered" criterion.
Transformation heal all injures. And satyrs, blendecs, grimelings, blizzard men has no female caste at all. So, can you test my idea? I am very bad with lua coding.
Logged

knutor

  • Bay Watcher
  • ..to hear the lamentation of the elves!
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2503 on: July 24, 2020, 11:06:55 pm »

Probably reported in one of 1xx's of dfHack pages, but in the event it hasn't been reported.

Fastdwarf teleport does not bring along the visiting mercs.

Ive a hu mercenary in shock squad, 4. S4 is filled to 10 souls. It was ordered to kill something in caverns. 9 soldiers teleported to  thing in cavern. All the dwarfs minus the mercenary.

Crossing fingers. To me teleport works like marching orders, for the squad soldiers. I hope someone out there in forumland, can fix this.
Logged
"I don't often drink Mead, but when I do... I prefer Dee Eef's.  -The most interesting Dwarf in the World.  Stay thirsty, my friend.
Shark Dentistry, looking in the Raws.

Schmaven

  • Bay Watcher
  • Abiding
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2504 on: July 24, 2020, 11:23:47 pm »

...
To me teleport works like marching orders, for the squad soldiers.
...

That's a cool idea.  Like a forced march in the military - everyone has to stop what they're doing and go there.

Except the mercenaries it seems. 
Logged
Pages: 1 ... 165 166 [167] 168 169 ... 242