gpt4 book ai didi

linden-scripting-language - 如何从 LSL 的记事卡中读取随机行?

转载 作者:行者123 更新时间:2023-12-02 02:37:01 24 4
gpt4 key购买 nike

我有一张记事卡,每行都有一个不同的词,我希望能够从这些行中随机选择。我该怎么做?

最佳答案

首先,正如您提到的,您需要一张记事卡。对于这个例子,我使用了一个名为“colors”的内容如下:

red
blue
green
yellow
orange
purple

有了那个记事卡,每次触摸 prim 时,下面的脚本都会从卡片中读取并随机聊天一行。

//this script will grab and chat a random line from the "colors" notecard each time the prim is touched.

string card = "colors";
key linecountid;
key lineid;
integer linemax;

integer random_integer( integer min, integer max )
{
return min + (integer)( llFrand( max - min + 1 ) );
}


default
{
state_entry()
{
//get the number of notecard lines
linecountid = llGetNumberOfNotecardLines(card);
}

touch_start(integer total_number)
{
lineid = llGetNotecardLine(card, random_integer(0, linemax));
}

dataserver(key id, string data)
{
if (id == linecountid)
{
linemax = (integer)data - 1;
}
else if (id == lineid)
{
llSay(0, data);
}
}
}

关于linden-scripting-language - 如何从 LSL 的记事卡中读取随机行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1040488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com