Yalnizxyz Footman Posted April 25, 2017 Posted April 25, 2017 int i=1; if (i<5); { Scanner klavye = new Scanner(System.in); System.out.println(“Please enter a numbers:”); a[ i ] = scan.nextInt(); System.out.println(a[ i ]); i +=1; } Thanks for answers...
Rolig Loon Posted April 25, 2017 Posted April 25, 2017 Study sections in the LSL wiki for llDialog and llSay. The first example in the page for llDialog should be very easy to adapt for your use.
Yalnizxyz Footman Posted April 25, 2017 Author Posted April 25, 2017 5 minutes ago, Rolig Loon said: Study sections in the LSL wiki for llDialog and llSay. The first example in the page for llDialog should be very easy to adapt for your use. Thanks for answer. But i want know , how i can write a[ i ] array, in LSL? Sory for english..
Love Zhaoying Posted April 25, 2017 Posted April 25, 2017 5 minutes ago, Yalnizxyz Footman said: Thanks for answer. But i want know , how i can write a[ i ] array, in LSL? There are no arrays in LSL. Strings and Lists are the closest you will come. As Rolig said, the example may show you enough information to get started.
Xiija Posted April 25, 2017 Posted April 25, 2017 (edited) you can do arrays with json? JsonGetValue JsonSetValue llJson2List llList2Json Here is a small example by Dora on how to use json that i was playing with, ... there should be forum posts on Json somewhere.... // JSON array forum example by Dora Gustafson, Studio Dora 2013 // Building an 3 by 5 array in a JSON Object // Rows are indexed by name and columns are indexed by number = 0,1,2,3,4 string JSONVotes; string JSONVotes2; tellVotes( string voter) { string Js = llJsonGetValue( JSONVotes, [voter]); list Jl = llParseString2List( Js,[",","[","]","\""],[]); string output = llDumpList2String( Jl, ", "); llOwnerSay( "Votes from "+voter+" are: "+output); } integer x; string Main; string votes; default { state_entry() { // Building the JSON object votes = llList2Json( JSON_ARRAY, [0, 0, 0, 0, 0]); // one row // Main = llList2Json( JSON_OBJECT, ["MAIN",JSONVotes] ); <--- cannot define before or will be null JSONVotes2 = llList2Json( JSON_OBJECT, [ "Betty2", votes, "Jerry2", votes, "Pierre2", votes]); // complete object JSONVotes = llList2Json( JSON_OBJECT, [ "Betty", votes, "Jerry", votes, "Pierre", votes]); // complete object Main = llList2Json( JSON_OBJECT, ["MAIN",JSONVotes] ); //<--- top lvl defined last } touch_end( integer num) { // Testing the JSON object ++x; llOwnerSay( "main before " + Main); string name = llDetectedName(0); Main += (string) llList2Json( JSON_OBJECT, ["SECOND", JSONVotes2] ); llOwnerSay( "main after " + Main); } } Edited April 25, 2017 by Xiija
Ela Talaj Posted April 25, 2017 Posted April 25, 2017 Firstly, there is a typo in your C++ code in the original post. On line 2: " if (i<5); " you appear to have an erroneous semicolon at the end. so it wouldn't do what you expect it to do Secondly, as other responders already mentioned, there's no arrays in LSL. The way around it is using lists. If it helps any, LSL lists are very similar to Python lists. Actually you can even emulate C++ array of structures using LSL strided lists, just have to be careful in indexing. The main thing to remember using lists is that LSL has no concept of reference so you put a whole object on the stack instead of a reference to object. Considering LSL memory restrictions it might be tricky to accommodate large lists.
Recommended Posts
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