-
-
Save Rumrusher/5a83f2bc103cc270f9bdf77c1f1dbd06 to your computer and use it in GitHub Desktop.
Switch to fort mode and back to advmode with little saving 9/28/2022 now there's two versions of this old script one more close to the original, and one made for using in playerforts... and adv nobles owning campsites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- changes from advmode to fort safely and back (hopefully) | |
--[[Now to warn you about saving and loading in either game mode might lead | |
to some side issues, for saving in fort mode switching to adv mode needs the adv to be `bodyswap` | |
back in again. for Saving in Adv to switch to Fort mode you probably be safe-ish if the site. | |
isn't a nano fort or a site that isn't 3x3 small. otherwise the game will try to resize the map. | |
oh and switching to fort mode on any pre-gen site larger than 4x4 might implode one pc if | |
you don't have like 20 gigs of memory for the 16x16 embark size. | |
ok so this version of this script has be updated again so that caravans and visitors and migrants | |
could show up at any edge of the map... and maybe leave from any spot... of the z level you assign the site too. | |
should be warned while I mostly iron out the Caravan crash which ties into entities than anything that messes with ui. | |
there still some unknowns left in the game | |
so uhh I probably should get to figuring out how to map the surface (properly) at some point... | |
should be said This is a modified copy of Warmist's Tofort script and this one is made for messing around the world. | |
there's a more Fort mode focus one called TopFort which dives into switching into player forts... and sometimes lord claimed campsites. | |
]]-- | |
if df.global.gamemode==df.game_mode.ADVENTURE then | |
local adv=df.global.world.units.active[0] | |
local comp={} | |
local ui=df.global.ui | |
function advGlobalPos() | |
local wd=df.global.world.world_data | |
return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y | |
end | |
function inSite() | |
local tx,ty=advGlobalPos() | |
for k,v in pairs(df.global.world.world_data.sites) do | |
local tp2={v.global_min_x, v.global_min_y, v.global_max_x, v.global_max_y} | |
if tx>=tp2[1] and tx<=tp2[3] and | |
ty>=tp2[2] and ty<=tp2[4] then | |
return v | |
end | |
end | |
end | |
local site=inSite() | |
if site==nil then | |
qerror("No site you are in found.") | |
end | |
local nomad={} | |
local h_ent | |
if ui.main.fortress_entity~=nil or ui.main.fortress_site~=nil then | |
ui.main.fortress_entity=nil | |
ui.main.fortress_site=nil | |
end | |
for k,v in pairs(df.global.world.history.figures[adv.hist_figure_id].entity_links) do | |
if v~=histfig_entity_link_memberst and not v==nil then | |
nomad=df.global.world.entities.all[v.entity_id] | |
print(v.entity_id) | |
else if v==histfig_entity_link_memberst then | |
nomad=df.global.world.history.figures[adv.hist_figure_id].entity_links[0] | |
end | |
end | |
end | |
if ui.main.fortress_entity==nil then | |
for k,v in pairs(df.global.world.entities.all) do | |
--if v.type==df.historical_entity_type.SiteGovernment and v.id==nomad.id then --maybe match race too? | |
if v.id==nomad.id then --maybe match race too? | |
if nomad.positions.own==nil then | |
break else | |
h_ent=v | |
break | |
end | |
end | |
if v.id~=nomad.id then | |
if v.type==df.historical_entity_type.SiteGovernment then | |
h_ent=v | |
end | |
end | |
end | |
if h_ent==nil then | |
qerror("Valid historical entity not found. sorry...") | |
end | |
ui.main.fortress_entity=h_ent | |
else | |
h_ent=ui.main.fortress_entity | |
end | |
function cleardesignate(adv) | |
local adv=df.global.world.units.active[0] | |
df.global.ui.main.mode=10 | |
df.global.selection_rect.start_x=0 | |
df.global.selection_rect.start_y=0 | |
df.global.selection_rect.start_z=610 | |
df.global.selection_rect.end_x=-14300 | |
df.global.selection_rect.end_y=9000 | |
df.global.selection_rect.end_z=0 | |
df.global.cursor.x=400 | |
df.global.cursor.y=400 | |
df.global.cursor.z=0 | |
dfhack.gui.getCurViewscreen():feed_key(1) | |
df.global.cursor.x=adv.pos.x | |
df.global.cursor.y=adv.pos.y | |
df.global.cursor.z=adv.pos.z | |
dfhack.gui.getCurViewscreen():feed_key(1) | |
dfhack.run_command('revflood') | |
end | |
local carter={} | |
function addToEntity(entity,unit,addtoLead) | |
local nem=dfhack.units.getNemesis(unit) | |
local hfig=nem.figure | |
for k,v in pairs(hfig.entity_links) do | |
if v.entity_id==entity.id then break else | |
carter=true | |
end | |
end | |
if carter==true then | |
hfig.entity_links:insert("#",{new=df.histfig_entity_link_memberst,entity_id=entity.id,link_strength=100}) | |
entity.nemesis_ids:insert("#",nem.id) | |
entity.nemesis:insert("#",nem) | |
entity.histfig_ids:insert("#",hfig.id) | |
entity.hist_figures:insert("#",hfig) | |
end | |
if addtoLead then | |
local lead_id | |
for k,v in pairs(entity.positions.own) do | |
if v.flags.IS_LEADER==true then | |
lead_id=v.id | |
break | |
end | |
end | |
if lead_id~=nil then | |
for k,v in pairs(entity.positions.assignments) do | |
if v.position_id==lead_id then | |
v.histfig=hfig.id | |
break | |
end | |
end | |
end | |
end | |
end | |
ui.civ_id=adv.civ_id | |
ui.race_id=adv.race | |
df.global.pause_state=true | |
ui.unk_races:insert("#",adv.race) | |
ui.site_id=site.id | |
if ui.main.fortress_site==nil then ui.main.fortress_site=site end | |
if site.entity_links==nil then site.entity_links:insert("#", {new=true, df.entity_site_link, target=site.id, entity_id=ui.fortress_entity.id,entity_site_link_flags.residence, entity_site_link_flags.trade_partner }) end | |
ui.group_id=h_ent.id | |
ui.game_state=2 | |
if #ui.tasks.discovered_plants==0 then | |
df.global.ui.tasks.discovered_creature_foods:insert("#",0) | |
df.global.ui.tasks.discovered_creatures:insert("#",0) | |
df.global.ui.tasks.discovered_plants:insert("#",0) | |
df.global.ui.tasks.discovered_plant_foods:insert("#",0) | |
end | |
if #ui.alerts.list==0 then | |
ui.alerts.list:insert("#",{new=true,name="Dummy alert"}) | |
ui.alerts.next_id=1 | |
end | |
local nem2=dfhack.units.getNemesis(adv) | |
local hfig2=nem2.figure | |
local nomad2=hfig2.entity_links[0] | |
local nomad3=hfig2.entity_links | |
local Test={} | |
for co2,mp2 in pairs(nomad3) do | |
--print(mp2.entity_id,h_ent.id) | |
if mp2.entity_id~=h_ent.id then Test=true else | |
Test=false | |
end | |
end | |
if Test==true then | |
addToEntity(h_ent,adv,true) | |
end | |
for co,mp in pairs(df.global.world.units.active) do | |
if mp.population_id==h_ent.id then | |
mp.flags2.resident=false | |
end | |
if mp.civ_id==h_ent.id or adv.civ_id==mp.civ_id then | |
mp.flags2.resident=false | |
end | |
if mp.relationship_ids.GroupLeader==adv.id then | |
local comp=mp | |
if test==true then | |
addToEntity(h_ent,comp,false) | |
end | |
end | |
end | |
function filleco(tbl,low,high) | |
for v =low, high do | |
tbl.general_items:insert("#",2) | |
end | |
tbl.weapons:insert("#",2) | |
tbl.armor:insert("#",2) | |
tbl.handwear:insert("#",2) | |
tbl.footwear:insert("#",2) | |
tbl.legwear:insert("#",2) | |
tbl.headwear:insert("#",2) | |
tbl.prepared_food:insert("#",2) | |
tbl.wood:insert("#",2) | |
tbl.thread_cloth:insert("#",2) | |
tbl.paper:insert("#",2) | |
tbl.parchment:insert("#",2) | |
tbl.bone:insert("#",2) | |
tbl.tooth:insert("#",2) | |
tbl.horn:insert("#",2) | |
tbl.pearl:insert("#",2) | |
tbl.shell:insert("#",2) | |
tbl.leather:insert("#",2) | |
tbl.silk:insert("#",2) | |
tbl.yarn:insert("#",2) | |
tbl.inorganic:insert("#",2) | |
tbl.meat:insert("#",2) | |
tbl.fish:insert("#",2) | |
tbl.plants:insert("#",2) | |
tbl.drinks:insert("#",2) | |
tbl.extract_animal:insert("#",2) | |
tbl.mill_animal:insert("#",2) | |
tbl.cheese_animal:insert("#",2) | |
tbl.extract_plant:insert("#",2) | |
tbl.mill_plant:insert("#",2) | |
tbl.cheese_plant:insert("#",2) | |
tbl.pets:insert("#",2) | |
end | |
function filleco2(tbl,low,high) | |
for v =low, high do | |
--tbl[v].unk1=site.pos.x | |
--tbl.unk1:insert("#",site.pos.x) | |
--tbl.unk2:insert("#",site.pos.y) | |
tbl.general_items:insert("#",nil) | |
--tbl[v].unk2=site.pos.y | |
end | |
tbl.weapons:insert("#",nil) | |
tbl.armor:insert("#",nil) | |
tbl.handwear:insert("#",nil) | |
tbl.footwear:insert("#",nil) | |
tbl.legwear:insert("#",nil) | |
tbl.headwear:insert("#",nil) | |
tbl.prepared_food:insert("#",nil) | |
tbl.wood:insert("#",nil) | |
tbl.thread_cloth:insert("#",nil) | |
tbl.paper:insert("#",nil) | |
tbl.parchment:insert("#",nil) | |
tbl.bone:insert("#",nil) | |
tbl.tooth:insert("#",nil) | |
tbl.horn:insert("#",nil) | |
tbl.pearl:insert("#",nil) | |
tbl.shell:insert("#",nil) | |
tbl.leather:insert("#",nil) | |
tbl.silk:insert("#",nil) | |
tbl.yarn:insert("#",nil) | |
tbl.inorganic:insert("#",nil) | |
tbl.meat:insert("#",nil) | |
tbl.fish:insert("#",nil) | |
tbl.plants:insert("#",nil) | |
tbl.drinks:insert("#",nil) | |
tbl.extract_animal:insert("#",nil) | |
tbl.mill_animal:insert("#",nil) | |
tbl.cheese_animal:insert("#",nil) | |
tbl.extract_plant:insert("#",nil) | |
tbl.mill_plant:insert("#",nil) | |
tbl.cheese_plant:insert("#",nil) | |
tbl.pets:insert("#",nil) | |
end | |
function fill(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",0) | |
tbl:insert("#",v) | |
tbl:insert("#",143) | |
tbl:insert("#",v) | |
end | |
end | |
function fill2(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",v) | |
tbl:insert("#",143) | |
tbl:insert("#",v) | |
tbl:insert("#",0) | |
end | |
end | |
function fillz(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",adv.pos.z) | |
tbl:insert("#",adv.pos.z) | |
tbl:insert("#",adv.pos.z) | |
tbl:insert("#",adv.pos.z) | |
end | |
end | |
function fillunk(tbl,low,high) | |
for v =low, high do | |
tbl[v].unk1=site.pos.x | |
tbl[v].unk2=site.pos.y | |
end | |
end | |
function fillanimal(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",1) | |
end | |
end | |
function fillstone(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",0) | |
end | |
end | |
function fillTrain(tbl,tbl2,low,high) | |
for v =low, high do | |
tbl2:insert("#",0) | |
tbl:insert("#",5) | |
end | |
end | |
function mapcheck2() | |
fill(df.global.ui.unk_mapedge_x,0,143) | |
fill2(df.global.ui.unk_mapedge_y,0,143) | |
fillz(df.global.ui.unk_mapedge_z,0,143) | |
fill(df.global.ui.map_edge.surface_x,0,143) | |
fill2(df.global.ui.map_edge.surface_y,0,143) | |
fillz(df.global.ui.map_edge.surface_z,0,143) | |
for _,Lay in pairs(df.global.ui.map_edge.layer_x) do | |
fill(Lay,0,143) | |
end | |
for _,Lay in pairs(df.global.ui.map_edge.layer_y) do | |
fill2(Lay,0,143) | |
end | |
for _,Lay in pairs(df.global.ui.map_edge.layer_z) do | |
fillz(Lay,0,143) | |
end | |
end | |
function sigh() | |
mapcheck() | |
mapcheck2() | |
for k,v in pairs(df.global.ui.unk_mapedge_x) do | |
end | |
for k,v in pairs(df.global.ui.map_edge.surface_z) do | |
df.global.ui.map_edge.surface_z[k]=adv.pos.z | |
--v=152 | |
end | |
end | |
function mapcheck() | |
fillunk(df.global.ui.unk2a8c[0],0,143) | |
fillunk(df.global.ui.unk2a8c[1],0,143) | |
fillunk(df.global.ui.unk2a8c[2],0,143) | |
fillunk(df.global.ui.unk2a8c[3],0,143) | |
end | |
Tab={} | |
Tab2={} | |
for k,Lay2 in pairs(df.global.ui.map_edge.layer_z) do | |
for k2,Lay3 in pairs(df.global.ui.unk2a8c[0]) do | |
if k then break else | |
Tab:insert("#",k) | |
end | |
Tab2:insert("#",k2) | |
return Tab,Tab2 | |
end | |
end | |
if #df.global.ui.map_edge.layer_z[0] == 0 then | |
print("map edge empty proceed to fill") | |
sigh() | |
else | |
print("welp map edge currently full") | |
end | |
if ui.main.fortress_entity.squads==0 then | |
for Sqa,Ds in pairs (df.global.world.squads.all) do | |
if Ds.entity_id==ui.main.fortress_entity.id then | |
ui.main.fortress_entity.squads:insert("#",{new=true,Ds}) | |
end | |
end | |
end | |
if #ui.tasks.discovered_plants==0 then | |
--for k,Lay2 in ipairs(df.global.world.raws.creatures.all) do | |
--return k | |
--end | |
local Anim=#df.global.world.raws.creatures.all | |
local Plan=#df.global.world.raws.plants.all | |
fillanimal(df.global.ui.tasks.discovered_creatures,0,Anim) | |
fillanimal(df.global.ui.tasks.discovered_creature_foods,0,Anim) | |
fillanimal(df.global.ui.tasks.discovered_plants,0,Plan) | |
fillanimal(df.global.ui.tasks.discovered_plant_foods,0,Plan) | |
--for k,Lay2 in ipairs(df.global.world.raws.plants.all) do | |
--return k | |
--end | |
--end | |
end | |
function fillTrain(tbl,tbl2,low,high) | |
for v =low, high do | |
tbl2:insert("#",0) | |
tbl:insert("#",5) | |
end | |
end | |
if #ui.main.fortress_entity.training_knowledge.level==0 then | |
local Anim=#df.global.world.raws.creatures.all | |
fillTrain(ui.main.fortress_entity.training_knowledge.level,ui.main.fortress_entity.training_knowledge.unk_10,0,Anim-1) | |
end | |
if #ui.kitchen.item_types==0 then | |
ui.kitchen.item_types:insert("#",0) | |
ui.kitchen.item_subtypes:insert("#",0) | |
ui.kitchen.mat_types:insert("#",0) | |
ui.kitchen.mat_indices:insert("#",0) | |
ui.kitchen.exc_types:insert("#",0) | |
end | |
if #ui.unk_9==0 then | |
ui.unk_9:insert("#",0) | |
ui.unk_9:insert("#",0) | |
ui.unk_10:insert("#",0) | |
ui.unk_10:insert("#",0) | |
ui.unk_11:insert("#",0) | |
ui.unk_11:insert("#",0) | |
end | |
if #ui.economic_stone==0 then | |
for k,Lay2 in ipairs(df.global.world.raws.inorganics) do | |
fillstone(df.global.ui.economic_stone,0,k) | |
--return k | |
end | |
end | |
if #ui.economy_prices.price_adjustment.general_items==0 then | |
filleco(df.global.ui.economy_prices.price_adjustment,0,114) | |
filleco2(df.global.ui.economy_prices.price_setter,0,114) | |
end | |
--fix training info | |
if h_ent.training_knowledge == nil then | |
h_ent.training_knowledge={new=true} | |
end | |
df.global.gamemode=df.game_mode.DWARF | |
df.global.gametype=df.game_type.DWARF_MAIN | |
if df.global.gview.view.child.child==nil then df.global.gview.view.child=df.viewscreen_dwarfmodest:new() | |
df.global.gview.view.child.parent=df.global.gview.view | |
end | |
cleardesignate() | |
print("Mode change complete.") | |
else | |
local adv=dfhack.gui.getSelectedUnit(true) | |
if adv then | |
--swap units... | |
end | |
df.global.gamemode=df.game_mode.ADVENTURE | |
df.global.gametype=df.game_type.ADVENTURE_MAIN | |
df.global.gview.view.child=df.viewscreen_dungeonmodest:new() | |
df.global.gview.view.child.parent=df.global.gview.view | |
print("Mode change complete.") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- changes from advmode to fort safely and back (hopefully) uhh this is version 7 of the alternate tofort script(originally made by warmist) I been modifying called topfort | |
-- this version of the script is made for players to jump into their old player forts from adv mode as an alternative means to retiring... so far | |
-- this method of unretiring doesn't spill the fort's supply of goods... | |
-- oh yeah be careful on swapping around different player forts or going back to an old Player fort after making a new one as the game doesn't clear mapedge between game modes when retiring | |
-- so data in fort mode might be stored if retired in adv mode and vice versa | |
if df.global.gamemode==df.game_mode.ADVENTURE then | |
local adv=df.global.world.units.active[0] | |
local ui=df.global.ui | |
function advGlobalPos() | |
local wd=df.global.world.world_data | |
return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y | |
end | |
function inSite() | |
local tx,ty=advGlobalPos() | |
for k,v in pairs(df.global.world.world_data.sites) do | |
local tp2={v.global_min_x, v.global_min_y, v.global_max_x, v.global_max_y} | |
if tx>=tp2[1] and tx<=tp2[3] and | |
ty>=tp2[2] and ty<=tp2[4] then | |
return v | |
end | |
end | |
end | |
local site=inSite() | |
if site==nil then | |
qerror("No site you are in found.") | |
end | |
local h_ent | |
if ui.main.fortress_entity==nil or ui.main.fortress_entity.site_links[0].target~=inSite().id then | |
for k,v in pairs(df.global.world.entities.all) do | |
if v.type==df.historical_entity_type.SiteGovernment and v.site_links[0].target==inSite().id then --maybe match race too? | |
h_ent=v | |
break | |
end | |
end | |
if h_ent==nil then | |
qerror("Valid historical entity not found. sorry...") | |
end | |
ui.main.fortress_entity=h_ent | |
else | |
h_ent=ui.main.fortress_entity | |
end | |
local carter={} | |
function addToEntity(entity,unit,addtoLead) | |
local nem=dfhack.units.getNemesis(unit) | |
local hfig=nem.figure | |
for k,v in pairs(hfig.entity_links) do | |
if v.entity_id==entity.id then break else | |
carter=true | |
end | |
end | |
if carter==true then | |
hfig.entity_links:insert("#",{new=df.histfig_entity_link_memberst,entity_id=entity.id,link_strength=100}) | |
entity.nemesis_ids:insert("#",nem.id) | |
entity.nemesis:insert("#",nem) | |
entity.histfig_ids:insert("#",hfig.id) | |
entity.hist_figures:insert("#",hfig) | |
end | |
if addtoLead then | |
local lead_id | |
for k,v in pairs(entity.positions.own) do | |
if v.flags.IS_LEADER==true then | |
lead_id=v.id | |
break | |
end | |
end | |
if lead_id~=nil then | |
for k,v in pairs(entity.positions.assignments) do | |
if v.position_id==lead_id then | |
v.histfig=hfig.id | |
break | |
end | |
end | |
end | |
end | |
end | |
function cleardesignate(adv) | |
local adv=df.global.world.units.active[0] | |
df.global.ui.main.mode=10 | |
df.global.selection_rect.start_x=0 | |
df.global.selection_rect.start_y=0 | |
df.global.selection_rect.start_z=610 | |
df.global.selection_rect.end_x=-14300 | |
df.global.selection_rect.end_y=9000 | |
df.global.selection_rect.end_z=0 | |
df.global.cursor.x=400 | |
df.global.cursor.y=400 | |
df.global.cursor.z=0 | |
dfhack.gui.getCurViewscreen():feed_key(1) | |
df.global.cursor.x=adv.pos.x | |
df.global.cursor.y=adv.pos.y | |
df.global.cursor.z=adv.pos.z | |
dfhack.gui.getCurViewscreen():feed_key(1) | |
dfhack.run_command('revflood') | |
end | |
ui.civ_id=adv.civ_id | |
ui.race_id=adv.race | |
ui.unk_races:insert("#",adv.race) | |
--if ui.unk_races==0 then ui.unk_races:insert("#",adv.race) end | |
ui.site_id=site.id | |
if ui.main.fortress_site==nil or ui.main.fortress_site.id~=ui.site_id then ui.main.fortress_site=site end | |
--if ui.main.fortress_site==nil or ui.main.fortress_site~=site or ui.main.fortress_site.id~=ui.site_id then ui.main.fortress_site=site end | |
--if site.entity_links==nil then site.entity_links:insert("#", {new=true, df.entity_site_link, target=site.id, entity_id=ui.fortress_entity.id, flags[0]=true, flags[5]=true }) end end | |
if site.entity_links==nil then site.entity_links:insert("#", {new=true, df.entity_site_link, target=site.id, entity_id=ui.fortress_entity.id}) end | |
ui.group_id=h_ent.id | |
ui.game_state=2 | |
local nem2=dfhack.units.getNemesis(adv) | |
local hfig2=nem2.figure | |
local nomad2=hfig2.entity_links[0] | |
local nomad3=hfig2.entity_links | |
local Test={} | |
for co2,mp2 in pairs(nomad3) do | |
--print(mp2.entity_id,h_ent.id) | |
if mp2.entity_id~=h_ent.id then Test=true else | |
Test=false | |
end | |
end | |
if Test==true then | |
addToEntity(h_ent,adv,false) | |
end | |
for co,mp in pairs(df.global.world.units.active) do | |
if mp.population_id==h_ent.id then | |
mp.flags2.resident=false | |
end | |
if mp.civ_id==h_ent.id or adv.civ_id==mp.civ_id then | |
mp.flags2.resident=false | |
end | |
if mp.relationship_ids.GroupLeader==adv.id then | |
local comp=mp | |
if test==true then | |
addToEntity(h_ent,comp,false) | |
end | |
end | |
end | |
function filleco(tbl,low,high) | |
for v =low, high do | |
tbl.general_items:insert("#",2) | |
end | |
tbl.weapons:insert("#",2) | |
tbl.armor:insert("#",2) | |
tbl.handwear:insert("#",2) | |
tbl.footwear:insert("#",2) | |
tbl.legwear:insert("#",2) | |
tbl.headwear:insert("#",2) | |
tbl.prepared_food:insert("#",2) | |
tbl.wood:insert("#",2) | |
tbl.thread_cloth:insert("#",2) | |
tbl.paper:insert("#",2) | |
tbl.parchment:insert("#",2) | |
tbl.bone:insert("#",2) | |
tbl.tooth:insert("#",2) | |
tbl.horn:insert("#",2) | |
tbl.pearl:insert("#",2) | |
tbl.shell:insert("#",2) | |
tbl.leather:insert("#",2) | |
tbl.silk:insert("#",2) | |
tbl.yarn:insert("#",2) | |
tbl.inorganic:insert("#",2) | |
tbl.meat:insert("#",2) | |
tbl.fish:insert("#",2) | |
tbl.plants:insert("#",2) | |
tbl.drinks:insert("#",2) | |
tbl.extract_animal:insert("#",2) | |
tbl.mill_animal:insert("#",2) | |
tbl.cheese_animal:insert("#",2) | |
tbl.extract_plant:insert("#",2) | |
tbl.mill_plant:insert("#",2) | |
tbl.cheese_plant:insert("#",2) | |
tbl.pets:insert("#",2) | |
end | |
function filleco2(tbl,low,high) | |
for v =low, high do | |
--tbl[v].unk1=site.pos.x | |
--tbl.unk1:insert("#",site.pos.x) | |
--tbl.unk2:insert("#",site.pos.y) | |
tbl.general_items:insert("#",nil) | |
--tbl[v].unk2=site.pos.y | |
end | |
tbl.weapons:insert("#",nil) | |
tbl.armor:insert("#",nil) | |
tbl.handwear:insert("#",nil) | |
tbl.footwear:insert("#",nil) | |
tbl.legwear:insert("#",nil) | |
tbl.headwear:insert("#",nil) | |
tbl.prepared_food:insert("#",nil) | |
tbl.wood:insert("#",nil) | |
tbl.thread_cloth:insert("#",nil) | |
tbl.paper:insert("#",nil) | |
tbl.parchment:insert("#",nil) | |
tbl.bone:insert("#",nil) | |
tbl.tooth:insert("#",nil) | |
tbl.horn:insert("#",nil) | |
tbl.pearl:insert("#",nil) | |
tbl.shell:insert("#",nil) | |
tbl.leather:insert("#",nil) | |
tbl.silk:insert("#",nil) | |
tbl.yarn:insert("#",nil) | |
tbl.inorganic:insert("#",nil) | |
tbl.meat:insert("#",nil) | |
tbl.fish:insert("#",nil) | |
tbl.plants:insert("#",nil) | |
tbl.drinks:insert("#",nil) | |
tbl.extract_animal:insert("#",nil) | |
tbl.mill_animal:insert("#",nil) | |
tbl.cheese_animal:insert("#",nil) | |
tbl.extract_plant:insert("#",nil) | |
tbl.mill_plant:insert("#",nil) | |
tbl.cheese_plant:insert("#",nil) | |
tbl.pets:insert("#",nil) | |
end | |
function fill(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",0) | |
tbl:insert("#",v) | |
tbl:insert("#",143) | |
tbl:insert("#",v) | |
end | |
end | |
function fill2(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",v) | |
tbl:insert("#",143) | |
tbl:insert("#",v) | |
tbl:insert("#",0) | |
end | |
end | |
function fillz(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",adv.pos.z) | |
tbl:insert("#",adv.pos.z) | |
tbl:insert("#",adv.pos.z) | |
tbl:insert("#",adv.pos.z) | |
end | |
end | |
function fillunk(tbl,low,high) | |
for v =low, high do | |
tbl[v].unk1=site.pos.x | |
tbl[v].unk2=site.pos.y | |
end | |
end | |
function fillanimal(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",1) | |
end | |
end | |
function fillstone(tbl,low,high) | |
for v =low, high do | |
tbl:insert("#",0) | |
end | |
end | |
function fillTrain(tbl,tbl2,low,high) | |
for v =low, high do | |
tbl2:insert("#",0) | |
tbl:insert("#",5) | |
end | |
end | |
function mapcheck2() | |
fill(df.global.ui.unk_mapedge_x,0,143) | |
fill2(df.global.ui.unk_mapedge_y,0,143) | |
fillz(df.global.ui.unk_mapedge_z,0,143) | |
fill(df.global.ui.map_edge.surface_x,0,143) | |
fill2(df.global.ui.map_edge.surface_y,0,143) | |
fillz(df.global.ui.map_edge.surface_z,0,143) | |
for _,Lay in pairs(df.global.ui.map_edge.layer_x) do | |
fill(Lay,0,143) | |
end | |
for _,Lay in pairs(df.global.ui.map_edge.layer_y) do | |
fill2(Lay,0,143) | |
end | |
for _,Lay in pairs(df.global.ui.map_edge.layer_z) do | |
fillz(Lay,0,143) | |
end | |
end | |
function sigh() | |
mapcheck() | |
mapcheck2() | |
for k,v in pairs(df.global.ui.unk_mapedge_x) do | |
end | |
for k,v in pairs(df.global.ui.map_edge.surface_z) do | |
df.global.ui.map_edge.surface_z[k]=adv.pos.z | |
--v=152 | |
end | |
end | |
function mapcheck() | |
fillunk(df.global.ui.unk2a8c[0],0,143) | |
fillunk(df.global.ui.unk2a8c[1],0,143) | |
fillunk(df.global.ui.unk2a8c[2],0,143) | |
fillunk(df.global.ui.unk2a8c[3],0,143) | |
end | |
Tab={} | |
Tab2={} | |
for k,Lay2 in pairs(df.global.ui.map_edge.layer_z) do | |
for k2,Lay3 in pairs(df.global.ui.unk2a8c[0]) do | |
if k then break else | |
Tab:insert("#",k) | |
end | |
Tab2:insert("#",k2) | |
return Tab,Tab2 | |
end | |
end | |
if #df.global.ui.map_edge.layer_z[0] == 0 then | |
print("map edge empty proceed to fill") | |
sigh() | |
else | |
print("welp map edge currently full") | |
end | |
if ui.main.fortress_entity.squads==0 then | |
for Sqa,Ds in pairs (df.global.world.squads.all) do | |
if Ds.entity_id==ui.main.fortress_entity.id then | |
ui.main.fortress_entity.squads:insert("#",{new=true,Ds}) | |
end | |
end | |
end | |
if #ui.tasks.discovered_plants==0 then | |
--for k,Lay2 in ipairs(df.global.world.raws.creatures.all) do | |
--return k | |
--end | |
local Anim=#df.global.world.raws.creatures.all | |
local Plan=#df.global.world.raws.plants.all | |
fillanimal(df.global.ui.tasks.discovered_creatures,0,Anim) | |
fillanimal(df.global.ui.tasks.discovered_creature_foods,0,Anim) | |
fillanimal(df.global.ui.tasks.discovered_plants,0,Plan) | |
fillanimal(df.global.ui.tasks.discovered_plant_foods,0,Plan) | |
--for k,Lay2 in ipairs(df.global.world.raws.plants.all) do | |
--return k | |
--end | |
--end | |
end | |
function fillTrain(tbl,tbl2,low,high) | |
for v =low, high do | |
tbl2:insert("#",0) | |
tbl:insert("#",5) | |
end | |
end | |
if #ui.main.fortress_entity.training_knowledge.level==0 then | |
local Anim=#df.global.world.raws.creatures.all | |
fillTrain(ui.main.fortress_entity.training_knowledge.level,ui.main.fortress_entity.training_knowledge.unk_10,0,Anim-1) | |
end | |
if #ui.alerts.list==0 then | |
ui.alerts.list:insert("#",{new=true,name="Dummy alert"}) | |
ui.alerts.next_id=1 | |
end | |
if #ui.kitchen.item_types==0 then | |
ui.kitchen.item_types:insert("#",0) | |
ui.kitchen.item_subtypes:insert("#",0) | |
ui.kitchen.mat_types:insert("#",0) | |
ui.kitchen.mat_indices:insert("#",0) | |
ui.kitchen.exc_types:insert("#",0) | |
end | |
if #ui.unk_9==0 then | |
ui.unk_9:insert("#",0) | |
ui.unk_9:insert("#",0) | |
ui.unk_10:insert("#",0) | |
ui.unk_10:insert("#",0) | |
ui.unk_11:insert("#",0) | |
ui.unk_11:insert("#",0) | |
end | |
if #ui.economic_stone==0 then | |
for k,Lay2 in ipairs(df.global.world.raws.inorganics) do | |
fillstone(df.global.ui.economic_stone,0,k) | |
--return k | |
end | |
end | |
if #ui.economy_prices.price_adjustment.general_items==0 then | |
filleco(df.global.ui.economy_prices.price_adjustment,0,114) | |
filleco2(df.global.ui.economy_prices.price_setter,0,114) | |
end | |
--fix training info | |
if h_ent.training_knowledge == nil then | |
h_ent.training_knowledge={new=true} | |
end | |
df.global.gamemode=df.game_mode.DWARF | |
df.global.gametype=df.game_type.DWARF_MAIN | |
if df.global.gview.view.child.child==nil then df.global.gview.view.child=df.viewscreen_dwarfmodest:new() | |
df.global.gview.view.child.parent=df.global.gview.view | |
end | |
cleardesignate(adv) | |
print("Mode change complete. TopFort ") | |
else | |
local adv=dfhack.gui.getSelectedUnit(true) | |
if adv then | |
--swap units... | |
end | |
df.global.gamemode=df.game_mode.ADVENTURE | |
df.global.gametype=df.game_type.ADVENTURE_MAIN | |
df.global.gview.view.child=df.viewscreen_dungeonmodest:new() | |
df.global.gview.view.child.parent=df.global.gview.view | |
print("Mode change complete. TopFort") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment