• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

M&M 2nd ed. Help Me With Script

Hello,

It's the first script that I'm writing, but I'm lost and that doesn't compile. :(

Code:
var val as number
      val = field[pwRanks].value
      if (val == 1) then
        field[pwInfo].text = "Removes one Injuried condition per 20 minutes"
      elseif (val == 2)
        field[pwInfo].text = "Removes one Injuried condition each 5 minutes"
      elseif (val == 3)
        field[pwInfo].text = "Removes one Injuried condition each 1 minute (10 Rounds)"
      elseif (val == 4)
        field[pwInfo].text = "Removes one Injuried condition each 30 seconds (5 Rounds)"
      elseif (val == 5)
        field[pwInfo].text = "Removes one Injuried condition each 12 seconds (2 Rounds)"		
      elseif (val == 6)
        field[pwInfo].text = "Removes one Injuried condition each 6 seconds (1 Round)"
      elseif (val == 7)
        field[pwInfo].text = "Removes one Injuried and the Disabled condition each 6 seconds (1 Round)"
      elseif (val == 8)
        field[pwInfo].text = "Removes one Injuried, the Disabled and the Dying condition each 6 seconds (1 Round)"
        endif

The error is
Code:
Syntax error in 'eval" script for Thing 'pwRegenera' (Eval Script #1) on line 3
-> Error parsing right-side expression in relational comparison

Any help? :D
 
Did some changes in the script, add "then", but still no luck.

Code:
var val as number
      val = field[pwRanks].value
      if (val = 1) then
        field[pwInfo].text = "Recovers from Injured in 20 minutes, from Disabled in 1 hour or Dying in 5 hours."
      endif 
	  if (val = 2) then
        field[pwInfo].text = "Recovers from Injured in 10 minutes, from Disabled in 20 minutes or Dying in 1 hour."
      endif 
	  if (val = 3) then
        field[pwInfo].text = "Recovers from Injured in 5 minutes, from Disabled in 10 minutes or Dying in 20 minutes."
      endif 
	  if (val = 4) then
        field[pwInfo].text = "Recovers from Injured in 1 minutes (10 Rounds), from Disabled in 5 minutes or Dying in 10 minutes."
      endif 
	  if (val = 5) then
        field[pwInfo].text = "Recovers from Injured in 6 seconds (1 Round), from Disabled in 1 minute (10 Rounds) or Dying in 5 minutes."		
      endif 
	  if (val = 6) then
        field[pwInfo].text = "Recovers from Injured in 6 seconds (1 Round) without rest, from Disabled in 6 seconds, or Dying in 1 minute."
      endif 
	  if (val = 7) then
        field[pwInfo].text = "Recovers from Injured and Disabled in 6 seconds (1 Round) without rest, or Dying in 6 seconds."
      endif 
	  if (val = 8) then
        field[pwInfo].text = "Recovers from Injured, Disabled and Dying in 6 seconds (1 Round) without rest."
      endif
 
Last edited:
I notice that you changed your "==" to "=". I do apologize... I meant to run your script through the editor last night, but I ran out of time to do more than dash off a reply. If I may make a suggestion, go to Power Options and add a copy of "Recovery (Bruised)" or something similar and take a look at how they handle the text. I know they do that one with "if" and "elseif".
 
Thanks. I tried to follow that example, but still having errors.

Code:
Syntax error in 'eval" script for Thing 'pwRegenera' (Eval Script #1) on line 15
-> Error in right-side expression of assignment


Code:
var text as string
      if (field[pwmRanks].value = 1) then
        text = "Recovers from Injuried in 20 minutes, from Disabled in 1 hour or Dying in 5 hours."
      elseif (field[pwmRanks].value = 2) then
        text = "Recovers from Injuried in 10 minutes, from Disabled in 20 minutes or Dying in 1 hour."
      elseif (field[pwmRanks].value = 3) then
        text = "Recovers from Injuried in 5 minutes, from Disabled in 10 minutes or Dying in 20 minutes."
      elseif (field[pwmRanks].value = 4) then
        text = "Recovers from Injuried in 1 minutes (10 Rounds), from Disabled in 5 minutes or Dying in 10 minutes."
      elseif (field[pwmRanks].value = 5) then
        text = "Recovers from Injuried in 6 seconds (1 Round), from Disabled in 1 minute (10 Rounds) or Dying in 5 minutes."
      elseif (field[pwmRanks].value = 6) then
        text = "Recovers from Injuried in 6 seconds (1 Round) without rest, from Disabled in 6 seconds, or Dying in 1 minute."
      elseif (field[pwmRanks].value = 7) then
        text = "Recovers from Injuried and Disabled in 6 seconds (1 Round) without rest, or Dying in 6 seconds."		
      else
        text = "Recovers from Injuried, Disabled and Dying in 6 seconds (1 Round) without rest."
        endif
      field[pwmInfo].text = text
 
Last edited:
Still no access to the editor at the moment, but your "else" clause doesn't close out the string. There's a missing end quote.
 
Huh. Didn't know it worked like that. Your problem is that you have a tab at the end of your "7" line. Strangely enough, that causes it to error out. The following will work:
var text as string
if (field[pwmRanks].value = 1) then
text = "Recovers from Injured in 20 minutes, from Disabled in 1 hour or Dying in 5 hours."

elseif (field[pwmRanks].value = 2) then
text = "Recovers from Injured in 10 minutes, from Disabled in 20 minutes or Dying in 1 hour."
elseif (field[pwmRanks].value = 3) then
text = "Recovers from Injured in 5 minutes, from Disabled in 10 minutes or Dying in 20 minutes."
elseif (field[pwmRanks].value = 4) then
text = "Recovers from Injured in 1 minutes (10 Rounds), from Disabled in 5 minutes or Dying in 10 minutes."
elseif (field[pwmRanks].value = 5) then
text = "Recovers from Injured in 6 seconds (1 Round), from Disabled in 1 minute (10 Rounds) or Dying in 5 minutes."
elseif (field[pwmRanks].value = 6) then
text = "Recovers from Injured in 6 seconds (1 Round) without rest, from Disabled in 6 seconds, or Dying in 1 minute."
elseif (field[pwmRanks].value = 7) then
text = "Recovers from Injured and Disabled in 6 seconds (1 Round) without rest, or Dying in 6 seconds."
else
text = "Recovers from Injured, Disabled and Dying in 6 seconds (1 Round) without rest."
endif
field[pwmInfo].text = text

FWIW, I started by eliminating the line in question and verifying that it still failed. Finding no reason why it should, I typed the line in and it worked. I then copied and pasted both texts into Notepad++ and compared them to see the extra tab. Go figure. :)
 
Thanks, now it's compiling!

...But, it doesn't work! There's no text in the Power!

regen_script_failure.png
 
{facepalm} I knew I should have actually run it. The reason for that, I suspect, is because "pvmInfo" stands for "Power Modifier information". Look through the other powers and find one that modifies the text based on the contents. Gravity Control might work since it displays different text based on the rank involved.
 
No problem. :) We all have to start somewhere. I had the benefit of Colen available a good bit of the time to massage me through script issues.
 
Back
Top