Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Problem with secret not generating. (do I need to gen a new world?)  (Read 708 times)

UselessMcMiner

  • Bay Watcher
  • praise jeebus
    • View Profile

So I wanted to test out a custom Secret type. But it didn't properly generate. Why? I'm not sure. But I noticed a script that someone else had written. (sorry I can't remember their name. I'll give credit when I find out who wrote it) that can generate a slab with a secret on it. Problem is that it takes it from the secrets in the world.dat folder. But mine hasn't generated properly.

Code: [Select]
local material = 'INORGANIC:SILVER'

function getSecretId()
  for _,i in ipairs(df.global.world.raws.interactions) do
    for _,is in ipairs (i.sources) do
      if getmetatable(is) == 'interaction_source_secretst' then
        if is.name == 'the secrets of the fae' then
          return i.id
        end
      end
    end
  end
end

local pos = copyall(df.global.cursor)
if pos.x <0 then
  error('Please place the cursor wherever you want to spawn the slab.')
end

local m = dfhack.matinfo.find(material)
if not m then
  error('Invalid material.')
end

local slab = df.item_slabst:new()
slab.id = df.global.item_next_id
df.global.world.items.all:insert('#',slab)
df.global.item_next_id = df.global.item_next_id+1
slab:setMaterial(m['type'])
slab:setMaterialIndex(m['index'])
slab:categorize(true)
slab.flags.removed = true
slab:setSharpness(0,0)
slab:setQuality(0)
slab.engraving_type = 6
slab.topic = getSecretId()
slab.description = 'The secrets of life and death'
dfhack.items.moveToGround(slab,{x=pos.x,y=pos.y,z=pos.z})

I'm almost certainly going to have to change thes lines

Code: [Select]
for _,i in ipairs(df.global.world.raws.interactions) do
    for _,is in ipairs (i.sources) do
      if getmetatable(is) == 'interaction_source_secretst' then
        if is.name == 'the secrets of the fae' then

How can I change the script so I don't have to gen a new world? I want to avoid that at all costs. Thanks for any help.
Logged
Quote
The scouts have been fighting a giant capuchin for the past month now. They still haven't killed it.

Obsidian 1053

The Sentries are still fighting the capuchin. For two monthes they have done nothing but punch this monkey.