Author Topic: Additional LUA-features (Selection & Yes/No-Dialogbox)  (Read 841 times)

MuwuM

  • Ornithopter
  • *****
  • Posts: 426
  • No Game without Move(ment)
    • View Profile
    • MuwuM - Lexicons
Additional LUA-features (Selection & Yes/No-Dialogbox)
« on: 19 December 2011, 22:00:45 »
I'd like to have the following Lua methods:
  • int getSelectedUnit()
    it return the id of the selected Unit or -1 if no Unit is selected and -2 if more than one unit are selected
.
  • void selectunit(UnitID)
    The selection is set to the unit with the ID UnitID.

and an Dialogbox
where Users may select YES or NO.

examples:
Do you want to restart?
:thumbup: YES        :thumbdown: NO

Player1: Would you mind to support me?
:thumbup: YES        :thumbdown: NO

an Image Overlay would be nice, too. This means simply render an image over the game screen (like the current way of hud but enable/disable via script; especially png's with transparency)
« Last Edit: 22 December 2011, 00:29:01 by MuwuM »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Additional LUA-features (Selection & Yes/No-Dialogbox)
« Reply #1 on: 19 December 2011, 23:59:19 »
For the dialogue box, you should be able to specify the two labels, instead of forcing it to be yes and no (they should also be passed through the translation system).

Example syntax:
dialogueBox(question, label1, label2)
  • question - Name of the language string for the question.
  • label1 - Name of the language string for the first label (button).
  • label2 - Name of the language string for the second label.

The function would return 0 if the first label is chosen, and 1 if the second label was chosen, thus, you could assign it to a variable or use it immediately in an argument.

Example:
Code: (Lua file) [Select]
if dialogueBox('endGameString', 'no', 'yes') then
endGame();
end

Code: (Language file) [Select]
endGameString=After a harrowing battle, you have defeated your foe. Exit the game?
no=No
yes=Yes
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Additional LUA-features (Selection & Yes/No-Dialogbox)
« Reply #2 on: 20 December 2011, 00:39:58 »
This seems like a must for campaigns.

 

anything