Quit Game and set settings from script?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
DWRL
Red Slime
Posts: 35
Joined: Wed Jan 15, 2020 2:26 am
Location: Germany
Contact:

Quit Game and set settings from script?

Post by DWRL »

Is there any way to just end the game from hamsterscript, set it to fullscreen, change the volume etc?
I am using my own menus, and would like to build myself a nice 'Settings'-Screen.

Also, leaving the game from my custom main menu would be rather nice too ;)
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Re: Quit Game and set settings from script?

Post by SwordPlay »

DWRL wrote:Is there any way to just end the game from hamsterscript, set it to fullscreen, change the volume etc?
I am using my own menus, and would like to build myself a nice 'Settings'-Screen.

Also, leaving the game from my custom main menu would be rather nice too ;)
try ctrl+f in the dictionary for "volume" and "game over" commands
"Imagination. Life is your creation."
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

The Quit option in the main menu is equivalent to calling "game over". If the titlescreen and load menu are disabled it quits completely out. (I've been meaning to add a command to quit unconditionally).

You can modify the music volume but not the master sound effects volume. I've been meaning to add a command for that.

There's no command to switch fullscreen/windowed. That would be a good addition too.

I'd like to add a builtin settings menu, and let people customise its appearance as a slice collection, in such as way that we can add more settings in the future (there's quite a number I want to add, such as various graphics backend settings (e.g. window scaling mode, smoothing/scaling filters) and screenshot/gif settings.
User avatar
DWRL
Red Slime
Posts: 35
Joined: Wed Jan 15, 2020 2:26 am
Location: Germany
Contact:

Post by DWRL »

Thank you both for the fast replies :D
"[G]ame over"[,] If the titlescreen and load menu are disabled it quits completely out.
Great, that does the trick :)
I'd like to add a builtin settings menu, and let people customise its appearance as a slice collection, in such as way that we can add more settings in the future (...).
Would be great :D
bis_senchi
Red Slime
Posts: 64
Joined: Sat Apr 20, 2019 8:59 am

I also suggest you "reset game"

Post by bis_senchi »

You can also use a command called reset game. The difference between reset game and game over is that reset game make reload the credit at the beginning and/or the into cutscene.
The player still has to press esc to completely leave game.exe

You could make like the one above and make it run after you saved your game.
To use this pick a free text box and put it a yes/no question

If yes the script leave after game is launched. If not the text box is displayed instead.
Then pick up another free txt box (in the script below I chose text box 58) in which you write something like: thanks for playing... see you later

Code: Select all

#----------------------------------------------
script, leave game after playing, begin

suspend player
suspend npcs
suspend box advance

show text box (58)
wait (6)
resume box advance
resume player
resume npcs
#game over #quit game completely
reset game # quit game and re-launch game intro and the load menu

end#end for the script
#------------------------------------------
If you want to make the player to quit the game from a sub menu with this script, just edit your menu item, change script type to "run script" and choose it. Edit the item bitset and hit "close when activated". Name the menu item "quit" or "leave"
Also make sure that you hit the bitset "allow gameplay & scripts"

Good luck!
Post Reply