Jump to content

Question

Posted

Hello I was coding, everything was ok till i started to put this :

 

def testas() :
    test = "ane"
    if player.isGm() : 
        test = "jo";
    return test

 

In another code sections it´s working perfectly...

 

    def onFirstTalk (self,npc,player):
        st = player.getQuestState(QUEST_LOADING_INFO)
        if not st : st = self.newQuestState(player)
        if player.isGM():

..............

 

 

Yes, i tried to put player in testas(player) same poop.

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

You seem to have zero knowledge regarding Python OOP, so I suggest you take a small look here: https://www.w3schools.com/python/python_classes.asp

 

For start, try calling your new method using 'self' reference which is almost equivalent to Java's 'this' reference.

Also, there must be an extra first parameter that refers to current object and exists solely to give you access to it. In most cases, developers name it self.

So, your method parameters should look like this: def testas(self, player):

and you should call it like this: self.test(player)

 

*Note: Do not use semicolons in Python.

 

I hope you find these tips helpful.

Edited by DnR

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..