Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 264 265 [266] 267 268 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1456318 times)

catvanbrian

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3975 on: June 11, 2013, 11:38:23 am »

how do you spawn poisons of a specific creature and turn them in to gases using createitem . tell me all please
Logged

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3976 on: June 11, 2013, 11:39:55 am »

You can use the modulo operator to simplify that.

r = unit.relations.birth_time - 10 * math.modf(unit.relations.birth_time / 10)
same as
r = unit.relations.birth_time % 10

It's the same syntax in ruby and lua.

Edit: Also, well done! :)  Although I am going to miss my exploity fast bird growth.

lua's and ruby's modulus doesn't work right with -1 for what I was trying to do
lua: -1 % 10 == 9
ruby: -1 % 10 == 11 9

what is needed here:
-1 % 10 == -1

Edit: not sure where my 11 came from
« Last Edit: June 11, 2013, 12:32:54 pm by Kurik Amudnil »
Logged

Brilliand

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3977 on: June 11, 2013, 11:54:26 am »

ruby: -1 % 10 == 11

Wait, what?

I Googled this, and apparently Ruby should return 9 in this case...
Logged
The blood of our enemies is but a symbol.  The true domain of Armok is magma - mountain's blood.

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3978 on: June 11, 2013, 12:30:37 pm »

ruby: -1 % 10 == 11

Wait, what?

I Googled this, and apparently Ruby should return 9 in this case...

Hmm, just tested that again, not sure where my 11 came from.  In any case, I need it to return -1 for -1%10 so that it doesn't change -1 to -10.  Also, when r == -1, we could drop the if statement which would set all cases of birth_time == -1 to 0 which should also work unless -1 has some special significance somewhere.

Mr S

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3979 on: June 11, 2013, 12:42:41 pm »

What is the unit of measure in this birth date?  Will this mod10 function change everybody's birthday to only once every ten days?  Or is it hours?  Millifortnights?  (Must convert all of these to the fff system of measures for a mod one day)
Logged

Brilliand

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3980 on: June 11, 2013, 01:53:45 pm »

What is the unit of measure in this birth date?  Will this mod10 function change everybody's birthday to only once every ten days?  Or is it hours?  Millifortnights?  (Must convert all of these to the fff system of measures for a mod one day)

Well, apparently a day is 1200 ticks, so one tick is slightly more than a minute.  This function will round everyone's birthday to the nearest 12 minutes.
Logged
The blood of our enemies is but a symbol.  The true domain of Armok is magma - mountain's blood.

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3981 on: June 11, 2013, 02:51:18 pm »


lua's and ruby's modulus doesn't work right with -1 for what I was trying to do
lua: -1 % 10 == 9
ruby: -1 % 10 == 9

They're doing it right, by the mathematical definition of modulus.

Conceptually, the result of a modulus operation will be in the set of integers between 0 (inclusive) and the divisor (exclusive).

0 <= result < divisor

or

0 <= result <= (divisor-1)

You expected a result of -1, but that's not between 0 and 9, so it is not a legal result.

Quote
what is needed here:
-1 % 10 == -1

Add a special case.

if (unit.relations.birth_time < 0) then result = -1
else result = (unit.relations.birth_time % 10)

or

result = (unit.relations.birth_time < 0) ? -1 : (unit.relations.birth_time % 10)
Logged

CaptainArchmage

  • Bay Watcher
  • Profile Pic has Changed! Sorry for the Delay.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3982 on: June 11, 2013, 06:25:07 pm »

I've been directed here from Moltenchannels. Do we actually have a fix that will cause all creatures to grow up to their proper sizes now? Will it cause dwarves to grow up properly, or not? How do I go about applying those changes in DFhack (using Mac OSX 10.6)? Do I have to apply the fix every time some dwarf gets born, or every year, or what?
Logged
Given current events, I've altered my profile pic and I'm sorry it took so long to fix. If you find the old one on any of my accounts elsewhere on the internet, let me know by message (along with the specific site) and I'll fix. Can't link the revised avatar for some reason.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3983 on: June 11, 2013, 06:52:28 pm »

Just a few posts before you, I posted this post which contains the fix. Just type "(whatever you name the file) enable" to have it automatically fix the bug for every unit on the map every month or "(name) force" to do it immediately for all units on the map.

CaptainArchmage

  • Bay Watcher
  • Profile Pic has Changed! Sorry for the Delay.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3984 on: June 11, 2013, 06:56:59 pm »

Just a few posts before you, I posted this post which contains the fix. Just type "(whatever you name the file) enable" to have it automatically fix the bug for every unit on the map every month or "(name) force" to do it immediately for all units on the map.

Alright. So that goes straight to a file, which I then execute? Do I need to execute the file every time I load a save, or do I just need to execute it once per save?
Logged
Given current events, I've altered my profile pic and I'm sorry it took so long to fix. If you find the old one on any of my accounts elsewhere on the internet, let me know by message (along with the specific site) and I'll fix. Can't link the revised avatar for some reason.

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3985 on: June 11, 2013, 06:58:09 pm »

Just after some advice here:  if I'm going to put this fix in my LNP+, I assume that I need to put it in a specific folder, with a .lua extension?  (I'm guessing hack/scripts)

@Putnam - I'd propose a standard name, so that it can be added to the .init without issues about different names.  How about "fixgrowthbug.lua"?
« Last Edit: June 11, 2013, 07:00:36 pm by PeridexisErrant »
Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3986 on: June 11, 2013, 07:00:59 pm »

Actually, I've got one better. Since I think you're running a succession game right now, you'll want to put it into the save. Save this file as "init.lua" in the save's raw folder (NOT the objects folder, but the top-level raw folder):

Code: (init.lua) [Select]
--Fixes the body size bug.

local function fixAllCreaturesOfSizeBug()
    for _,unit in ipairs(df.global.world.units.active) do
        r = unit.relations.birth_time - 10 * math.modf(unit.relations.birth_time / 10) --Kurik Amudnil's code; if it's not clear, it sets a creature's birth_time to the nearest multiple of 10 of the previous one.
        if r > 0 then
            unit.relations.birth_time = unit.relations.birth_time - r
        end
    end
end

function automateTheFix()
    fixAllCreaturesOfSizeBug()
    dfhack.timeout(1,"months",automateTheFix) --will this work as it is?
end

automateTheFix()

fixgrowthbug.lua would work as the standard name for the non-init version.
« Last Edit: June 11, 2013, 07:03:24 pm by Putnam »
Logged

CaptainArchmage

  • Bay Watcher
  • Profile Pic has Changed! Sorry for the Delay.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3987 on: June 11, 2013, 07:12:34 pm »

Actually, I've got one better. Since I think you're running a succession game right now, you'll want to put it into the save. Save this file as "init.lua" in the save's raw folder (NOT the objects folder, but the top-level raw folder):

Code: (init.lua) [Select]
--Fixes the body size bug.

local function fixAllCreaturesOfSizeBug()
    for _,unit in ipairs(df.global.world.units.active) do
        r = unit.relations.birth_time - 10 * math.modf(unit.relations.birth_time / 10) --Kurik Amudnil's code; if it's not clear, it sets a creature's birth_time to the nearest multiple of 10 of the previous one.
        if r > 0 then
            unit.relations.birth_time = unit.relations.birth_time - r
        end
    end
end

function automateTheFix()
    fixAllCreaturesOfSizeBug()
    dfhack.timeout(1,"months",automateTheFix) --will this work as it is?
end

automateTheFix()

fixgrowthbug.lua would work as the standard name for the non-init version.

OK. I've added the .lua file to the raw folder. Is that all that's needed? This will need to run in a DFhack'd version, right? (unless Toady fixes the bug in the coming release)
Logged
Given current events, I've altered my profile pic and I'm sorry it took so long to fix. If you find the old one on any of my accounts elsewhere on the internet, let me know by message (along with the specific site) and I'll fix. Can't link the revised avatar for some reason.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3988 on: June 11, 2013, 07:15:39 pm »

Is the file called init.lua?

If it is, that should be all you need. If it comes up with an error, post it.

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3989 on: June 11, 2013, 07:16:29 pm »

Can I get some quick confirmation before uploading a new description:  this will work if I put it in hack/scripts called "fixgrowthbug.lua", and add "fixgrowthbug enable" to dfhack.init?

Thanks!
Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.
Pages: 1 ... 264 265 [266] 267 268 ... 373