Create a script for PlayOnLinux - Chapter 2: Base functions

Displaying a message

Add the following code to your script

message "Hello World"

Here is what you get

You manage to display messages. Happy? I invite you to read the annexe to enhance this window's legibility. You will learn to change the title, display a "cancel" button and step numbers

Displaying a message in the console

If you open playonlinux from a terminal, you can display a message inside of it. It's very useful for debugging. Enter the following code:

echo "Hello World"

Commenting your code

The "#" symbol tells to bash to ignore the following text. Here is an example:

echo "Hello World"
# A nice comment
echo "Goodbye World"

I invite you to comment your code as much as possible to improve the legibility and help scripters for the validation

A field?

You want to ask an information to the user? The text_field function is perfect for you. Add the following code to your script:

text_field "What's your name?"

And here is the window which appears

Nothing happens? It's still normal. Actually, if you observe well, the entered value is sent in your console.

We will see in the next chapter how to don't loose this value and then use it

A question?

You want the user to answer by yes or by no? A "question" function exists

Here is its functioning:

question "Do you like PlayOnLinux?"

The result will be as follows:

If the user clicks on Yes, you will see a "0" appearing in your console. Else, you will see a "1"

We will learn to don't loose this value in the next chapter

A little menu

In the same way that the two previous functions, you can create a nice menu for PlayOnLinux.

menu "What do you want to eat this evening?" "Carrots Potatoes Chips"

The result is displayed in the console

And if I want to propose "Some Carrots", "A lot of Chips", "No Potatoes", it displays 6 different entries?

Yes, the "menu" function uses the space as default separator. Thus, a space correspond to a new entry in your menu. If you want to change the separator, please read the annexes.

Present your application

This command is very important. It allows you to present an application to the user before he installs it

presentation "Game's name" "Game's editor" "Game's websie" "Your nickname" "Game's prefix (see the chapter 5)"

Example:

presentation "The platypus' quest" "PlayOnLinux" "http://www.playonlinux.com" "Tinou" "platypus_quest"
Il n'y a rien à voir ici