Fixed a lot of bugs, mostly in dfusion->tools.

Embark anywhere now works (in windows atleast), all other tools should work in both linux and windows.
TODO: should move embark anywhere somewhere else (as it is code changing tool)
develop
Warmist 2012-04-03 23:51:54 +03:00
parent 6d4ef1fd38
commit 26f5e0dfb5
2 changed files with 38 additions and 23 deletions

@ -254,11 +254,11 @@ function it_menu:display()
if r=='q' then return end if r=='q' then return end
ans=tonumber(r) ans=tonumber(r)
if ans==nil or not(ans<=table.maxn(self.items) and ans>0) then if ans==nil or not(ans<=#self.items and ans>0) then
print("incorrect choice") print("incorrect choice")
end end
until ans~=nil and (ans<=table.maxn(self.items) and ans>0) until ans~=nil and (ans<=#self.items and ans>0)
self.items[ans][1]() self.items[ans][1]()
end end
function MakeMenu() function MakeMenu()

@ -71,7 +71,7 @@ function tools.embark()
end end
end end
tools.menu:add("Embark anywhere",tools.embark) tools.menu:add("Embark anywhere",tools.embark)
function tools.getCreatureId(vector) --redo it to getcreature by name function tools.getCreatureId(vector) --redo it to getcreature by name/id or something
tnames={} tnames={}
rnames={} rnames={}
--[[print("vector1 size:"..vector:size()) --[[print("vector1 size:"..vector:size())
@ -103,28 +103,43 @@ function tools.getCreatureId(vector) --redo it to getcreature by name
end end
return indx return indx
end end
function tools.change_adv() function tools.change_adv(unit,nemesis)
myoff=offsets.getEx("AdvCreatureVec") if nemesis==nil then
vector=engine.peek(myoff,ptr_vector) nemesis=true --default value is nemesis switch too.
indx=tools.getCreatureId(vector) end
print("Swaping, press enter when done or 'q' to stay, 's' to stay with legends id change") if unit==nil then
tval=vector:getval(0) unit=getCreatureAtPointer()
vector:setval(0,vector:getval(indx))
vector:setval(indx,tval)
r=getline()
if r=='q' then
return
end end
if r~='s' then if unit==nil then
tval=vector:getval(0) error("Invalid unit!")
vector:setval(0,vector:getval(indx))
vector:setval(indx,tval)
end end
local lid=tools.getlegendsid(vector:getval(0)) local other=df.global.world.units.other[0]
if lid~=0 then local unit_indx
engine.poked(offsets.getEx("PlayerLegend"),lid) for k,v in pairs(other) do
if v==unit then
unit_indx=k
break
end
end
if unit_indx==nil then
error("Unit not found in array?!") --should not happen
end
other[unit_indx]=other[0]
other[0]=unit
if nemesis then --basicly copied from advtools plugin...
local nem=getNemesis(unit)
local other_nem=getNemesis(other[unit_indx])
if other_nem then
other_nem.flags[0]=false
other_nem.flags[1]=true
end
if nem then
nem.flags[1]=true
nem.flags[2]=true
df.global.ui_advmode.player_id=nem.id
else else
print("Warning target does not have a valid legends id!") error("Current unit does not have nemesis record, further working not guaranteed")
end
end end
end end
tools.menu:add("Change Adventurer",tools.change_adv) tools.menu:add("Change Adventurer",tools.change_adv)