|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Akiros Newbie cheater Reputation: 0
Joined: 11 Apr 2020 Posts: 24 Location: my house
|
Posted: Sat Jul 30, 2022 3:08 pm Post subject: Need help with this please |
|
|
Hello, I have a project that has a feature of generating random strings made of 10 variables put together. I am just unsure on how to grab them randomly.
I need the script to arrange the variables to be printed randomly.
example:
a="asa"
b="2ws"
c="d30"
d="4ds"
e="gfv"
print(a, b)
print(c, b)
print(d, b)
print(e, b)
(without having to write down every single one)
This is what ive got so far:
-------------------------------------------------------------------------
a="aos"
b="daf"
c="4de"
d="1es"
e="d2a"
loop=0
function generate(sender)
print(a, b)
if loop~="5" then
loop=loop+1
generate()
end
end
generate()
----------------------------------------------------------------------
Any help is appreciated
_________________
help pls im noob |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Sat Jul 30, 2022 3:53 pm Post subject: |
|
|
I'm just giving an example to understand what you want.
If you want something different, just say it.
Code: | mTbl = {"asa",
"2ws",
"d30",
"4ds",
"gfv"}
function generate(tbl,loop)
res = ""
for i,k in pairs(tbl) do
if i~=loop then
res = res .. k .. " " .. tbl[loop] .. "\n"
--print(res)
end
end
return res
end
a = generate(mTbl,1)
b = generate(mTbl,2)
c = generate(mTbl,3)
print("-----a:\n" .. a)
print("-----b:\n" .. b)
print("-----c:\n" .. c) |
result:
-----a:
2ws asa
d30 asa
4ds asa
gfv asa
-----b:
asa 2ws
d30 2ws
4ds 2ws
gfv 2ws
-----c:
asa d30
2ws d30
4ds d30
gfv d30
_________________
|
|
Back to top |
|
|
Akiros Newbie cheater Reputation: 0
Joined: 11 Apr 2020 Posts: 24 Location: my house
|
Posted: Sat Jul 30, 2022 5:04 pm Post subject: Thank you ! |
|
|
This is exactly what I am looking for. However I would like to know if instead of pairs in line 9, I could add more so the output would be like this.
output:
-----a:
2ws 3ds asa
d30 2ws asa
4ds gfv asa
gfv d30 asa
(still random with the ending being controllable)
also if there is any way to remove space as it is not cooperable
_________________
help pls im noob |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Sat Jul 30, 2022 5:12 pm Post subject: |
|
|
This way it produces an ordered result.
Will this be a problem?
Code: | mTbl = {"B1",
"B2",
"B3",
"B4"
}
nTbl = {"A3",
"A4",
"A5",
"A6"
}
function generate(atbl,btbl,loop)
res = ""
s = ""
for i,k in pairs(btbl) do
--if i~=loop then s = atbl[loop] end
res = res .. k .. " " .. atbl[loop] .. "\n"
--print(res)
--end
end
return res
end
a = generate(mTbl,nTbl,1) --mtbl 1
c = generate(nTbl,mTbl,3) --ntbl 3
print("-----a:\n" .. a)
print("-----c:\n" .. c) |
EDIT:
Code: | mTbl = {"B1",
"B2",
"B3",
"B4"
}
nTbl = {"A3",
"A4",
"A5",
"A6"
}
function generate(atbl,btbl,loop,rst)
res = ""
s = #atbl
if rst==2 then
for i,k in pairs(btbl) do
res = res .. k .. " " .. atbl[loop] .. "\n"
end
end
if rst==3 then
for i,k in pairs(btbl) do
--if i~=loop then s = atbl[loop] end
res = res .. btbl[i] .. " " .. btbl[s] .. " " .. atbl[loop] .. "\n"
s = tonumber(s) - 1
--print(res)
end
end
return res
end
a = generate(mTbl,nTbl,1,2) -- 2 tbl
c = generate(nTbl,mTbl,3,3) --3 tbl
print("-----a:\n" .. a)
print("-----c:\n" .. c) |
result:
-----a:
A3 B1
A4 B1
A5 B1
A6 B1
-----c:
B1 B4 A5
B2 B3 A5
B3 B2 A5
B4 B1 A5
_________________
|
|
Back to top |
|
|
Akiros Newbie cheater Reputation: 0
Joined: 11 Apr 2020 Posts: 24 Location: my house
|
Posted: Sun Jul 31, 2022 10:35 am Post subject: |
|
|
Hello, why does this error when I add more to the table ?
mTbl = {"B1",
"B2",
"B3",
"B4",
"B5"
}
nTbl = {"A3",
"A4",
"A5",
"A6"
}
function generate(atbl,btbl,loop,rst)
res = ""
s = #atbl
if rst==2 then
for i,k in pairs(btbl) do
res = res .. k .. " " .. atbl[loop] .. "\n"
end
end
if rst==3 then
for i,k in pairs(btbl) do
--if i~=loop then s = atbl[loop] end
res = res .. btbl[i] .. " " .. btbl[s] .. " " .. atbl[loop] .. "\n"
s = tonumber(s) - 1
--print(res)
end
end
return res
end
a = generate(mTbl,nTbl,1,2) -- 2 tbl
c = generate(nTbl,mTbl,3,3) --3 tbl
print("-----c:\n" .. c)
_________________
help pls im noob |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Sun Jul 31, 2022 11:04 am Post subject: |
|
|
Code: | mTbl = {"B1",
"B2",
"B3",
"B4",
"B5"
}
nTbl = {"A3",
"A4",
"A5",
"A6"
} |
#mTbl = 5
#nTbl = 4
Try to put an equal number of items in both tables, otherwise add a rule that keeps using it if it's not "nil".
Or take the table with the least number of items for the alignment limit:
function generate(atbl,btbl,loop,rst)
res = ""
s = math.min(#atbl,#btbl)
print(s) -- > 4
_________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|