效果如下:
需要用到sscanf()函数: 从一个字符串中读进与指定格式相符的数据。
Action()
{
char s1[],s2[],s3[]; int n=atoi(lr_eval_string("{rand}"));//n从1开始取值 //int n=2;//n从1开始取值 int i=,l,y,m=,k=; int j=n-; lr_output_message("s1原始:%s", s1); sscanf(lr_eval_string("{num}"),"%s",s1);//作用:将num参数的值,赋值给s1字符串,也可以用字符串连接函数 sscanf(lr_eval_string("{rand}"),"%s",s2); lr_output_message("s1新值:%s", s1); while(s1[j]!='\0')//改if为while
{
s3[m]=s1[j];
m++;
j++;
}
s3[m] = '\0';//加入字符串结束标识
while(s2[i]!='\0')//改if为while
{
s1[n-+i]=s2[i];
i++;
} l=n+i-;
while(s3[k]!='\0')//改if为while
{
s1[l]=s3[k];
k++;
l++;
}
s1[l] = '\0';//加入字符串结束标识 lr_output_message("s1最终:%d", atoi(s1)); return ;
}
方法2:个人更新换脚本2
int Action()
{ //char s[10]="222222"; //长度为6,i的取值只能为0-6
//int i = 3;
char s[];
int i = atoi(lr_eval_string("{rand}"));
char *ss,*p,*ch; int j; sscanf(lr_eval_string("{num}"),"%s",s); lr_output_message("%s",s); p = s;
ss = (char *)malloc();
ch = ss; for(j = ;j <strlen(s)+;j++)
{
if(i == j)
{
*ss = 'A';
ss++;
}
else
{
*ss = *p;
ss++;
p++; }
} ss++; *ss ='\0' ; lr_output_message("%s",ch); }