csbx Posted May 14, 2018 Share Posted May 14, 2018 (edited) The purpose of the following script is to randomize where quest items for my quest are placed. 'drug01' - 'drug03' are the quest items'drugX01' - 'drugX05' are xmarkers the items are randomly distributed to. When entering the cell for the first time, this script runs, moving the items (already in the cell) to the various xmarkers--randomly. When I run this, only the first item gets moved and the second two remain in their original place in the cell. I know it's something stupid that I'm missing. Any help would be appreciated. EDIT: THIS IS UPDATED AND NOW WORKS AS WRITTEN----------------- int i = Utility.randomInt(1, 5) if i == 1 Drug01.MoveTo(DrugX01) Elseif i == 2 Drug01.MoveTo(DrugX02) Elseif i == 3 Drug01.MoveTo(DrugX03) Elseif i == 4 Drug01.MoveTo(DrugX04) Elseif i == 5 Drug01.MoveTo(DrugX05) ElseEndif int jWhile ((j == i) || (j == 0)) j = Utility.randomInt(1, 5)Endwhile if j == 1 Drug02.MoveTo(DrugX01) Elseif j == 2 Drug02.MoveTo(DrugX02) Elseif j == 3 Drug02.MoveTo(DrugX03) Elseif j == 4 Drug02.MoveTo(DrugX04) Elseif j == 5 Drug02.MoveTo(DrugX05) ElseEndif int kWhile ((k == i) || (k== j) || (k == 0)) k = Utility.randomInt(1, 5)Endwhile if k == 1 Drug03.MoveTo(DrugX01) Elseif k == 2 Drug03.MoveTo(DrugX02) Elseif k == 3 Drug03.MoveTo(DrugX03) Elseif k == 4 Drug03.MoveTo(DrugX04) Elseif k == 5 Drug03.MoveTo(DrugX05) ElseEndif debug.notification(i)debug.notification(j)debug.notification(k) Edited May 14, 2018 by csbx Link to comment Share on other sites More sharing options...
Reneer Posted May 14, 2018 Share Posted May 14, 2018 (edited) In your While loops you only want "j/k = Utility.RandomInt" not "j/k == Utility.RandomInt". Edited May 14, 2018 by Reneer Link to comment Share on other sites More sharing options...
csbx Posted May 14, 2018 Author Share Posted May 14, 2018 Yes. Thanks, man. I also found a couple of more errors (not including the 0 possibility when entering the loop after declaring the int. AND when I copied the cases I forgot to change the variable from i to j, then k. Works beautifully now. I'll probably come back to this script to re-use in lots of spots. Thanks again !In your While loops you only want "j/k = Utility.RandomInt" not "j/k == Utility.RandomInt". Link to comment Share on other sites More sharing options...
Reneer Posted May 14, 2018 Share Posted May 14, 2018 Happy to help. :) Link to comment Share on other sites More sharing options...
Recommended Posts