Jump to content
  • 0

Python script


egzistas

Question

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.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...