Post by tsh73 on Sept 18, 2022 18:57:45 GMT
Like, generating a player character by roll of dice
(animated window, press Generate)
First group selects at random,
second goes in cycle downwards (but in the end set random)
checkboxes are toggled at random.
Probably there is a better way?
(animated window, press Generate)
First group selects at random,
second goes in cycle downwards (but in the end set random)
checkboxes are toggled at random.
Probably there is a better way?
' Form created with the help of Freeform-J v.261006
' Generated on Sep 15, 2022 at 18:51:59
nomainwin
WindowWidth = 864
WindowHeight = 295
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #main.groupbox1, "Law/chaos", 30, 11, 128, 155
groupbox #main.groupbox2, "Good/Evil", 166, 11, 128, 155
groupbox #main.groupbox3, "Perks", 310, 11, 144, 155
radiobutton #main.rb1, "Lawful", [dummy], [dummy], 46, 46, 100, 20
radiobutton #main.rb2, "Neutral", [dummy], [dummy], 46, 71, 100, 20
radiobutton #main.rb3, "Chaotic", [dummy], [dummy], 46, 96, 100, 20
radiobutton #main.rb4, "Good", [dummy], [dummy], 198, 46, 100, 20
radiobutton #main.rb5, "Neutral", [dummy], [dummy], 198, 71, 100, 20
radiobutton #main.rb6, "Evil", [dummy], [dummy], 198, 96, 100, 20
checkbox #main.ch1, "Ranger", [dummy],[dummy] , 342, 46, 100, 20
checkbox #main.ch2, "Empathy", [dummy],[dummy] , 342, 71, 100, 20
checkbox #main.ch3, "Healer", [dummy],[dummy] , 342, 96, 100, 20
checkbox #main.ch4, "Mechanic", [dummy],[dummy] , 342, 121, 100, 20
texteditor #main.txt, 470, 16, 368, 195
button #main.btReset, "Reset", [btResetClick], UL, 30, 176, 112, 25
button #main.btGenerate, "Generate", [btGenerateClick], UL, 174, 176, 112, 25
button #main.btAccept, "Accept", [btAcceptClick], UL, 318, 176, 128, 25
menu #main, "Edit" '<--- Texteditor Menu can be moved but not removed.
'values corersponding to check/radio, to be WORD$ separated
rb$="Lawful Neutral Chaotic Good Neutral Evil"
ch$="Ranger Empathy Healer Mechanic"
open "selection+generation" for window as #main
print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
goto [btResetClick]
wait
[quit.main]
Close #main
END
[dummy] 'Perform action for the radiobutton named 'rb1'
'Insert your own code here
wait
[btResetClick] 'Perform action for the button named 'btReset'
'Insert your own code here
#main.rb2 "set"
#main.rb5 "set"
#main.ch1 "reset"
#main.ch2 "reset"
#main.ch3 "reset"
#main.ch4 "reset"
wait
[btGenerateClick] 'Perform action for the button named 'btGenerate'
'Insert your own code here
dt=300
goto [tick]
wait
[tick]
timer 0
'first group goes random
r1=int(rnd(0)*3)+1 '1..3
hndl$="#main.rb";r1
#hndl$ "set"
'secong group cycle
'r2=int(rnd(0)*3)+4 '4..6
r2=(r2+1) mod 3 '0..2
hndl$="#main.rb";r2+4 '4..6
#hndl$ "set"
r3=int(rnd(0)*4)+1 '1..4
hndl$="#main.ch";r3
#hndl$ "value? res$"
if res$="set" then #hndl$ "reset" else #hndl$ "set" 'toggle
if dt>50 then
dt=dt-15
timer dt, [tick]
else
'if second group changes in cycle order, output supposed to be the same?
'but we want it to be different so randomize at the end
r2=int(rnd(0)*3)+4 '4..6
hndl$="#main.rb";r2
#hndl$ "set"
timer 0
end if
wait
[btAcceptClick] 'Perform action for the button named 'btAccept'
t$=space$(4)
#main.txt "!cls"
#main.txt "So by sheer force of fortune your alignment is ..."
'#main.txt t$;"Lawful Neutral"
dim rb(6)
for i =1 to 6
hndl$="#main.rb";i
#hndl$ "value? res$"
rb(i)= (res$="set")
'#main.txt i;" ";res$
next
if rb(2) and rb(5) then
txt$=txt$+t$+word$(ch$,i)
#main.txt t$;"True neutral"
else
txt$=""
for i =1 to 3
if rb(i) then txt$=txt$+ t$;word$(rb$,i)
next
for i =4 to 6
if rb(i) then txt$=txt$+ " ";word$(rb$,i)
next
#main.txt txt$
end if
'#main.txt "posessing traits"
'#main.txt t$;"Empathy"
'#main.txt t$;"Healer"
txt$=""
for i =1 to 4
hndl$="#main.ch";i
#hndl$ "value? res$"
if res$="set" then txt$=txt$+t$+word$(ch$,i)+chr$(13)
'#main.txt word$(ch$,i);" ";res$
next
if txt$<>"" then
#main.txt "posessing traits"
#main.txt txt$
end if
wait