No Autosaving

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
User avatar
bigkahuna
Posts: 657
Joined: September 11th, 2010, 6:24 pm
Location: In your mind.

No Autosaving

Post by bigkahuna »

Hey everyone, I was attempting to disable autosaving in an RPG scenario, and instead go for a manual save so that there would be no cheating involved. I cannot disable the save mechanism, so I tried to utilize the :nosaves command.
This is from menu_events.cpp for some context:

Code: Select all

void do_nosaves();
...
register_command("nosaves", &console_handler::do_nosaves,
                 _("Disable autosaves."));
...
void console_handler::do_nosaves() {
     game_config::disable_autosave = (get_data() != "off") ? true : false;
And from game_config.cpp:

Code: Select all

     std::string wesnoth_program_dir;
     bool debug = false, editor = false, ignore_replay_errors = false, mp_debug = false, exit_at_end = false, no_delay = false, small_gui = false, disable_autosave = false;
How would I change "disable_autosave" to true if it is in C++? I know you can in Lua. Or could I just fire command "nosaves" somehow? Help would be very appreciated here.
Check out my campaign Sweet Revenge!
Join the new R2D forum!
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: No Autosaving

Post by Anonymissimus »

You somehow seem to miss that C++ code is not part of any addon. You can use such modifications only personally on your computer with your own recompiled wesnoth binary. Unless others don't happen to have your recompiled binary they won't be affected.
Other than that, afaik there's no support for this in wml or the lua interface.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: No Autosaving

Post by AI »

It wouldn't be a bad idea to expose it though. It's useful in other scenarios also. In some WML-heavy scenarios saving can take a long time, so it's recommended to have autosaves off.
User avatar
pauxlo
Posts: 1047
Joined: September 19th, 2006, 8:54 pm

Re: No Autosaving

Post by pauxlo »

AI wrote:It wouldn't be a bad idea to expose it though. It's useful in other scenarios also. In some WML-heavy scenarios saving can take a long time, so it's recommended to have autosaves off.
If so, then I would make the preference a three-way one:

Autosave:
  • always
  • when not disabled by WML
  • never
The default maybe being the middle one.
I (as a user) don't want a campaign designer to disallow me using autosaving. (I would be forced to save manually each turn.)
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: No Autosaving

Post by Anonymissimus »

pauxlo wrote:In some WML-heavy scenarios saving can take a long time, so it's recommended to have autosaves off.
If this happens the author should use lua or new wml tags and structures to reduce wml bloat instead. Custom events instead of macros etc.
I don't feel comfortable about autosaving compulsorily disabled too.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: No Autosaving

Post by AI »

You're welcome to refactor some of the 10k+ line scenarios we have in wesnoth-umc-dev. :P

Anyway, making features take less code won't reduce the size of the code, it will increase the number of features. That's how these things tend to work.
User avatar
bigkahuna
Posts: 657
Joined: September 11th, 2010, 6:24 pm
Location: In your mind.

Re: No Autosaving

Post by bigkahuna »

I'm not worried about saving taking a long time or WML bloat. See below.
pauxlo wrote:I (as a user) don't want a campaign designer to disallow me using autosaving. (I would be forced to save manually each turn.)
I want to create a new way of saving. A.K.A only let the user save out of non-combat/stress situations. This way data still gets saved, but no save loading. Also, this has to happen because every time the user saves I have to reset and refresh certain variables. The solutions to this problem are:

A. Create an event/WML function/Lua function to disable autosaving. Then I can set a menu item for the user to save under the right conditions (most effective IMHO).

B. Create a new event type (name=save) with [filter_condition] to use my custom variable refreshing. This would be the easiest, but would rather defeat the purpose of no autosaving.

C. Create a function to delete saves. This would be less effective than the first, but may work. However, I doubt that this would work, as saves and user files are protected. Unchecked, this could potentially allow a campaign writer to delete the player's hard drive or something drastic like this.

D. Warn the user not to save because files may be corrupted and just deal with the consequences (bleh).
Anonymissimus wrote:I don't feel comfortable about autosaving compulsorily disabled too.
Think of this in an RPG situation. In the Pokemon games, the only places that saves were allowed were outside of the battle scenes. In Wesnoth, it is all too easy to save-load to get the right hits you want.
Check out my campaign Sweet Revenge!
Join the new R2D forum!
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: No Autosaving

Post by Anonymissimus »

bigkahuna wrote:Also, this has to happen because every time the user saves I have to reset and refresh certain variables.
...
B. Create a new event type (name=save) with [filter_condition] to use my custom variable refreshing. This would be the easiest, but would rather defeat the purpose of no autosaving.
There is wesnoth.game_events.on_save in 1.9 wich is a lua function called every time a game is saved. So you could sort of warn that autosaves must be disabled and when this function is called fire [endlevel]result=defeat (which you can make dependant on whatever variables you want). This affects manual saves and autosaves, not sure whether the function is not called at all then.
Anonymissimus wrote:I don't feel comfortable about autosaving compulsorily disabled too.
Think of this in an RPG situation. In the Pokemon games, the only places that saves were allowed were outside of the battle scenes. In Wesnoth, it is all too easy to save-load to get the right hits you want.
Agreed. And IMHO some difficulty reports would suddenly start to shift from "bah this is so easy" to complaints.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Post Reply