delete saved game?

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

Moderators: marionline, SDHawk

Post Reply
User avatar
marionline
Metal Slime
Posts: 673
Joined: Sat Feb 26, 2011 9:23 pm

delete saved game?

Post by marionline »

Is it possible to delete/remove a saved game from a rpg-file?
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, use the delete save command.
User avatar
marionline
Metal Slime
Posts: 673
Joined: Sat Feb 26, 2011 9:23 pm

Post by marionline »

Thanks! :)
I did not know it was possible to do this with a plotscripting command.
User avatar
Greenyel
Slime
Posts: 21
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

Delete Menu

Post by Greenyel »

Hi!
I saw this command on plotscript dictionary. But just The "delete save" command. Without any variables of it.
Is it possible to make a menu were The player can choose what slot he wants to delete? Like the load menu interface?
I was trying to make this on the title menu of my game. Something like "new game", "load game", and "delete saved game" options.
Like a lot of games were The "delete saved game" option exist. Sometimes within The load menu itself...
Last edited by Greenyel on Thu Jan 19, 2017 11:48 pm, edited 1 time in total.
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, this is easy. You can call "load menu(false)" or "save menu(false)" to show the load/save menu and return the selected save slot instead of actually loading/saving.
Of course, you should use 'load menu', otherwise the player can pick an empty slot, and worse they get asked "Really overwrite existing save?".

Code: Select all

slot := load menu(false)
if (slot > 0) then (delete save(slot))
There's just one problem: the "New Game" option is visible at the top of the menu. I'll add an option to remove it now.

EDIT: done, you can get the improved command in nightly builds (wait half a day first). Then you just use "slot := load menu(false, false)" instead.
Last edited by TMC on Fri Jan 20, 2017 6:08 am, edited 3 times in total.
User avatar
Greenyel
Slime
Posts: 21
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

Post by Greenyel »

It worked thanks.
But when you choose a save to delete, I tried to make a textbox with a choice apearing, something like "really wanna delete?" before deleting, but got an error. It didnt worked how I spected.

Code: Select all

Plotscript, delete save menu, begin
variable (slot)
slot := load menu(false) 
if (slot > 0) then (
show textbox (832) # Really delete?
if (check tag (tag:Delete ok) == 1) then (delete save(slot)))
end
First of all is that when the choice appears, the "title menu" cursor is still active, moving along with the "choice" cursor.

Image

And even if I choose "YES" (it sets tag "Delete ok" on), the save isnt deleted.

Im using the animated title script:

Code: Select all

plotscript, animated title, begin 
  #### If you want title music, add a line like this here: 
  play song(69) 

  # Set a tag to show the load game menu if there are any games to load 
  variable (slot) 
  for (slot, 1, 32) do ( 
    if (save slot used (slot)) then ( 
      set tag(178, on) 
    ) 
  ) 

  suspend player 
  open menu (3) 

  # Show an animated backdrop while any menu is open 
  while (true) do ( 
    variable (backdrop) 
    ##### Change 2 and 8 to first and last backdrop 
    for (backdrop, 255, 265) do ( 
      show backdrop (backdrop) 
      ##### Change to the desired delay between backdrops (2 ticks = 1/9th second) 
      wait(2) 
      if (top menu == false) then (break(2))  # Exit while loop when no menu open 
    ) 
  ) 

  # When the menu is closed the above loop ends, so continue to a new game. 
  # Hide the backdrop. 
  show map 
  resume player 
  intro
  # Call your real new-game script here, if any 
end
Last edited by Greenyel on Fri Jan 27, 2017 2:32 am, edited 2 times in total.
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Add "wait for textbox" after the "show textbox" command. Otherwise the script will continue and check the tag before the player makes their decision

The menu remaining active when a textbox choicebox is shown is an engine bug. You can work around it by temporarily disabling controls on the menu. For good measure, I also temporarily disable the ability to close the menu with ESC.

Code: Select all

Plotscript, delete save menu, begin
  variable (slot)
  slot := load menu(false)
  if (slot > 0) then (
    set menu bit(top menu, menubit:no controls, true)  #arrow keys etc do nothing
    set menu bit(top menu, menubit:no close, true)   #ESC does nothing
    show textbox (832) # Really delete?
    wait for textbox
    set menu bit(top menu, menubit:no controls, false)
    set menu bit(top menu, menubit:no close, false)
    if (check tag (tag:Delete ok)) then (delete save(slot))
  )
end
I haven't tested this script...
User avatar
Greenyel
Slime
Posts: 21
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

Post by Greenyel »

Tested here.
Its working ok now.
User avatar
Greenyel
Slime
Posts: 21
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

Post by Greenyel »

It seems after I inserted an skipable cutcene script just before the main menu, this delete script started to have the same problem again.

This is the script that runs before the main menu script:

Code: Select all

plotscript, opening, begin
  suspendplayer
  suspendnpcs
  suspendboxadvance
  fadescreenout (0, 0, 0)
  showbackdrop (279)
  wait(10)
  fade screen in
  wait(50)
  fadescreenout (0, 0, 0)
  wait (3)
  showbackdrop (280)
  skippable wait(10)
if(not(skipping waits)) then(fadescreen in)
  skippable wait(50)
if(not(skipping waits)) then(fadescreenout (0, 0, 0))
  playsong (72)
  showbackdrop (229)
  skippable wait (10)
if(not(skipping waits)) then(fadescreenout (63, 63, 63))
if(not(skipping waits)) then(fadescreenout (0, 0, 0))
  skippable wait (78)
if(not(skipping waits)) then(fadescreen in)
  skippable wait (20)
if(not(skipping waits)) then(fadescreenout (0, 0, 0))
  skippable wait (10)
  showbackdrop (232)
  skippable wait (10)
if(not(skipping waits)) then(fadescreen in)
  skippable wait (50)
if(not(skipping waits)) then(fadescreenout (0, 0, 0))
  skippable wait (10)
  showbackdrop (230)
  skippable wait (10)
if(not(skipping waits)) then(fadescreen in)
  skippable wait (30)
  showbackdrop (241)
  skippable wait (2)
  showbackdrop (231)
  skippable wait (20)
if(not(skipping waits)) then(fadescreen out)
  skippable wait (10)
  showbackdrop (233)
  skippable wait (10)
if(not(skipping waits)) then(fadescreen in)
  skippable wait (30)
  showbackdrop (234)
  skippable wait (3)
  showbackdrop (235)
  skippable wait (3)
  showbackdrop (236)
  skippable wait (3)
  showbackdrop (237)
  skippable wait (5)
  showbackdrop (238)
if(not(skipping waits)) then(fadescreenout (63, 63, 63))
  skippable wait (20)
  show backdrop (239)
  skippable wait (3)
if(not(skipping waits)) then(fadescreen in)
  show backdrop (239)
  skippable wait (3)
  show backdrop (240)
  skippable wait (3)
  show backdrop (239)
  skippable wait (3)
  show backdrop (240)
  skippable wait (3)
  fade screen in
  animated title
end
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

What problem? You mean this?
First of all is that when the choice appears, the "title menu" cursor is still active, moving along with the "choice" cursor.

And even if I choose "YES" (it sets tag "Delete ok" on), the save isnt deleted.
Is the animatedtitle script exactly the same as the copy you posted before? Is "delete save menu" exactly the same as the version I posted?
If it's not, post the current version.
If it is, then you wouldn't even be able to select the Yes/No choice when confirming the delete save, because you have "suspendboxadvance" at the beginning of your opening script, and no resumeboxadvance at the end.
User avatar
Greenyel
Slime
Posts: 21
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

Post by Greenyel »

Thanks TMC!
Can this be because of the "skipping waits" script?
It uses whyle command.

Code: Select all

global variable(1, skipping waits) 

script, skippable wait, ticks, begin 
  while (skipping waits == false && ticks > 0) do ( 
    if (key is pressed(key:ENTER)) then ( 
      skipping waits := true 
    ) 
    wait (1) 
    ticks -= 1 
  ) 
end 
Last edited by Greenyel on Wed Apr 19, 2017 12:09 pm, edited 1 time in total.
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

No, that script is fine.

Could you confirm what the problem actually is? And post the other scripts?
User avatar
Greenyel
Slime
Posts: 21
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

Post by Greenyel »

Yes, the scripts are the same version you posted. This problem was solved, but it started again after I inserted the "Opening Script" before the main menu start.

Strange ... I'm going to do a last test at home with the latest version of Nightly bild. If the problem persists, I'll send you a PM with the file.
Last edited by Greenyel on Wed Apr 19, 2017 8:14 pm, edited 1 time in total.
Post Reply