Issues with script

Posted by Sanichi on Sat 25 Oct 2014 08:39 PM — 7 posts, 34,165 views.

#0
I'm having issues starting up a script in Windows 8.1, I'm not sure if it's an issue with the script or how I've gotten python working on this computer. This script worked for me when my computer was originally a Windows 8, but I recently had to clear my system due to issues. Is there any advice for my problem?

The error reads as follows:

Quote:
Script error
Plugin: DMSkillController (called from world: DM)
Execution of line 154 column 4
Immediate execution
unexpected indent
Line in error:
def SkillImprove(TriggerName, trig_line, wildcards):
Error context in script:
150 :
151 :
152 :
153 :
154*: def SkillImprove(TriggerName, trig_line, wildcards):
155 :
156 : #Concatonate all the variables passed by the MUSHclient
157 : vName = ''.join([wildcards[x] for x in range(len(wildcards)-1)])
158 :
[WARNING] C:\Program Files (x86)\MUSHclient\worlds\plugins\Counter.xml
Line 63: Error parsing script (Cannot load)
Australia Forum Administrator #1
I'm no Python expert, but isn't it usually indented? eg.


def SkillImprove(TriggerName, trig_line, wildcards):

  #Concatonate all the variables passed by the MUSHclient
  vName = ''.join([wildcards[x] for x in range(len(wildcards)-1)])


After all, the error message was:


 unexpected indent
Amended on Sat 25 Oct 2014 09:04 PM by Nick Gammon
#2
I'm not quite sure if that might be the issue in this case.
Many similar indentions are found through the code:

Quote:
https://gist.github.com/castercerberus/f4a4bb543ce005d9b2cf


And.. I suspect it might be compatibility issues since other people have been able to utilize the script. Though, I'm more clueless about this subject than most about here.
Australia Forum Administrator #3
The link showed the code indented:


    <script>
    <![CDATA[
    def SkillImprove(TriggerName, trig_line, wildcards):

       #Concatonate all the variables passed by the MUSHclient
       vName = ''.join([wildcards[x] for x in range(len(wildcards)-1)])

       #Replace invalid characters with other characters to store as variables
       vName = vName.replace(' ', '_').replace('\'', '').replace('-', '_').replace('#', '_')

       #If the variable doesn't currently have a value give it
       #the value of 1, else increment it by 1
       if not world.GetVariable(vName):
          vValue = 1
       else:
          vValue = int(world.GetVariable(vName)) + 1

       #Display in the command window the improvement message
       #with the corresponding number of improvements added in
       world.SetVariable(vName, str(vValue))
       world.ColourTell('#00FFFF', '', '* You think your ' + str(vName))
       world.ColourTell('#FFFFFF', '', ' [')
       world.ColourTell('#FF0000', '', str(vValue))
       world.ColourTell('#FFFFFF', '', '] ')
       world.ColourNote('#00FFFF', '', 'skill has improved. *' )



The error message you posted did not.

I think there might be an issue in the way you are saving the plugin.

Click on the "raw" button ( gist:f4a4bb543ce005d9b2cf ) and save that to disk as your plugin.
Amended on Sat 25 Oct 2014 11:05 PM by Nick Gammon
Australia Forum Administrator #4
I found that if I copied and pasted from your link (but not the "raw" link) it seemed to discard all indentation, for some reason. That's why I suggested using the raw code.
#5
Seems it working now!
That's.. fairly odd it tends to save like that though.

Thank you!
Australia Forum Administrator #6
Yes, it is odd.

This, by the way, is why I don't like languages where the amount of whitespace (the indentation) has syntactic meaning.