egzistas Posted July 18, 2019 Posted July 18, 2019 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. Quote
0 DenArt Designs Posted July 18, 2019 Posted July 18, 2019 why python? everything works on java its 2019 :D onFirstTalk exist on core while testas no Quote
0 DnR Posted July 18, 2019 Posted July 18, 2019 (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 July 18, 2019 by DnR Quote
Question
egzistas
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
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.