| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 634 人关注过本帖
标题:[求助]如何循环运行?
只看楼主 加入收藏
nisila
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-7-8
收藏
 问题点数:0 回复次数:3 
[求助]如何循环运行?

我以前是学VB的,所以对于以下程序不是很理解,该程序运行了一次就结束了,我想让他不断的循环,请教高手,如何实现呢?

--------------------------------------------------

bool ShiftStory(int WareID)
{
if(IsWareUpStair(WareID) == 1)
{
if(Value("IsManUpStair") !=1)
{
GoUpStair(0);
}
if(Value("IsManUpStair") != 1)
{
ShowText("GoUpStair Error");
return false;
}
}
else
{
if(Value("IsManUpStair") == 1)
{
GoDownStair(0);
}
if(Value("IsManUpStair") == 1)
{
ShowText("GoDownStair Error");
return false;
}
}
return true;
}

bool ScriptContinueMakeItem(int ItemID)
{
if(ContinueMakeItem(ItemID) == 1)
{
while(IsMakingItem(ItemID) == 1)
{
Yield(0);
}
ShowText("Complete Make Item");
return true;
}
return false;
}


int MakeItem37247(int ItemCount)
{
if(IsFindItem(37247,ItemCount) == 1)
{
return 1;
}
return 0;
}

int MakeItem40035(int ItemCount)
{
if(IsFindItem(40035,ItemCount) == 1)
{
return 1;
}
return 0;
}

int MakeItem41142(int ItemCount)
{
if(IsFindItem(41142,ItemCount) == 1)
{
return 1;
}
if(IsHaveNecessaryItem(41142) != 1)
{
ShowText("Have not NecessaryItem 41142");
return 0;
}
if(!ShiftStory(39075))
{
return 0;
}
ScriptContinueMakeItem(41142);
if(IsFindItem(41142,ItemCount) == 1)
{
return 1;
}
int Count = 0;
int SubCount;
while(Count < ItemCount)
{
MakeItem41142Material();
if(MakeItem(41142) != 1)
{
SubCount = 0;
int Succ = 0;
while(SubCount < 2)
{
MakeItem41142Material();
if(MakeItem(41142) == 1)
{
Succ = 1;
break;
}
SubCount++;
Yield(0);
}
if(Succ == 0)
{
ShowText("MakeItem(41142) Failure");
return 0;
}
}
while(IsMakingItem(41142) == 1)
{
RefreshStat("IsMakingItem41142");
Yield(0);
}
if(IsFindItem(41142,ItemCount) == 1)
{
break;
}
Count++;
Yield(0);
}
if(IsFindItem(41142,ItemCount) == 1)
{
return 1;
}
return 0;
}

void MakeItem41142Material()
{
if(MakeItem37247(1) == 0)
{
ShowText("Make Item 37247 Failure");
return;
}
if(MakeItem40035(5) == 0)
{
ShowText("Make Item 40035 Failure");
return;
}
}

int MakeItem40030(int ItemCount)
{
if(IsFindItem(40030,ItemCount) == 1)
{
return 1;
}
return 0;
}

int MakeItem41052(int ItemCount)
{
if(IsFindItem(41052,ItemCount) == 1)
{
return 1;
}
if(IsHaveNecessaryItem(41052) != 1)
{
ShowText("Have not NecessaryItem 41052");
return 0;
}
if(!ShiftStory(39075))
{
return 0;
}
ScriptContinueMakeItem(41052);
if(IsFindItem(41052,ItemCount) == 1)
{
return 1;
}
int Count = 0;
int SubCount;
while(Count < ItemCount)
{
MakeItem41052Material();
if(MakeItem(41052) != 1)
{
SubCount = 0;
int Succ = 0;
while(SubCount < 2)
{
MakeItem41052Material();
if(MakeItem(41052) == 1)
{
Succ = 1;
break;
}
SubCount++;
Yield(0);
}
if(Succ == 0)
{
ShowText("MakeItem(41052) Failure");
return 0;
}
}
while(IsMakingItem(41052) == 1)
{
RefreshStat("IsMakingItem41052");
Yield(0);
}
if(IsFindItem(41052,ItemCount) == 1)
{
break;
}
Count++;
Yield(0);
}
if(IsFindItem(41052,ItemCount) == 1)
{
return 1;
}
return 0;
}

void MakeItem41052Material()
{
if(MakeItem37247(1) == 0)
{
ShowText("Make Item 37247 Failure");
return;
}
if(MakeItem40030(5) == 0)
{
ShowText("Make Item 40030 Failure");
return;
}
}

void MakeItem32280()
{
if(IsHaveNecessaryItem(32280) != 1)
{
ShowText("Have not NecessaryItem 32280");
return;
}
if(!ShiftStory(38010))
{
return;
}
if(ScriptContinueMakeItem(32280))
{
return;
}
MakeItem32280Material();
if(MakeItem(32280) != 1)
{
int Count = 0;
int Succ = 0;
while(Count < 2)
{
MakeItem32280Material();
if(MakeItem(32280) == 1)
{
Succ = 1;
break;
}
Count++;
Yield(0);
}
if(Succ == 0)
{
ShowText("MakeItem(32280) Failure");
return;
}
}
while(IsMakingItem(32280) == 1)
{
RefreshStat("IsMakingItem32280");
Yield(0);
}
}

void MakeItem32280Material()
{
if(MakeItem41142(40) == 0)
{
ShowText("Make Item 41142 Failure");
return;
}
if(MakeItem41052(10) == 0)
{
ShowText("Make Item 41052 Failure");
return;
}
}

{
if (Value("InTent") ==0)
{
PutDownTent(0);
EnterTent(0);
if (Value("InTent") ==0)
{
ShowText("Enter Tent Fail");
return;
}
}
MakeItem32280();
}

搜索更多相关主题的帖子: 运行 
2007-07-08 11:24
静夜嘶
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2007-7-2
收藏
得分:0 

兄弟,太长啦,看得眼花缭乱.
我想你把错误的关键部分贴出来比较好.


2007-07-08 12:27
卧龙孔明
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:59
帖 子:3872
专家分:684
注 册:2006-10-13
收藏
得分:0 
int I;
for(I=0;I<循环次数;I++)
{


bool ShiftStory(int WareID)
{
if(IsWareUpStair(WareID) == 1)
{
if(Value("IsManUpStair") !=1)
{
GoUpStair(0);
}
if(Value("IsManUpStair") != 1)
{
ShowText("GoUpStair Error");
return false;
}
}
else
{
if(Value("IsManUpStair") == 1)
{
GoDownStair(0);
}
if(Value("IsManUpStair") == 1)
{
ShowText("GoDownStair Error");
return false;
}
}
return true;
}

bool ScriptContinueMakeItem(int ItemID)
{
if(ContinueMakeItem(ItemID) == 1)
{
while(IsMakingItem(ItemID) == 1)
{
Yield(0);
}
ShowText("Complete Make Item");
return true;
}
return false;
}


int MakeItem37247(int ItemCount)
{
if(IsFindItem(37247,ItemCount) == 1)
{
return 1;
}
return 0;
}

int MakeItem40035(int ItemCount)
{
if(IsFindItem(40035,ItemCount) == 1)
{
return 1;
}
return 0;
}

int MakeItem41142(int ItemCount)
{
if(IsFindItem(41142,ItemCount) == 1)
{
return 1;
}
if(IsHaveNecessaryItem(41142) != 1)
{
ShowText("Have not NecessaryItem 41142");
return 0;
}
if(!ShiftStory(39075))
{
return 0;
}
ScriptContinueMakeItem(41142);
if(IsFindItem(41142,ItemCount) == 1)
{
return 1;
}
int Count = 0;
int SubCount;
while(Count < ItemCount)
{
MakeItem41142Material();
if(MakeItem(41142) != 1)
{
SubCount = 0;
int Succ = 0;
while(SubCount < 2)
{
MakeItem41142Material();
if(MakeItem(41142) == 1)
{
Succ = 1;
break;
}
SubCount++;
Yield(0);
}
if(Succ == 0)
{
ShowText("MakeItem(41142) Failure");
return 0;
}
}
while(IsMakingItem(41142) == 1)
{
RefreshStat("IsMakingItem41142");
Yield(0);
}
if(IsFindItem(41142,ItemCount) == 1)
{
break;
}
Count++;
Yield(0);
}
if(IsFindItem(41142,ItemCount) == 1)
{
return 1;
}
return 0;
}

void MakeItem41142Material()
{
if(MakeItem37247(1) == 0)
{
ShowText("Make Item 37247 Failure");
return;
}
if(MakeItem40035(5) == 0)
{
ShowText("Make Item 40035 Failure");
return;
}
}

int MakeItem40030(int ItemCount)
{
if(IsFindItem(40030,ItemCount) == 1)
{
return 1;
}
return 0;
}

int MakeItem41052(int ItemCount)
{
if(IsFindItem(41052,ItemCount) == 1)
{
return 1;
}
if(IsHaveNecessaryItem(41052) != 1)
{
ShowText("Have not NecessaryItem 41052");
return 0;
}
if(!ShiftStory(39075))
{
return 0;
}
ScriptContinueMakeItem(41052);
if(IsFindItem(41052,ItemCount) == 1)
{
return 1;
}
int Count = 0;
int SubCount;
while(Count < ItemCount)
{
MakeItem41052Material();
if(MakeItem(41052) != 1)
{
SubCount = 0;
int Succ = 0;
while(SubCount < 2)
{
MakeItem41052Material();
if(MakeItem(41052) == 1)
{
Succ = 1;
break;
}
SubCount++;
Yield(0);
}
if(Succ == 0)
{
ShowText("MakeItem(41052) Failure");
return 0;
}
}
while(IsMakingItem(41052) == 1)
{
RefreshStat("IsMakingItem41052");
Yield(0);
}
if(IsFindItem(41052,ItemCount) == 1)
{
break;
}
Count++;
Yield(0);
}
if(IsFindItem(41052,ItemCount) == 1)
{
return 1;
}
return 0;
}

void MakeItem41052Material()
{
if(MakeItem37247(1) == 0)
{
ShowText("Make Item 37247 Failure");
return;
}
if(MakeItem40030(5) == 0)
{
ShowText("Make Item 40030 Failure");
return;
}
}

void MakeItem32280()
{
if(IsHaveNecessaryItem(32280) != 1)
{
ShowText("Have not NecessaryItem 32280");
return;
}
if(!ShiftStory(38010))
{
return;
}
if(ScriptContinueMakeItem(32280))
{
return;
}
MakeItem32280Material();
if(MakeItem(32280) != 1)
{
int Count = 0;
int Succ = 0;
while(Count < 2)
{
MakeItem32280Material();
if(MakeItem(32280) == 1)
{
Succ = 1;
break;
}
Count++;
Yield(0);
}
if(Succ == 0)
{
ShowText("MakeItem(32280) Failure");
return;
}
}
while(IsMakingItem(32280) == 1)
{
RefreshStat("IsMakingItem32280");
Yield(0);
}
}

void MakeItem32280Material()
{
if(MakeItem41142(40) == 0)
{
ShowText("Make Item 41142 Failure");
return;
}
if(MakeItem41052(10) == 0)
{
ShowText("Make Item 41052 Failure");
return;
}
}

{
if (Value("InTent") ==0)
{
PutDownTent(0);
EnterTent(0);
if (Value("InTent") ==0)
{
ShowText("Enter Tent Fail");
return;
}
}
MakeItem32280();
}

}


My Blog: www.aiexp.info
虽然我的路是从这里开始的,但是这里不再是乐土.感谢曾经影响过,引导过,帮助过我的董凯,飞燕,leeco,starwing,Rockcarry,soft_wind等等等等.别了,BCCN.
2007-07-08 17:24
卧龙孔明
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:59
帖 子:3872
专家分:684
注 册:2006-10-13
收藏
得分:0 
如果要永远循环下去可以将3楼的红字部分改为:
while(1)
{

.........
.........
}

My Blog: www.aiexp.info
虽然我的路是从这里开始的,但是这里不再是乐土.感谢曾经影响过,引导过,帮助过我的董凯,飞燕,leeco,starwing,Rockcarry,soft_wind等等等等.别了,BCCN.
2007-07-08 17:25
快速回复:[求助]如何循环运行?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017313 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved