-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnft-generator.sh
105 lines (86 loc) · 2.3 KB
/
nft-generator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# pick-card.sh
# This is an example of choosing random elements of an array.
# Get the possible combinations/characteristics from the "load" file
. ./load
# Note variables spread over multiple lines.
# Read into array variable.
background=($Backgrounds)
eye=($Eyes)
# Count how many elements.
num_backgrounds=${#background[*]}
num_eyes=${#eye[*]}
nftno="1"
mkdir nfts/test
if [ ! -f nfts/test/1.txt ]; then
background_result="${background[$((RANDOM%num_backgrounds))]}"
eye_result="${eye[$((RANDOM%num_eyes))]}"
echo "$background_result $eye_result" >> nfts/test/$nftno.txt
echo "Background: $background_result"
echo "Eye: $eye_result"
find_duplicate="$background_result $eye_result"
nftno="$(($nftno + 1))"
fi
generate () {
background_result="${background[$((RANDOM%num_backgrounds))]}"
eye_result="${eye[$((RANDOM%num_eyes))]}"
find_duplicate="$background_result $eye_result"
}
#save () {
#echo "$background_result $eye_result" >> nfts/test/$nftno.txt
#echo "Background: $background_result"
#echo "Eye: $eye_result"
#nftno="$(($nftno + 1))"
#}
save () {
}
duplicate_check_loop () {
generate
for filename in nfts/test/*.txt; do
if [ "$(cat $filename)" = "$find_duplicate" ]; then
echo "Duplicate reached! Skipping..."
else
save
fi
done
}
#if [ -f nfts/test/1.txt ]; then
#
#fi
#while true; do
#
#done
#if [ -f nfts/test/1.txt ]; then
# while true; do
# duplicate_check_loop
#done
#fi
#if [ -f nfts/test/1.txt ]; then
# duplicate_check_loop
# (bash nft-generator.sh &)
#fi
#if [ -f nfts/test/1.txt ]; then
# while true; do
# duplicate_check_loop
# sleep 5s
#done
#fi
#if [ -f nfts/test/1.txt ]; then
# while true; do
# for filename in nfts/test/*.txt; do
# background_result="${background[$((RANDOM%num_backgrounds))]}"
# eye_result="${eye[$((RANDOM%num_eyes))]}"
# find_duplicate="$background_result $eye_result"
# if [ "$(cat $filename)" = "$find_duplicate" ]; then
# echo "Duplicate reached! Skipping..."
# else
# echo "$background_result $eye_result" >> nfts/test/$nftno.txt
# echo "Background: $background_result"
# echo "Eye: $eye_result"
# nftno="$(($nftno + 1))"
#fi
#done
#done
#fi
exit 0
#- from: https://tldp.org/LDP/abs/html/randomvar.html