Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3]

Author Topic: Dwarven Emigration: An alternative to insanity. Let's try this again.  (Read 14181 times)

fricy

  • Bay Watcher
  • [DFHACK:ZEALOT]
    • View Profile

Thank you lethosor, I have a feeling that we are getting close, though we are not there yet. With your changes I could get farther, then the game froze for about a minute, and got this error:
Code: [Select]
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:23: stack overflow
stack traceback:
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:23: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:52: in function 'desert'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:207: in function 'checkForDeserters'
...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:254: in function <...8.5/Macnewbie/Dwarf Fortress/hack/scripts/emigration.lua:220>

In this test fort I have 21 unhappy/miserable/tantruming dwarves, so I suppose the 21 errors in line 52 correspond to those, and the game stalled when the script tried to calculate their desire to emigrate. Maybe just one more fix? :)

EDIT: It seem to be working somewhat, some of my dwarves do join the merchants, but I keep getting this message in the terminal. So let's say it's working 10% as intended... Tested on mac, both r3 and r4.
« Last Edit: May 17, 2014, 07:06:23 am by fricy »
Logged

lethosor

  • Bay Watcher
    • View Profile

"Stack overflow" means that there are too many nested function calls (apparently this limit is 24 - the fact that there are 21 identical lines just means that function was called 21 times from within itself). Basically, desert() is calling itself, and Lua limits the number of times a function can do this to prevent infinite loops. My best guess is that it's calling desert() on a relative of a dwarf, which then calls desert() on the original dwarf and creates a loop.
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.

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game

Still buggy, huh?  Sorry, I've just been focusing on another project lately and haven't had much time for DF... I'll just have to sit down and fix this for real at some point.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist

Still buggy, huh?  Sorry, I've just been focusing on another project lately and haven't had much time for DF... I'll just have to sit down and fix this for real at some point.
As soon as its stable, this will certainly go into MDF.  If fixing this bug is too time consuming, could you do a simpler version that can be manually trigger with autosyndrome? Expelling unwanted dwarves with a workshop reaction...
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game

Still buggy, huh?  Sorry, I've just been focusing on another project lately and haven't had much time for DF... I'll just have to sit down and fix this for real at some point.
As soon as its stable, this will certainly go into MDF.  If fixing this bug is too time consuming, could you do a simpler version that can be manually trigger with autosyndrome? Expelling unwanted dwarves with a workshop reaction...

The gnomes have a reaction like that already as part of the druidism system, it can be easily copy-pasted on its own.

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game

Okay, I actually tested it this time.  Haven't seen any families leave, but then families are supposed to have a lower chance of leaving.  Shouldn't crash.  The parameter will actually work anywhere from 1 to 1000.  The higher the number, the higher the chance of citizens leaving.

taliakirana

  • Bay Watcher
    • View Profile

This is a really good idea.
Logged

fricy

  • Bay Watcher
  • [DFHACK:ZEALOT]
    • View Profile

Okay, I actually tested it this time.  Haven't seen any families leave, but then families are supposed to have a lower chance of leaving.  Shouldn't crash.  The parameter will actually work anywhere from 1 to 1000.  The higher the number, the higher the chance of citizens leaving.

Tested, mac, dfhack-r3: Still needs lethosor's fixes for desireToStay in lines 170, 192, 197, and when I tried it with emigration 1000 the game froze instantly, last gamelog message I could see was someone joining the merchants. Running it without parameters seems to work OK.
Thx for a great plugin!

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game

Okay, maybe not actually 1000.  0-999, but for practical purposes high numbers will be ridiculous.  Try like 5 or something and if nobody ever leaves try higher numbers.  I used 900 but that was just for testing, and most free citizens left within a month.

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game

Updated: now it can be disabled by inputting 'emigration 0'.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist

Thank you. :)

In case other people want to use something similar: I added "emigration 10" to the dfhack.init and allow the player to set it ingame, let his dwarves decide.

These are the inorganics you need.
Code: [Select]
[INORGANIC:EMIGRATION0]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE][STATE_NAME_ADJ:ALL:No Emigration][MATERIAL_VALUE:0]
[SYNDROME][SYN_CLASS:\AUTO_SYNDROME][SYN_CLASS:\COMMAND][SYN_CLASS:emigration][SYN_CLASS:0][SYN_CLASS:\WORKER_ID]

[INORGANIC:EMIGRATION10]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE][STATE_NAME_ADJ:ALL:Little Emigration][MATERIAL_VALUE:0]
[SYNDROME][SYN_CLASS:\AUTO_SYNDROME][SYN_CLASS:\COMMAND][SYN_CLASS:emigration][SYN_CLASS:10][SYN_CLASS:\WORKER_ID]

[INORGANIC:EMIGRATION50]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE][STATE_NAME_ADJ:ALL:Moderate Emigration][MATERIAL_VALUE:0]
[SYNDROME][SYN_CLASS:\AUTO_SYNDROME][SYN_CLASS:\COMMAND][SYN_CLASS:emigration][SYN_CLASS:50][SYN_CLASS:\WORKER_ID]

[INORGANIC:EMIGRATION100]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE][STATE_NAME_ADJ:ALL:Lots of Emigration][MATERIAL_VALUE:0]
[SYNDROME][SYN_CLASS:\AUTO_SYNDROME][SYN_CLASS:\COMMAND][SYN_CLASS:emigration][SYN_CLASS:100][SYN_CLASS:\WORKER_ID]

These are the reactions. They allow none, little, moderate and a lot of emigration. Its added to the custom building called "Embassy", but you can put it anywhere you like.
Code: [Select]
[REACTION:EMIGRATION0]
[NAME:Forbid Emigration]
[BUILDING:EMBASSY:CUSTOM_SHIFT_E]
[PRODUCT:100:1:BOULDER:NONE:INORGANIC:EMIGRATION0]

[REACTION:EMIGRATION10]
[NAME:Allow little Emigration]
[BUILDING:EMBASSY:CUSTOM_SHIFT_F]
[PRODUCT:100:1:BOULDER:NONE:INORGANIC:EMIGRATION10]

[REACTION:EMIGRATION50]
[NAME:Allow moderate Emigration]
[BUILDING:EMBASSY:CUSTOM_SHIFT_G]
[PRODUCT:100:1:BOULDER:NONE:INORGANIC:EMIGRATION50]

[REACTION:EMIGRATION100]
[NAME:Allow a lot of Emigration]
[BUILDING:EMBASSY:CUSTOM_SHIFT_H]
[PRODUCT:100:1:BOULDER:NONE:INORGANIC:EMIGRATION100]
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::
Pages: 1 2 [3]