Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Set shuffle value

Registered User
2024-04-01 00:58:37

Hi am new, do anyone know how to set shuffle value of a variable instead of the random value. (like it will not repeate a value more than once till all value are selected)

2024-04-01 05:59:19

You would need to use the Execute Java Script action to do this. Here's some code:

var cards = [1, 2, 3, 4, 5]; // Array of cards

// Function to shuffle the cards array randomly
function shuffle(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]]; // Swap elements
return array;

var shuffled = shuffle(cards); // Shuffled deck

// Function to pick a random card from the deck and remove it
function pickCard(array) {
var randomIndex = Math.floor(Math.random() * array.length); // Get random index
var pickedCard = array.splice(randomIndex, 1)[0]; // Remove and return picked card
return pickedCard;

var card = pickCard(shuffled); // Picked card
print(card); // Output picked card

Feel free to ask if you have any questions. Welcome to CopperCube!

Registered User
2024-04-01 15:48:56

Thanks bro, i will check the code when i am free

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Inter?ational" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact