duno 发表于 2009-7-1 08:13:42

help->content->scripting->function list->utils->msgbox

lkyun 发表于 2009-7-1 08:23:29

Lua function
utils.msgbox
Summary
Display a message box and get a response
Prototype
response = utils.msgbox ( msg, title, type, icon, default )

Description
This lets you display a Windows message box (very similar to MsgBox in VBscript). The intention is to allow you to display (in a small dialog box), information of an urgent nature, or ask a yes/no type question.
The calling sequence is:

result = utils.msgbox ( msg, title, type, icon, default )

The only required argument is the message text itself, the others default to their first possible value. The first 4 arguments are string arguments, the last is a number.
· msg = message to display (max 1000 characters)
· title = title of box - if nil, defaults to "MUSHclient" (max 100 characters)
· type = type of box (must be in lower case and exactly as shown here):

· "ok" - The message box contains one push button: OK. This is the default.
· "abortretryignore" - The message box contains three push buttons: Abort, Retry, and Ignore.
· "okcancel" - The message box contains two push buttons: OK and Cancel.
· "retrycancel" - The message box contains two push buttons: Retry and Cancel.
· "yesno" - The message box contains two push buttons: Yes and No.
· "yesnocancel" - The message box contains three push buttons: Yes, No, and Cancel.
· icon = type of icon:

· "!" - An exclamation-point icon appears in the message box. This is the default.
· "?" - A question-mark icon appears in the message box.
· "i" - An icon consisting of a lowercase letter i in a circle appears in the message box.
· "." - A stop-sign icon appears in the message box.
· default = default button (1 - 3)
This sets the default button (the one with the focus) to be either button 1, 2 or 3. The default is the first button.

Return value = (string) yes, no, ok, retry, ignore, cancel, abort
Example:

print (utils.msgbox ("You are being paged", "Warning!", "ok", "!", 1)) --> ok
print (utils.msgbox ("You are being paged")) --> ok
print (utils.msgbox ("Go ahead?", "Question", "yesno", "?")) --> yes / no

好复杂,勉强看懂了

sure 发表于 2009-7-1 08:25:46

Lua语言,楼上的比我快

maper 发表于 2009-7-1 09:34:58

原帖由 sure 于 2009-6-30 11:46 PM 发表 http://pkuxkx.com/forum/images/common/back.gif
maper比我牛,我只写了领悟、朱熹、红豆的trigger值得一提,maper做的是gps定位,超牛
sure 你太谦虚了,你的每一次出手都改变了游戏进程。ttk_05
我那个自动行走是参考别人的ttk_13

ddid 发表于 2009-7-1 09:59:14

duno,maper,sure == 已知的三位论坛中的MUSH高手 yct23

估计还有更多不怎么上论坛的……

上两张图,估计可以解释得更清楚:





需要注意第二张图中的第二个圆圈,那个“.”很重要。

[ 本帖最后由 ddid 于 2009-7-1 10:32 AM 编辑 ]

lkyun 发表于 2009-7-16 20:10:49

大家说的都是在trigger中用的,我在脚本中加入后总是提示出错啊,下面三种格式都有问题,谁能给个标准格式
world.utils.msgbox("答完了,退出!");
.utils.msgbox("答完了,退出!");
utils.msgbox("答完了,退出!");

maper 发表于 2009-7-16 20:23:51

引用怎么老是会出问题呢?
楼上的详细说说你在脚本中是怎么用的?包括触发,脚本语言等等。

[ 本帖最后由 maper 于 2009-7-16 08:24 PM 编辑 ]

lkyun 发表于 2009-7-16 20:33:46

function asktest()
{
var num=parseInt(world.GetVariable("ansnum"));
num=num+1;
world.send("tell bake "+num);
world.SetVariable("ansnum",num);
if(num==50)
{
world.SetVariable("ansnum",0);
utils.msgbox("答完了,退出!");
}
else
{
//world.SetVariable("fdnum",0);
world.DoAfter(3,"ask hongdou about test");
}
}
function testwait()
{
world.DoAfter(1,"ask hongdou about test");
}
function answertest()
{
var a=world.GetVariable("an");
var a1=world.GetVariable("an1");
var a2=world.GetVariable("an2");
var a3=world.GetVariable("an3");
var a4=world.GetVariable("an4");
switch (a) {
case a1:
   world.send("answer 1");
   break;
case a2:
   world.send("answer 2");
   break;
case a3:
   world.send("answer 3");
   break;
case a4:
   world.send("answer 4");
   break;
default:
   utils.msgbox("请手动回答!");
   break;
}
}


这是我在论坛上下的红豆机器人的脚本,红色这两句我想改成提示框弹出,但每次满足条件后mush就会报错说格式不对
触发里全是答案,就不必要贴上来了

[ 本帖最后由 lkyun 于 2009-7-16 08:42 PM 编辑 ]

maper 发表于 2009-7-16 20:41:51

utils.msgbox只能在lua语言下使用,而你使用的是js。

lkyun 发表于 2009-7-16 20:43:45

那我干脆tell另一个id,用zmud4.62里的#mess来提示,笨办法啊
页: 1 [2] 3
查看完整版本: 请会用mush和zmud的高手进来指点下