From f57e897c29e725559e8ba37a877cdb7c437e382e Mon Sep 17 00:00:00 2001 From: "p.kosyh" Date: Mon, 14 Jun 2010 11:41:55 +0000 Subject: [PATCH] dbg module added --- stead/dbg.lua | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 stead/dbg.lua diff --git a/stead/dbg.lua b/stead/dbg.lua new file mode 100644 index 0000000..527a727 --- /dev/null +++ b/stead/dbg.lua @@ -0,0 +1,77 @@ +-- add this: reuire "dbg" +-- in your project +-- for debug tools +choose_location = dlg { + debug = true, + nam = 'Go to', + dsc = 'Select location.', + gen = function(s) + local k,v + objs(s):zap(); + for k,v in pairs(_G) do + if isRoom(v) and not v.debug then + local n = call(v, 'nam'); + put(phr(n, nil, [[return goto("]]..k..[[")]]), s); + end + end + put (phr('Exit',nil,'return back()'), s) + end +} + +choose_object = dlg { + debug = true, + nam = 'Get object', + dsc = 'Select object to get.', + gen = function(s) + local k,v + objs(s):zap(); + for k,v in pairs(_G) do + if isObject(v) and not isRoom(v) and not isPlayer(v) and not v.debug and not have(v) and not isStatus(v) then + local n = call(v, 'nam'); + put(phr(n, '', k..':enable(); return take("'..k..'")'), s); + end + end + put (phr('Exit',nil, 'return back()'), s) + end +} + +drop_object = dlg { + debug = true, + nam = 'Drop object', + dsc = 'Select object to drop.', + gen = function(s) + local k,v + objs(s):zap(); + for k,v in pairs(_G) do + if isObject(v) and not isRoom(v) and not isPlayer(v) and not v.debug and have(v) then + local n = call(v, 'nam'); + put (phr(k,'','drop("'..k..'","'..deref(from())..'")'), s) + end + end + put (phr('Exit',nil, 'return back()'), s) + end +} + +debug_dlg = dlg { + debug = true, + nam = 'Debug Tool', + dsc = 'Select tool.', + obj = { + [1]=phr('Go to location...', true ,[[pon(1); choose_location:gen(); return goto('choose_location')]]), + [2]=phr('Get object...', true , [[pon(2); choose_object:gen(); return goto('choose_object')]]), + [3]=phr('Put object...', true , [[pon(3); drop_object:gen(); return goto('drop_object')]]), + [4]=phr('Exit',nil , [[pon(4); return back()]]), + }, +}; + +debug_tool = menu { + debug = true, + nam = txtb('debug'), + inv = function(s) + debug_dlg.__from__ = deref(here()); + me().where = 'debug_dlg'; -- force to go + local r = call(debug_dlg, 'enter'); + return r; + end +}; +putf('debug_tool', me());