event location shuffle

Started by nathmatt, June 29, 2010, 12:18:51 pm

Previous topic - Next topic

nathmatt

June 29, 2010, 12:18:51 pm Last Edit: June 30, 2010, 12:29:30 pm by nathmatt
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
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


ForeverZer0

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.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

nathmatt

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
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


SBR*

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...