Is this even possible????

  • Yes

    Votes: 3 60.0%
  • No

    Votes: 1 20.0%
  • I'm a sheep.

    Votes: 2 40.0%

  • Total voters
    5
  • Poll closed .

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
There's a specific battle in my game, that'd I'd like to break the fourth wall with a little, like Undertale did... Call me a dweeb if you want, whatever, but I was hoping someone knew where to find the code for when it erases variables?
I know how code works, but I've never studied it before, so I don't really know how it all works, or what I'm looking at... Please, if you could point me in the right direction that would be great.
Or if it's impossible, just tell me below and I'll remove this thread after a while of no responses.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
11,998
First Language
English
Primarily Uses
RMVXA
'Tutorials' is where people who have made a tutorial and want to share it can post it. "How do I...?" questions go in the Support forum for the engine you are using.
[move]RPGMaker VX Ace[/move]
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
249
Reaction score
76
First Language
English
Primarily Uses
RMVXA
A quick glance tells me that Scene_Gameover doesn't reset variables. That's because it goes straight to Scene_Title, which doesn't need variables by default, and the only times variables are reset is when you start or load a game.

In fact, these resets are done in DataManager's create_game_objects and extract_save_contents() . For extract, the $game_variables array is replaced with the array in file. What I would suggest (by creating a method to overwrite this, not edit directly) is:

Code:
module DataManager
 def self.extract_save_contents(contents)
   fourthwallvar = $game_variables[4thWall] if $game_variables
  $game_system        = contents[:system]
  $game_timer         = contents[:timer]
  $game_message       = contents[:message]
  $game_switches      = contents[:switches]
  $game_variables     = contents[:variables]
  $game_self_switches = contents[:self_switches]
  $game_actors        = contents[:actors]
  $game_party         = contents[:party]
  $game_troop         = contents[:troop]
  $game_map           = contents[:map]
  $game_player        = contents[:player]
   $game_variables[4thWall] = fourthwallvar if fourthwallvar
 end
end
Ideally, you save the variable before the reset, then reassign the value back into the variable. Of course, replace 4thWall with the variable ID, no leading 0s.
 
Last edited:

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
Maybe I'm an idiot, but what you suggested isn't working for me sadly... I've tried removing the script that resets variables on a load game, I've tried inserting that line of code you gave me in to the game, I've tried replacing the 4thwall and the fourthwall individually, and together with ID, I've tried inserting it as a script into the enemies code, I've tried saving before and after the whole game over screen.... I don't know what to do anymore, I'm really at a loss here. Maybe I'm just being an idiot? Lol...
 

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
'Tutorials' is where people who have made a tutorial and want to share it can post it. "How do I...?" questions go in the Support forum for the engine you are using.
[move]RPGMaker VX Ace[/move]
Also sorry, kind of new here... Didn't know where any forums were, won't happen again lol
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,709
Reaction score
8,497
First Language
German
Primarily Uses
RMMV
He is telling you that game over does NOT erase your variables, variables are only erased on New game or replaced when an old savefile is opened.

So your basic assumption is wrong, and it would help if you describe to us what you did in your game that convinced you wrongly of that opinion. Then we can check what really happened and what you have to do to solve your Problem.
 

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
He is telling you that game over does NOT erase your variables, variables are only erased on New game or replaced when an old savefile is opened.

So your basic assumption is wrong, and it would help if you describe to us what you did in your game that convinced you wrongly of that opinion. Then we can check what really happened and what you have to do to solve your Problem.

Yeah, I got that already... It was kind of slapping me in the face lol, and I should have realized it. Though it really has the same end result... When that gameover hits, you have to load a save state and I just can't find a way around that.

And I tried to explain what I did above in the previous reply..... Though I'm not very good at it I guess?

He suggested that I use that line of code right? Or am I an idiot? ... He said, and I quote "What I would suggest (by creating a method to overwrite this, not edit directly) is:" and then printed the line of code below it... So I figured I had to use that somewhere... And since he said not edit directly, I figured that means I shouldn't have to mess with the actual script of the game itself... Though after a bit of time wasted putting it in different places, trying different thing, I even tried inserting it into the game itself... And that didn't work either.

I don't know anything about code, so I don't know what it was for... Or what he was even giving me... But I tried inserting it into different places, tried working around the load state erasing variables, but it all ended with the same result... It didn't work... So in conclusion, I HAVE NO IDEA WHAT TO DO WITH WHAT HE GAVE ME....... I read through what he gave me at least 10 times, the code itself, and what he wrote... I couldn't figure out what he was telling me to do. Please, be gentle lol I'm not used to working with this kind of stuff... This is actually the first game I'm going to even attempt using code in... Later of course.. Or maybe now, depending on what's said in the forums later... Or before?... Yeah... Help lol
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
249
Reaction score
76
First Language
English
Primarily Uses
RMVXA
Got home and tested it. Of course, the snippet I posted works when continuing a game (and thus needs saving), but I pretty much tap some variables ([1] in my case), load up the savefile after getting a gameover, and my variable stays increased. Note that this script is not written to affect New Game the same way, but it can with a bit of editing.

Anyway, when a person provide a script or snippet, it's generally assumed that you can copy-paste it as is. Just go to the Script Database (paper and pen icon on the map editor), and paste this under *Materials.
 

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
oooooh lol when you said
"replace 4thWall with the variable ID, no leading 0s."
I got really confused I was like: "Um... But... Why'd you send it like that then?" XD
However... I posted it in materials, and the game won't start, it just crashes... Ugh.

Edit:

Ok, so I input the code in materials, after erasing all the notes... Was that a bad?... Pretty sure it wasn't, since notes don't effect the game... Right?.......... The green notes?.... Yeah.

Anyway, after I input it, the game gives me this crap:

Script '( Insert here )' line 3: SyntaxError occured.
unexpected tIDENTIFIER, expecting ']'
fourthwallvar = $game_variables[4thWall] if $game_variables
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,316
Reaction score
7,845
First Language
Indonesian
Primarily Uses
RMVXA
He is telling u to change "4thWall" to variable ID, which it should be for example
Code:
fourthwallvar = $game_variables[10] if $game_variables
Have u changed it?
 

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
OOOH! The variable ID... I want to die now lol
Okay so... I had no idea what that meant lol, but a quick search has just informed me of what that meant, and I'm just going to go try again lol. Forgive my stupidity, I just don't... Don't dabble with ****ing code. Too much frustration lol... Plus, I don't know much about it honestly /: Well actually, I do know one thing... Don't ever... EVER ****ing touch stable code, because if you do, you can kiss your bug-free game goodbye, and say hello to death, because it's coming lol
I'm also having other problems with other lines of code that I've posted in another forum... So I can't even test this out, as the game crashes every time I start it... So I don't have the code above input into it yet sadly... This is an all-nighter, huh?
Ugh... Oh well.
However, I finally get what I'm supposed to do, so I'll get back to this and post if it works or not... Plz... Work lol
Edit: fricking huh? Lol okay, that's great... I didn't type that but LET'S JUST GO WITH IT! ;D
 
Last edited:

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
Okay so, turns out it did not work... I pasted the material you gave me in a newly inserted line under materials... Did I edit this right?

Code:
module DataManager
 def self.extract_save_contents(contents)
   YouLostvar = $game_variables[1] if $game_variables
  $game_system        = contents[:system]
  $game_timer         = contents[:timer]
  $game_message       = contents[:message]
  $game_switches      = contents[:switches]
  $game_variables     = contents[:variables]
  $game_self_switches = contents[:self_switches]
  $game_actors        = contents[:actors]
  $game_party         = contents[:party]
  $game_troop         = contents[:troop]
  $game_map           = contents[:map]
  $game_player        = contents[:player]
   $game_variables[1] = YouLostvar if YouLostvar
 end
end

Did I POSSIBLY do something so wrong that I should be dead?... jw... Because it crashes my game lol...
Ugh, I still don't understand, and I'm pretty sure that's sad... I pasted exactly as is above, I have a variable named YouLost, it's set to 1, and I don't even know what the hell I'm doing anymore.. Oh also this:

Script 'YouLost' line 3: SyntaxError occurred.

dynamic constant assignment
YouLostvar =$game_variables[1] if $game_variables

Hope that helps too...
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,224
Reaction score
730
First Language
English
Primarily Uses
RMVXA
Ok, so this works fine for me.
Code:
module DataManager
 def self.extract_save_contents(contents)
   fourthwallvar = $game_variables[14] if $game_variables
  $game_system        = contents[:system]
  $game_timer         = contents[:timer]
  $game_message       = contents[:message]
  $game_switches      = contents[:switches]
  $game_variables     = contents[:variables]
  $game_self_switches = contents[:self_switches]
  $game_actors        = contents[:actors]
  $game_party         = contents[:party]
  $game_troop         = contents[:troop]
  $game_map           = contents[:map]
  $game_player        = contents[:player]
   $game_variables[14] = fourthwallvar if fourthwallvar
 end
end
Whatever I set to variable 14 is reset to zero when starting a new game.

I'm not entirely sure what the effect is supposed to be.

I think you misunderstand one point but maybe I'm wrong, the variable is 1 or 2 or 3 etc. not youlostvar. You can name it, which is for you to know what each variable is for so that you don't make the mistake of using it for something else. This is done in the editor.
So what you have is variable 1 called youlostvar. and you set it to the value of 1.
What I have in the code is variable 14. Correct me if I'm wrong guys, the variable data goes into a named variable? (fourthwallvar)
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
249
Reaction score
76
First Language
English
Primarily Uses
RMVXA
To Ronin: Here is the version that allows you to keep the variable over to the new game:
Code:
module DataManager
  def self.create_game_objects
     fourthwallvar = $game_variables[14] if $game_variables
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_timer         = Game_Timer.new
    $game_message       = Game_Message.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
     $game_variables[14] = fourthwallvar if fourthwallvar
  end
end

====

To Hyper: Your error just pointed out a interesting feature of Ruby: Any variable name that starts with a capital becomes a Constant, which in coding is a value-holder that shouldn't be changed in-script. Hence, YouLostvar is a Constant while youLostvar is a Variable, and for this code, we need a Variable.
 

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
Are you KIDDING ME?! Lol I could've finished hours ago if I knew that! Oh my gosh ... Just... Code... It's so ... Precise lol... Okay let me test that out~
That's a nope lol...
I just don't get it, maybe the script is fine, I'm just doing the actual input wrong on the character?...
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,224
Reaction score
730
First Language
English
Primarily Uses
RMVXA
I think now you need to explain in detail what your doing and what you want the outcome to be.
Your first post just says point you to where variables erases.
 

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
Really? I thought I was pretty thorough...
Okay, so I'm having a battle with a fourth wall break in my game, where every time the player dies, the boss knows about it, and will make little jokes about your death... Don't even say it~ Not like Undertale. In my game, every one knows about your power... It's treated as more of a groundhog day scenario, where no one's memories reset... They also kind of freak out and glitch out at the sight of this, and the game will get very creepy, as they break the fourth wall multiple times, and freak out in disturbing ways as to hopefully, freak people out. Basically, in the game I'm making, everything is broken... And the npc's become aware of that, and realize that the game they're inside of is broken, which releases a more demonic presence from within the realm of the game itself... If that made any sense lol
Now all I need to know is how exactly do you stop variables, and possibly switches, from getting reset to the last save?
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
249
Reaction score
76
First Language
English
Primarily Uses
RMVXA
So you need more than one variable? This version copies the array rather than just one variable.
Code:
module DataManager
#These two methods are the "resets" after a GameOver.  They are written with the "resets" in the middle
#because the way I wrote them is store and restore variables if you already started a game, and run game normally
#if you haven't started yet.
  def self.create_game_objects #After a Gameover, this method keeps your variables and switches when you start a new game.
     fourthwallvar = $game_variables if $game_variables #storing the previous variables array
     fourthwallswitch = $game_switches if $game_switches #storing the previous switch array
     fourthwallselfs = $game_self_switches if $game_self_switches #storing the previous events' self switches
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_timer         = Game_Timer.new
    $game_message       = Game_Message.new
    $game_switches      = Game_Switches.new # Best not to remove these items as they are carefully defined
    $game_variables     = Game_Variables.new #
    $game_self_switches = Game_SelfSwitches.new #
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
     $game_variables = fourthwallvar if fourthwallvar #reassigning the previous variable array
     $game_switches = fourthwallswitch if fourthwallswitch #reassigning the previous switch array
     $game_selfswitches = fourthwallselfs if fourthwallselfs #reassigning the previous event self switches
  end
 def self.extract_save_contents(contents) #After a Gameover, this method keeps your variables and switches when you continue a saved game.
     fourthwallvar = $game_variables if $game_variables
     fourthwallswitch = $game_switches if $game_switches
     fourthwallselfs = $game_self_switches if $game_self_switches
  $game_system        = contents[:system]
  $game_timer         = contents[:timer]
  $game_message       = contents[:message]
  $game_switches      = contents[:switches] #We load data from the savefile, so best not to remove these or you'll start with nothing.
  $game_variables     = contents[:variables] #
  $game_self_switches = contents[:self_switches] #
  $game_actors        = contents[:actors]
  $game_party         = contents[:party]
  $game_troop         = contents[:troop]
  $game_map           = contents[:map]
  $game_player        = contents[:player]
     $game_variables = fourthwallvar if fourthwallvar
     $game_switches = fourthwallswitch if fourthwallswitch
     $game_selfswitches = fourthwallselfs if fourthwallselfs
 end
end

Alternatively, there are several ways to write this, such as:

Code:
module DataManager
#In this version, variables don't exist before you start/load the first time, but this proves that after Game Overs,
#variables aren't reset yet, so the next time you load from there, these values won't be reassigned.
  def self.create_game_objects
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_timer         = Game_Timer.new
    $game_message       = Game_Message.new
     $game_switches      = Game_Switches.new unless $game_variables #Just like if runs when this exists,
     $game_variables     = Game_Variables.new unless $game_variables #unless will skip this if it exists,
     $game_self_switches = Game_SelfSwitches.new unless $game_variables # like a reverse if.
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
  end
 def self.extract_save_contents(contents)
  $game_system        = contents[:system]
  $game_timer         = contents[:timer]
  $game_message       = contents[:message]
   $game_switches      = contents[:switches] unless $game_variables #
   $game_variables     = contents[:variables] unless $game_variables #
   $game_self_switches = contents[:self_switches] unless $game_variables #
  $game_actors        = contents[:actors]
  $game_party         = contents[:party]
  $game_troop         = contents[:troop]
  $game_map           = contents[:map]
  $game_player        = contents[:player]
end
end
The other alternative is to look up a Global Variable/Switch script if you don't trust me. Anyway, keep in mind that variables and switches aren't made in the Title Screen but when you start/load a game after pressing that button, so if you're planning to screw with the title when you start up every time, the Global stuff is recommended.
 

hypershadic11

Veteran
Veteran
Joined
Nov 25, 2017
Messages
53
Reaction score
27
First Language
English
Primarily Uses
RMVXA
Well I didn't need more than one yet lol... Basically I'm just testing out one battle, seeing if I can even do it through RPGMVXA.
Though I appreciate the code, and will definitely still use it...
In fact, let me do that right quick lol...

...

Nope! :D... Alright, let me try that first one rq..

Also nope... Sadly...

I'm too tired to keep this going on, I'll just have to twiddle around with the event itself tomorrow, and I'll get back to you then. Also, if you don't mind, could you tell me how you'd set up the event? I'm just curious... Might be doing it wrong, because I know your code isn't the problem.
 

Harosata

Dramatic Lightning's BFF
Veteran
Joined
Aug 20, 2015
Messages
249
Reaction score
76
First Language
English
Primarily Uses
RMVXA
How I tested this script:

NPC A adds to Variable 1 by one point. (Control Variable)
NPC B textboxes me how much is in Variable 1 (by typing in \V[1]).
NPC C does Game Over. (Game Over)

I talk to NPC A at least once, and NPC B tells me 1. Then I talk to NPC to get the Game Over Screen, which then goes to the Title Screen afterwards. From there, I either do New Game or Continue (New Game as I haven't saved here), then I talk to NPC B. Without the script, NPC B would tell me 0, but with the script, NPC B remembers to tell me 1.

---

Anyway, you say you at least have a boss who remembers your defeats. There are two ways I interpret that:

1. Your Process Battle can handle when you Lose. This brings you back to the Map after losing a battle and executes what you have in that branch, but will not trigger a game over. There, you could simply do
-Control Variable
-Game Over

2. Or I'm guessing that you want to have the Battle go straight to Game Over and had the Variable increase inside the Troop battle, hoping that when Party HP is 0, it would run.The problem is that Battles are designed to head straight to Win or Loss in that case and ignore any Event that could run at that point. I have two solutions in that case:

A. Increase the Defeats Variable at the beginning of the Battle. You may want to reset the variable or turn a switch on after winning the Battle, but generally, each loss is simply a battle you haven't won.

B. Or you'll need a script designed to add events to victory/defeat like Himework's Post Battle Events. Use Comment for the <notetag> so that the marked page will run that Event when you lose.
 

Latest Threads

Latest Profile Posts

Should've done this a few days ago but...
PRI_200136808.jpg
Rest in Peace, Sir Clive Sinclair
1940 - 2021
Entrepreneur, Technologist, Father of the British Computing Industry, and protagonist of Legend of ZUN.

Without you, England's games and tech industry wouldn't be where it is.
Woof, haven't touched any game-making elements in a couple of weeks I think.
Doing a thing in MV...

R3PuRjF.png
Don't you just hate it when you get a high level armor only for it to look like a metal plated bikini on your female character?? Seriously. How can that protect you??? Enemies can hit the squishy parts! :kaosigh:

Forum statistics

Threads
115,284
Messages
1,088,622
Members
149,904
Latest member
Martine1979
Top