mob
var
listtlength = 0
listt = list(new/obj/test1,new/obj/test2,new/obj/test3)
listttwo = list()
proc
test()
if(src.listtlength <= 5)
var/o = pick(src.listt)
o += src.listttwo
src.test()
obj
test1
test2
test3
ID:171764
Aug 13 2004, 7:17 am (Edited on Aug 13 2004, 9:15 am)
|
|
how do i make a proc that will randomly pick a given number of objs from a list and then put them in another list?
|
In response to Hell Ramen
|
|
i want it to automatically add it to the list, and not the players contents.i dont want to type out 1000 if()'s -_-
thanks for tryin to help i guess |
In response to Kablez
|
|
Sorry, I'm kind of bad at helping people... =/
Because I kinda'... suck at coding. |
In response to Hell Ramen
|
|
Hell Ramen wrote:
proc That should work. No it shouldn't. You can't add a string to contents, and your indentation is all wrong. And no put usr in proc. Ungh. Lummox JR |
In response to Lummox JR
|
|
yes lummox we already figured it out shouldnt work, why dont you help me instead?
|
In response to Kablez
|
|
Kablez wrote:
yes lummox we already figured it out shouldnt work, why dont you help me instead? Because you didn't provide enough context to be clear on what you were asking. What exactly are you trying to do? Be as specific as possible. Lummox JR |
In response to Lummox JR
|
|
thats as specific as i can get, i want exactly what i typed in,
//something like this but works |
In response to Kablez
|
|
Kablez wrote:
thats as specific as i can get, No it's not. It might be as specific as you're willing to get, but if you can't communicate the problem better you may as well give up on ever getting help on anything. For any issue you have, you'll need some level of detail. In the example code you posted I did notice one glaring flaw: Your lists aren't defined as var/list, so you're not using list.len to figure out their length. This matters because your var listtlength is never being updated, and it's kinda superfluous anyway because you should use list.len instead. Lummox JR |
In response to Lummox JR
|
|
heh oops i wasnt paying attention when i was typing that code out(just made it up when i saw your post)i guess i was to busy fixing usr to src to noticed i forgot to add src.listlength ++
|
In response to Kablez
|
|
Kablez wrote:
heh oops i wasnt paying attention when i was typing that code out(just made it up when i saw your post)i guess i was to busy fixing usr to src to noticed i forgot to add src.listlength ++ But the point is, you don't need that var at all. The list itself knows its length; use that. Lummox JR |
Kablez wrote:
how do i make a proc that will randomly pick a given number of objs from a list and then put them in another list? > mob Ok, first, you will need to find out how many objects are going to be moved. Depending on what you want, from 0 to the length of the first list sounds fine. So with this information, you can use rand() to find that out. Next, you would want to loop while the previous variable(randomised number) is still above 0, and the from the first list, using pick(), get an object, and move it into the second list. |
That should work.
Also, you need to make the variable, so meh. :P
And, for more proccessess... just add another one, like Rand_OBJ2(). =/ That should work, I didn't test it.