Jump to content

Speaking randomly selected name.


MightOverwhelm
 Share

You are about to reply to a thread that has been inactive for 4258 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

default {

  touch_start(integer total_number)

// Enlist the card #1 to #22

  {      list cardList = ["c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8","c9", "c10", "c11", "c12", "c13", "c14", "c15", "c16", "c17", "c18", "c19", "c20", "c21", "c22"];

// Randomize Order the Cards

    cardList = llListRandomize(cardList , 1 );

// Delete the card after 11th

    TarotList = llDeleteSubList(cardList, 10, 21);

//Object say the randomized 10 cards

    llOwnerSay((string)TarotList );

  }

}

 

I need help on the scope or something else.

This code is not working somehow how should I fix?

Link to comment
Share on other sites

It would be good, if you could be a little more specific about the problem you have with the script - especially, since the lines you posted seem to be just a part of the script - e.g. you never declared TarotList in the script you posted.

And a little hint: use the little symbol with the C in it to post code.

  • Like 1
Link to comment
Share on other sites


MightOverwhelm wrote:

default {

  touch_start(integer total_number)

 { ...

    TarotList = llDeleteSubList(cardList, 10, 21);

  }

}

 

I need help on the scope ...

TarotList is out of scope bc is not declared in the event. or is not declared globally. so declare like:

list TarotList = ...

LSL is a typed language. meaning in this case you have to explicitly declare the variable type. unlike say in Basic, if you come from that background, where you dont have to  

 

 

Link to comment
Share on other sites

default {

  touch_start(integer total_number)

// Enlist the card #1 to #22

  {      list cardList = ["c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8","c9", "c10", "c11", "c12", "c13", "c14", "c15", "c16", "c17", "c18", "c19", "c20", "c21", "c22"];

// Randomize Order the Cards

    cardList = llListRandomize(cardList , 1 );

// Delete the card after 11th

    list TarotList = llDeleteSubList(cardList, 10, 21);

//Object say the randomized 10 cards

    llOwnerSay((string)TarotList );

  }

}

 So it this how to do it>?

Link to comment
Share on other sites

Thanks for helping my first step. But I have another problems.

 

default {
//Touch to activate the tool
touch_start(integer total_number)
{
//Declaring The Fool can be Truth or Reverth
list FoolCheck = ["The Fool (Truth)", "The Fool (Reverth)"];
//Randomly selecting Truth or Reverth
FoolCheck = llListRandomize(FoolCheck , 1 );
//Fool will displays Truth or Reverth The Fool
list Fool = llDeleteSubList(FoolCheck, 1,1 );

//Similar thing with above.
list MagiCheck = ["The Magician (Truth)", "The Magician (Reverth)"];
MagiCheck = llListRandomize(MagiCheck , 1 );
list Magician = llDeleteSubList(MagiCheck, 1,1 );

//I hope it will say The Fool truth or Reverth and The magician Truth or Reverth but it just say Fool and Magician
list cardlist = ["Fool", "Magician"];
llOwnerSay((string)cardlist );
}
}

 

Since tarot their is Truth and Reverth every time open cards.

I decided to do the process of above so script will randomly select Truth or Reverth but it does not works :(

Link to comment
Share on other sites

You went to all the trouble of winnowing the lists named "Fool" and "Magician" down to one name each and then you ignored them in the end and wrote

list cardlist = ["Fool", "Magician"];
llOwnerSay((string)cardlist );

Of course it's going to say either "Fool" or "Magician".  Those two words are the only choices in the list called cardlist.  If you want to say the contents of the list named "Fool" and the list named "Magician", forget about cardlist.  Just write

llOwnerSay ( (string) Fool + "   " + (string) Magician);       :smileywink:

Link to comment
Share on other sites

default {
//Touch to activate the tool
touch_start(integer total_number)
{
//Declaring The Fool can be Truth or Reverth
//Randomly selecting Truth or Reverth
//Fool will displays Truth or Reverth The Fool

//<--! Card Checking Process----

//The Fool
list FoolCheck = ["The Fool (Truth)", "The Fool (Reverse)"];
FoolCheck = llListRandomize(FoolCheck , 1 );
list Fool = llDeleteSubList(FoolCheck, 1,1 );

//The Magician
list MagiCheck = ["The Magician (Truth)", "The Magician (Reverse)"];
MagiCheck = llListRandomize(MagiCheck , 1 );
list Magician = llDeleteSubList(MagiCheck, 1,1 );

//The High Priestess
list HiPrCheck = ["The High Priestess (Truth)", "The High Priestess (Reverse)"];
HiPrCheck = llListRandomize(HiPrCheck , 1 );
list HighPrietess = llDeleteSubList(HiPrCheck, 1,1 );

//The Empress
list EmprCheck = ["The Empress (Truth)", "The Empress (Reverse)"];
EmprCheck = llListRandomize(EmprCheck , 1 );
list Empress = llDeleteSubList(EmprCheck, 1,1 );

//The Emperor
list EmorCheck = ["The Emperor (Truth)", "The Emperor (Reverse)"];
EmorCheck = llListRandomize(EmorCheck , 1 );
list Emperor = llDeleteSubList(EmorCheck, 1,1 );

//The Hierophant
list HierCheck = ["The Hierophant (Truth)", "The Hierophant (Reverse)"];
HierCheck = llListRandomize(HierCheck , 1 );
list Hierophant = llDeleteSubList(HierCheck, 1,1 );

//The Lovers
list LoveCheck = ["The Lovers (Truth)", "The Lovers (Reverse)"];
LoveCheck = llListRandomize(LoveCheck , 1 );
list Lovers = llDeleteSubList(LoveCheck, 1,1 );

//The Chariot
list CharCheck = ["The Chariot (Truth)", "The Chariot (Reverse)"];
CharCheck = llListRandomize(CharCheck , 1 );
list Chariot = llDeleteSubList(CharCheck, 1,1 );

//Justice
list JustCheck = ["Justice (Truth)", "Justice (Reverse)"];
JustCheck = llListRandomize(JustCheck , 1 );
list Justice = llDeleteSubList(JustCheck, 1,1 );

//The Hermit
list HermCheck = ["The Hermit (Truth)", "The Hermit (Reverse)"];
HermCheck = llListRandomize(HermCheck , 1 );
list Hermit = llDeleteSubList(HermCheck, 1,1 );

//Wheel of Fortune
list WheelCheck = ["Wheel of Fortune (Truth)", "Wheel of Fortune (Reverse)"];
WheelCheck = llListRandomize(WheelCheck , 1 );
list Wheel = llDeleteSubList(WheelCheck, 1,1 );

//Strength
list StreCheck = ["Strength (Truth)", "Strength (Reverse)"];
StreCheck = llListRandomize(StreCheck , 1 );
list Strength = llDeleteSubList(StreCheck, 1,1 );

//The Hanged Man
list HangCheck = ["The Hanged Man (Truth)", "The Hanged Man (Reverse)"];
HangCheck = llListRandomize(HangCheck , 1 );
list Hanged = llDeleteSubList(HangCheck, 1,1 );

//Death
list DeathCheck = ["Death (Truth)", "Death (Reverse)"];
DeathCheck = llListRandomize(DeathCheck , 1 );
list Death = llDeleteSubList(DeathCheck, 1,1 );

//Temperance
list TempCheck = ["Temperance (Truth)", "Temperance (Reverse)"];
TempCheck = llListRandomize(TempCheck , 1 );
list Temperance = llDeleteSubList(TempCheck, 1,1 );

//The Devil
list DevilCheck = ["The Devil (Truth)", "The Devil (Reverse)"];
DevilCheck = llListRandomize(DevilCheck , 1 );
list Devil = llDeleteSubList(DevilCheck, 1,1 );

//The Tower
list TowerCheck = ["The Tower (Truth)", "The Tower (Reverse)"];
TowerCheck = llListRandomize(TowerCheck , 1 );
list Tower = llDeleteSubList(TowerCheck, 1,1 );

//The Star
list StarCheck = ["The Star (Truth)", "The Star (Reverse)"];
StarCheck = llListRandomize(StarCheck , 1 );
list Star = llDeleteSubList(StarCheck, 1,1 );

//The Moon
list MoonCheck = ["The Moon (Truth)", "The Moon (Reverse)"];
MoonCheck = llListRandomize(MoonCheck , 1 );
list Moon = llDeleteSubList(MoonCheck, 1,1 );

//The Sun
list SunCheck = ["The Sun (Truth)", "The Sun (Reverse)"];
SunCheck = llListRandomize(SunCheck , 1 );
list Sun = llDeleteSubList(SunCheck, 1,1 );

//Judgement
list JudgeCheck = ["The Judge (Truth)", "The Judge (Reverse)"];
JudgeCheck = llListRandomize(JudgeCheck , 1 );
list Judge = llDeleteSubList(JudgeCheck, 1,1 );

//The World
list WorldCheck = ["The World (Truth)", "The World (Reverse)"];
WorldCheck = llListRandomize(WorldCheck , 1 );
list World = llDeleteSubList(WorldCheck, 1,1 );

//--!> Card Process Fin

//<!-- Enlisting the card
list TarotCardList = ["(string) Fool", "(string) Magician", "(string) HighPrietess", "(string) Empress", "(string) Emperor", "(string) Hierophant", "(string) Lovers", "(string) Chariot", "(string) Justice", "(string) Hermit", "(string) Wheel", "(string) Strength", "(string) Hanged", "(string) Death", "(string) Temperance", "(string) Devil", "(string) Tower", "(string) Star", "(string) Moon", "(string) Sun", "(string) Judge", "(string) World"];
TarotCardList = llListRandomize(TarotCardList , 1 );
list TarotList = llDeleteSubList(TarotCardList, 10, 21);
llOwnerSay((string)TarotList );
//What I try do is Randomized selected 10 talot card will display with result of truth or revirth but object say (String)+Name of card which as like in code.

}
}

Link to comment
Share on other sites

Hmmmm...   You are still saying the words "Devil", "Chariot" and so on, only now you have added the word "(String)" to each one.   You're still not getting the idea of reading a variable from one of those lists.  Each time you do your randomize and squash exercises, you end up with a list that has only one variable in it.  There are two ways to say that variable.  One way is to say llSay(0, llList2String(Devil,0)) or whatever the list is.   The other way is to say the entire list as a string, like this ..... llSay(0,(string)Devil).   Either way works in this case, because you only have one variable per list.  The first way is more generalizable, so that's what most scripters would prefer.

Now, you really don't need all those lists. They're a waste of memory and they make for an unnecessarily long code.

Here's a way to compress it into fewer steps.

list gCards = ["The Fool","The Magician","The High Priestess","The Empress","The Emperor","The Hierophant","The Lovers","The Chariot","Justice","The Hermit","Wheel of Fortune","Strength","The Hanged Man","Death","Temperance","The Devil","The Tower","The Star","The Moon","The Sun","The Judge","The World"];default{    touch_start(integer total_number)    {        list cardlist = [];        integer i;        while ( i< (gCards!=[]) )  //(gCards !=[]) == llGetListLength(gCards)        {            string Side = llList2String([" (Truth)", " (Reverse)"],llFloor(llFrand(2.0)));            cardlist += [llList2String(gCards,i) + Side];            ++i;        }        llSay(0," \n" + llDumpList2String(cardlist," \n"));    }}

 

Link to comment
Share on other sites

Well, each of your choices are just binary decisions ("Truth" or "Reverse"), so the only work should be to pick one at random and apply it to a card name.  For that, all you need is a list of the card names and a way to loop through them one at a time and add your random choice.  The only mild trick is making the random choice itself.  That easily done by making a short list ["Truth" or "Reverse"] and writing "pick one".....

       string Side =  llList2String([" Truth" , " Reverse"], llFloor(llFrand(2.0)) );

Add the choice to the card name, save it in a list to be read out later, rinse, and repeat. 

Syntax is rarely the big stumbling block in writing scripts.  You can always look up the functions in the wiki, and the more you work with the common ones, the less you have to think about them.  The big challenge (and the fun) is always logic-- figuring out where you want to go, assessing what you need to know to get there, and working out a map to connect the two ends of the project.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4258 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...