Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Need help with my Pedometer
dk1129
post Jul 12 2010, 01:28 PM
Post #1


Level 1
Group Icon

Group: Member
Posts: 5
Type: None
RM Skill: Undisclosed




So I'm creating a pedometer that watches step count (using RMXP so step count already exists) and rewards the player for reaching a certain step count. Can anyone help?

The pedometer is a non-usable item that initiates the counting/rewarding process once acquired. Here is an example of the common event (parallel process) i've started:

CODE

@>Control Variables: [0001: Pedometer] = Steps
@>Conditional Branch: [0001: Pedometer] == 50
@>Change Gold: +50
@>Play SE
@>Text: Message
@>
: Branch End
@>Conditional Branch: [0001: Pedometer] == 200
@>Change Items: [Herb], +1
@>Play SE
@>Text: Message
@>
: Branch End


Problem is that since it is parrallel, it keeps adding gold and showing message because the step count still is 50. Adding +1 to the pedometer variable making it 51 to break the loop doesn't work because the common event overwrites it with real step count back to 50 as it is suppose to. So I figured I'd use a script to change the system's step count that the variable relies on, but nothing works. I've tried:

CODE

--------------------------------
Attempt 1 (gives NameError)
----------------------------------
increase_steps

------------------------------
Attempt 2 (does nothing)
----------------------------
@steps + 1

-------------------------------
Attempt 3 (does nothing)
------------------------------
@steps = 51

------------------------------
Attempt 4 (get NoMethodError)
------------------------------
$game_party.step + 1

---------------------------------
Attempt 5 (get NoMethodError)
-------------------------------------
$game_party.step = 51


This post has been edited by dk1129: Jul 12 2010, 01:38 PM
Go to the top of the page
 
+Quote Post
   
HeroOfHyla
post Jul 13 2010, 07:32 PM
Post #2


Twirling towards freedom
Group Icon

Group: +Gold Member
Posts: 2,791
Type: Scripter
RM Skill: Advanced




Moving to eventing.


__________________________
Asexual - Arizonan - Atheist
I've got a gmail account and a yahoo mail account under this name, if you need to contact me.
You can find me on facebook too. facebook.com/heroofhyla . If you send me a friend request, tell me who you are so I don't get confused.

PlagueRPG SITE IS WORKING! (if you see "test page," hit ctrl+f5)
Latest update: New battle system demo, April 19, 2010

http://heroofhyla.deviantart.com/ ----- http://heroofhyla.livejournal.com/ ----- http://thatonecomic.smackjeeves.com
Go to the top of the page
 
+Quote Post
   
RzrBladeMontage
post Jul 14 2010, 08:13 PM
Post #3


"Hey.. would you say... I became a Hero?" - Zack Fair
Group Icon

Group: Revolutionary
Posts: 773
Type: Event Designer
RM Skill: Advanced




Well I took a look at this for you. I tried for awhile to do this all with events, however I had to give up and use a little scripting (just a little!). There's a demo at the bottom of this post but I'll post step by step instructions as well.

Here is what you need for my small example:

3 Switches
1 Item "Pedometer"
1 Variable
1 Common Event

Okay, on your games opening screen, turn ON 2 switches: 50StepReward and 100StepReward. Like I said, this is just an example.

Now have your event where your character gets the Pedometer item. This is what I have in the demo.



In the Script option, put
CODE
$game_party.steps = 0


this will reset the step count to zero after your character recieves the Pedometer. Now go to your list of scripts. Make a new script and call it something like Step_Reset. Make sure it is ABOVE "Main." Now put:

CODE
class Game_Party
  attr_accessor :steps
end




Without this piece in your scripts, the step reset won't work.

Now make a common event. Make it a parallel process and only let it be activated if the switch "Pedometer" is on. Make sure the Variable you're using for the Pedometer is set to equal the number of steps the player has taken. This is where the switches and the conditional branches come in. Make a conditional branch that checks if the Pedometer variable is equal to 0, if it is, do nothing, but under the else put another branch that checks to see if the 50StepReward switch is on. If it is, make another conditional branch that checks to see if your Pedometer variable is equal to 50, if it is, add the coins (or items) to the player's inventory, throw in a nice little sound effect and give the player a message to let them know what they got for walking a certain amount. After that, turn OFF the 50StepReward Switch. This will make sure that the player doesn't keep getting the message and the reward for walking 50 steps. Continue to make your conditional branches all the way down until you have all the rewards for a certain amount of steps that you want. Make sure to put the new conditional branches in the correct spots so you don't stop them from being activated if you turn off a switch. (See picture below).



Everytime you add a new reward, you will have to add a switch and turn it on at the beginning of your game, and add it to the common event under the correct conditional branches, and then make sure to turn the switch off.

That's it! It's pretty simple once you get the right stuff in place. Hope this helps smile.gif.

EDIT: Do you mind if I post this as a submission for other people to use?



__________________________





Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 03:14 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker