Page 1 of 1
some programming help.. options..
Posted: Tue Mar 31, 2015 10:26 am
by rambo66
Hi,
i would like to invite someone in a group and i would also like to choose by a short list, how should i modify this:
for example i want to choose between "Mark", "Tom", "Lars"
here the extraction of the relevant code, what should i modify ? till now i have for each buddy another script, this sucks
for sure i also need autoinvite, i know
Code: Select all
<onLoad>
PartyWith = "xxyy"
</onLoad>
<!-- # 1 --><waypoint x="123" z="123" y="123">
sendMacro("InviteByName(\""..PartyWith.."\");");
</waypoint>
thanks
ram
edit: damn... i think i'm in the wrong folder again, sorry, please move upwards, thx
Re: some programming help.. options..
Posted: Tue Mar 31, 2015 10:42 am
by rock5
How do you want it to choose?
Re: some programming help.. options..
Posted: Tue Mar 31, 2015 10:51 am
by rambo66
I would like to have a short suggestion in the code, like:
"Mark", "Tom", "Lars"
i know there is also the "risk" that i may have a new char, but i also want to avoid to enter always the partner name
Re: some programming help.. options..
Posted: Tue Mar 31, 2015 12:16 pm
by rock5
You mean like having a list and selecting from the list?
Code: Select all
PartyList = {"Mark", "Tom", "Lars"}
PartyWith = PartyList[1]
You would still need to modify the file every time you change.
You could make it bring up a list when running that you could choose from, like my invaders script.
Code: Select all
PartyList = {"Mark", "Tom", "Lars"}
repeat
cprintf(cli.lightgreen,"\nChoose who to party with.\n")
for i,name in pairs(PartyList) do
printf(" [%d] %s\n",i,name)
end
printf(" [0] Other\n")
cprintf(cli.yellow," Select> ")
PartyWith = tonumber(io.stdin:read())
if type(PartyWith) ~= "number" or 0 > PartyWith or PartyWith > #PartyList then
cprintf(cli.yellow,"\nExpecting number from 0 to %d.\n",#PartyList)
yrest(2000)
else
if PartyWith == 0 then
printf("Enter name of player to party with> ")
PartyWith = io.stdin:read()
else
PartyWith = PartyList[PartyWith]
end
break
end
until false
Output.
Code: Select all
Choose who to party with.
[1] Mark
[2] Tom
[3] Lars
[0] Other
Select> 2
To add names just add it to the table at the top. If you select 0 you can type whatever name you like.
Re: some programming help.. options..
Posted: Tue Mar 31, 2015 12:44 pm
by rambo66
thanks rock,

i will try that soon
Re: some programming help.. options..
Posted: Tue Mar 31, 2015 2:33 pm
by rambo66
it works, thank you Rock
Re: some programming help.. options..
Posted: Tue Mar 31, 2015 3:43 pm
by rock5
That's good.
Hm... I've got the urge to make an input class for asking questions. Let me do a bit of brain storming.
I can think of 4 types of questions users might want to ask. They might want to ask for a string, number, select from an indexed list or select from a keyed list. For example
Code: Select all
Input number> _
Input String> _
Select indexed option
[1] Up
[2] Down
[3] Left
[4] Right
Choice> _
Select keyed option
[W] Up
[S] Down
[A] Left
[D] Right
Choice> _
You should be able to specify the start text, end text and options, maybe even specifying the colors. It might have to specify the type of question and maybe some options to limit the input, for instance limiting to numbers.
So if the class is called CQuestion, usage might look like this.
Code: Select all
-- Index list example
myquestion = CQuestion()
myquestion:SetStartText("Select one of the following")
myquestion:SetStartTextColor("lightgreen")
myquestion:SetOptions({"Up","Down","Left","Right"})
myquestion:SetEndText("Choice> ")
myquestion:SetEndTextColor("yellow")
I guess I could also use variables for the above instead of functions, eg.
Code: Select all
myquestion.StartText = "Select one of the following"
Then you would need to run it somehow.
Re: some programming help.. options..
Posted: Sun Apr 05, 2015 7:50 am
by rambo66
Hi Rock,
to be honest, i've tried the first one.. it works fine for me
thanks and happy Easter to you