Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: nathmatt on June 29, 2010, 12:18:51 pm

Title: event location shuffle
Post by: nathmatt on June 29, 2010, 12:18:51 pm
im trying to store the events current location in an array shuffle the location of each event

here is what i have
$game_map.events.each_pair{|i,event|
@event[i] = [event.x,event.y]}
delay(5)
@events = $game_map.events.clone
@event.shift
@event.shuffle!
@event.unshift(nil)
$game_map.events.each_pair{|i,event| p i,@event[i]
event.moveto(@event[i][0],@event[i][1])}


class Array
 def shuffle!
   size.downto(1) { |n| push delete_at(rand(n)) }
   self
 end
end
Title: Re: event location shuffle
Post by: ForeverZer0 on June 30, 2010, 05:24:32 pm
Is what you are doing is just trying to randomly mix up the at what index each value has in the array? If so, I may have a different approach that you may find useful.
Title: Re: event location shuffle
Post by: nathmatt on June 30, 2010, 05:57:46 pm
im trying to shuffle the locations im working on a jigsaw puzzle script so i need you to see the events in place then shuffle there locations then im comparing them by storing them with .clone before i shuffle them
Title: Re: event location shuffle
Post by: SBR* on July 01, 2010, 03:30:02 am
When using the $game_map.events.each_pair in the end, don't you now move a copy of the event? I never work that far with arrays, so...