RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
How do I use variables properly? RM3K

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 86
As it stands, I only know how to use them to advance pages.

A while back I was trying to make a night and day system. I spent months on it, so I came here... And somone showed me how to do it with variables. Easy I thought! So I did it.... Then... day would turn into night... And night would turn into morning, but noon would neve come for the variable wouldnt go back to the first page (out of like... 100). I tried to divide the variable and subtract it, but it didnt seem to do anything... all I could do was add it.

So, Id like to know a few things about  variables:

-In the example above, I used variables to advance 100 pages in a continous script. My most important question is: when I reach the last page, how do I make the variable go back to the first page.

-Later on, Im planning to make a pac-man themed mini game. Players will have to talk to a guy and collect 100 dots within a time limit. If they do so in record time, they'll be rewarded. First, players will have to talk to this guy who will start the switch. The switch will trigger the time limit and the dots. So, each dot collected will advance the variable by one. If the pages advance 100 times before the time limit runs out, then the event will be compleated successfully. The player wont see the timer.

I am wondering... Is it possible to make a variable stop working with a timer? And if not, how would I get around this?
I am also wondering, when the event is failed, will my variable start where it left off? Say... the player collected 50 dots out of 100... And he failed, so the switch turns off, ending the event. Then he'll talk to the NPC again and start again... Will RM3K start him at page one, or page 50?

Random events: I would love to incoperate them. I think variables do this but I dont know. I want to put in a lottery system... or maybe a fishing system.

thanks.

Please note, I dont have access to RM3K now. I was working on this game, and it was turning out great, but then I moved out... So I didnt have a computer. I just got this puppy so Im eager to start.

*
Rep:
Level 85
Real Men Make Fan Games
Project of the Month winner for May 2009
Alright, let's get started!

As for your first example, the day/night system, it's going to be much easier for you to condense your code into one page (as opposed to 100...).  But that said, if you wanted to return to the first page, I'd have to know the preconditions for the following 99 pages.  Let's say it's a variable being a certain number.  To return to page 1, on page 100 I would "Set" your Day/Night variable to 1 (or 0, depending on how you set up your system). Rm2k3 will see that the precondition for pages 2-100 do not exist and would bring you back to page 1.


For your Pac-Man minigame, your best bet is to, in the handler for the game being over, simply set your Pac-Man variable to 0.  This will reset your game for the next play.  Variables will stay at their values regardless of what goes on afterward unless you use another variable operations. Switches and the like will not affect them.

Randomizing numbers is as easy as one command within "Variable Operation."  Set the operation to "Set" and pick the "random number" option.  You can then select your range.