Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] Why not change `sleep 370` to for example `sleep $((time + 10))` to make it adapt to the specified t

[DiscordArchive] Why not change `sleep 370` to for example `sleep $((time + 10))` to make it adapt to the specified t

[DiscordArchive] Why not change `sleep 370` to for example `sleep $((time + 10))` to make it adapt to the specified t

rektbyfaith
Administrator
0
05-21-2022, 08:29 PM
#1
Archived author: Revision • Posted: 2022-05-21T20:29:42.449000+00:00
Original source

Why not change `sleep 370` to for example `sleep $((time + 10))` to make it adapt to the specified time?
rektbyfaith
05-21-2022, 08:29 PM #1

Archived author: Revision • Posted: 2022-05-21T20:29:42.449000+00:00
Original source

Why not change `sleep 370` to for example `sleep $((time + 10))` to make it adapt to the specified time?

rektbyfaith
Administrator
0
05-21-2022, 08:31 PM
#2
Archived author: Revision • Posted: 2022-05-21T20:31:11.530000+00:00
Original source

That way you won't have to go through and edit certain sleeps every time you change the time
rektbyfaith
05-21-2022, 08:31 PM #2

Archived author: Revision • Posted: 2022-05-21T20:31:11.530000+00:00
Original source

That way you won't have to go through and edit certain sleeps every time you change the time

rektbyfaith
Administrator
0
05-21-2022, 08:42 PM
#3
Archived author: Revision • Posted: 2022-05-21T20:42:34.388000+00:00
Original source

You can also do something like this to simplify things if you want to. The first line is clearly optional as it simply reads the time from the arguments, like `./script.sh 300` would set time to 300. The second line calculates the amount of minutes so you don't have to change it. It wouldn't be hard to throw an if at it to determine if it's minute or minutes but I imagine it's rare to see such a low time.

```
time=$1
timetext="$((time / 60)) minute(s)"
```
rektbyfaith
05-21-2022, 08:42 PM #3

Archived author: Revision • Posted: 2022-05-21T20:42:34.388000+00:00
Original source

You can also do something like this to simplify things if you want to. The first line is clearly optional as it simply reads the time from the arguments, like `./script.sh 300` would set time to 300. The second line calculates the amount of minutes so you don't have to change it. It wouldn't be hard to throw an if at it to determine if it's minute or minutes but I imagine it's rare to see such a low time.

```
time=$1
timetext="$((time / 60)) minute(s)"
```

rektbyfaith
Administrator
0
05-21-2022, 08:43 PM
#4
Archived author: Revision • Posted: 2022-05-21T20:43:37.749000+00:00
Original source

Of course, if you use arguments - you have to make sure to stop if one isn't given if it's required.

```
if [[ -z $1 ]]; then
exit
fi
```
rektbyfaith
05-21-2022, 08:43 PM #4

Archived author: Revision • Posted: 2022-05-21T20:43:37.749000+00:00
Original source

Of course, if you use arguments - you have to make sure to stop if one isn't given if it's required.

```
if [[ -z $1 ]]; then
exit
fi
```

rektbyfaith
Administrator
0
05-21-2022, 08:44 PM
#5
Archived author: Revision • Posted: 2022-05-21T20:44:29.638000+00:00
Original source

Or set it to a default value if $1 isn't supplied.
rektbyfaith
05-21-2022, 08:44 PM #5

Archived author: Revision • Posted: 2022-05-21T20:44:29.638000+00:00
Original source

Or set it to a default value if $1 isn't supplied.

rektbyfaith
Administrator
0
05-21-2022, 09:01 PM
#6
Archived author: Revision • Posted: 2022-05-21T21:01:56.112000+00:00
Original source

As a reference, this would be a full check of minute/minutes:
```
time=$1
timetext="$((time / 60))"
[ $time -gt 119 ] && timetext="${timetext} minutes" || timetext="${timetext} minute"
```
rektbyfaith
05-21-2022, 09:01 PM #6

Archived author: Revision • Posted: 2022-05-21T21:01:56.112000+00:00
Original source

As a reference, this would be a full check of minute/minutes:
```
time=$1
timetext="$((time / 60))"
[ $time -gt 119 ] && timetext="${timetext} minutes" || timetext="${timetext} minute"
```

rektbyfaith
Administrator
0
05-21-2022, 09:47 PM
#7
Archived author: Tanados • Posted: 2022-05-21T21:47:50.853000+00:00
Original source

Ty for the reply and the advice that you give me. For sure your ideas are better and that will improve the whole code
I add your reference into the script. Are you think I can do something more to be good for all who have no clue how to make something like this.
I like to help others as well as I learn new stuff Like this that you show me I don't now that i can use reference like this for minutes
rektbyfaith
05-21-2022, 09:47 PM #7

Archived author: Tanados • Posted: 2022-05-21T21:47:50.853000+00:00
Original source

Ty for the reply and the advice that you give me. For sure your ideas are better and that will improve the whole code
I add your reference into the script. Are you think I can do something more to be good for all who have no clue how to make something like this.
I like to help others as well as I learn new stuff Like this that you show me I don't now that i can use reference like this for minutes

rektbyfaith
Administrator
0
05-21-2022, 10:15 PM
#8
Archived author: Revision • Posted: 2022-05-21T22:15:04.555000+00:00
Original source

I'm sorry to say I'm not sure what you're asking.
rektbyfaith
05-21-2022, 10:15 PM #8

Archived author: Revision • Posted: 2022-05-21T22:15:04.555000+00:00
Original source

I'm sorry to say I'm not sure what you're asking.

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)