gm-editor, set field to lua return value.

develop
Warmist 2012-11-28 17:40:37 +02:00
parent 2bbcfe912a
commit 3964c8a581
1 changed files with 15 additions and 0 deletions

@ -169,6 +169,19 @@ function GmEditorUi:onRenderBody( dc)
current_item=current_item+1
end
end
function GmEditorUi:set(input)
local trg=self:currentTarget()
if input== nil then
dialog.showInputPrompt("Set to what?","Lua code to set to (v cur target):",COLOR_WHITE,"",dfhack.curry(self.set,self))
return
end
local e,what=load("return function(v) return "..input.." end")
if e==nil then
dialog.showMessage("Error!","function failed to compile\n"..what,COLOR_RED)
end
trg.target[trg.keys[trg.selected]]=e()(trg)
end
function GmEditorUi:onInput(keys)
if self.mode==MODE_BROWSE then
@ -190,6 +203,8 @@ end
dialog.showMessage("Offset",string.format("Size hex=%x,%x dec=%d,%d",size,off,size,off),COLOR_WHITE)
elseif keys.CUSTOM_ALT_F then
self:find()
elseif keys.CUSTOM_ALT_S then
self:set()
elseif keys.CUSTOM_ALT_E then
--self:specialEditor()
elseif keys.CUSTOM_ALT_I then --insert