Lambda Lambda - 1 year ago 166
Ruby Question

Ruby - Equivalent to foreach

I'm working on a project in RMXP with Ruby scripts.

I create a table with id maps. I am now looking to go the table such that if the player enters one of the maps of the table, things happen.

Example of action: tMaps = [006, 008, 009]

If the hero is on the map 004, 005 ... it nothing happens If the hero
is on the map 006, Action

I hope this is feasible. If not, what other means I have in Ruby to find the maps and to assign actions?

PS I've traveled a bit, this wiki :

Answer Source

Your list is wrong, I suppose you want integer : [6, 8, 9] not [006, 008, 009] (this is octal form)

tMaps = [6, 8, 9]

tMaps.each do
   |value| puts 'value : '+value.to_s

# or : 
for value in tMaps
   puts 'value : '+value.to_s
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download