I have the following two lines in a notebox on a state (for my state add/remove commands script):
onadd: mp -= 5onremove: mp += 5and these regular expressions to pull out the notes:
The onadd line is being read correctly, and mp reduced as it should be. But the onremove line is only being half read.Adding some extra logging statements to the code shows that everything from the + onwards is being ignored.
$data_states[state_id].note.split(/[\r\n+]/).each do |line| case line when /onadd:\s*(.*)/i p line # >> onadd: self.mp -= 5 p $1 # >> self.mp -= 5 eval($1) when /onremove:\s*(.*)/i p line # >> onremove: self.mp p $1 # >> self.mp eval($1) endendCan someone tell me:
1. WHY the += 5 is being excluded from the second test?
2. What I need to do to make it work?
onadd: mp -= 5onremove: mp += 5and these regular expressions to pull out the notes:
Code:
when /onadd:\s*(.*)/iwhen /onremove:\s*(.*)/i
$data_states[state_id].note.split(/[\r\n+]/).each do |line| case line when /onadd:\s*(.*)/i p line # >> onadd: self.mp -= 5 p $1 # >> self.mp -= 5 eval($1) when /onremove:\s*(.*)/i p line # >> onremove: self.mp p $1 # >> self.mp eval($1) endendCan someone tell me:
1. WHY the += 5 is being excluded from the second test?
2. What I need to do to make it work?