Basically like this:
string = ''
if x.element_set_array.size > 0
string += $data_system.elements[x.element_set_array[0]]
(1..x.element_set_array.size).each {|i|
string += ', ' + $data_system.elements[x.element_set_array[i]]
}
end
I would actually suggest that you make a method that does that. You simply pass on the element ID array and the elements array.
class Array
def split(delimiter, elements)
string = ''
if self.size > 0
begin
string += elements[self[0]].name
(1..self.size).each {|i|
string += delimiter + elements[self[i]].name
}
rescue
string += elements[self[0]].to_s
(1..self.size).each {|i|
string += delimiter + elements[self[i]].to_s
}
end
end
return string
end
end
i.e. A call for weapon elements would be: "string = weapon.element_set.split(', ', $data_system.elements)".
Or a call for armor guard states would be: "string = armor.guard_state_set.split(', ', $data_states)".
You could use this method for others things as well. I just remembered that this method is called "explode" in PHP. xD