TheLopez
Feb 25, 2006, 05:29 PM
Anyone know what happened to the Python API located at:
http://www.sthurlow.com/cvDocs/
I haven't been able to reach it all day :mad:
http://www.sthurlow.com/cvDocs/
I haven't been able to reach it all day :mad:
|
View Full Version : Python API TheLopez Feb 25, 2006, 05:29 PM Anyone know what happened to the Python API located at: http://www.sthurlow.com/cvDocs/ I haven't been able to reach it all day :mad: Belizan Feb 25, 2006, 05:42 PM I don't know, I noticed it was down this morning when I was linking it in to Valchas' thread. I've been working on a reflection tool to inspect Python objects, it's not very far along, but it is occasionally helpful... def getInfoOnObject(pObj): sObj = str(pObj.__class__) sFields = str(pObj.__dict__) pPlayer = gc.getPlayer(0) iX = pPlayer.getStartingPlot().getX() iY = pPlayer.getStartingPlot().getY() #sMethods = str(pObj.__methods__) #sMembers = str(pObj.__members__) sDir = str(dir(pObj)) count = 0 for sField in dir(pObj): sField = str(sField) if(sField[0] != '_'): count = count + 1 if(count > 2): message = sField CyInterface().addMessage(0,True,len(message),messa ge,'AS2D_BOMBARDED',0,'Art/Interface/Buttons/Units/Fighter.dds',ColorTypes(6),iX,iY,True,True) sAttrDir = str(dir(getattr(pObj, sField))) break methodList = [method for method in dir(pObj) if callable(getattr(pObj, method))] fieldList = [field for field in dir(pObj) if not callable(getattr(pObj, field))] processFunc = 1 and (lambda s: " ".join(s.split())) or (lambda s: s) message = "\n".join(["%s %s" %(method.ljust(30), processFunc(str(getattr(pObj, method).__doc__))) for method in methodList]) CyInterface().addMessage(0,True,len(message),messa ge,'AS2D_BOMBARDED',0,'Art/Interface/Buttons/Units/Fighter.dds',ColorTypes(7),iX,iY,True,True) #message = message + "\n".join(["%s %s" %(field.ljust(30), str(type(getattr(pObj, field)))) for field in fieldList]) message = "\n".join(["%s %s" %(field.ljust(30), str(type(getattr(pObj, field)))) for field in fieldList]) CyInterface().addMessage(0,True,len(message),messa ge,'AS2D_BOMBARDED',0,'Art/Interface/Buttons/Units/Fighter.dds',ColorTypes(7),iX,iY,True,True) #message = "Object:" + sObj + "\nFields:" + sFields + "\nMethods:" + sMethods +"\nMembers" + sMembers #message = "Object:" + sObj + "\nFields:" + sDir + "\nTest: " + sAttrDir #message = "Object:" + sObj + "\nFields:" + sDir #message = "Object:" + sObj + "\n\n" + message message = "Object:" + sObj + "\n\n" CyInterface().addMessage(0,True,len(message),messa ge,'AS2D_BOMBARDED',0,'Art/Interface/Buttons/Units/Fighter.dds',ColorTypes(7),iX,iY,True,True) Alyph Feb 25, 2006, 05:43 PM why not download the html version onto your machine? RogerBacon Feb 25, 2006, 09:20 PM There's one at http://civilization4.net/files/modding/PythonAPI/ but I think it is a little out of data. Some of the functions have changed in the 1.52 patch. Still, it's better than nothing. Roger Bacon TheLopez Feb 25, 2006, 09:32 PM There's one at http://civilization4.net/files/modding/PythonAPI/ but I think it is a little out of data. Some of the functions have changed in the 1.52 patch. Still, it's better than nothing. Roger Bacon Roger, I stopped using that one when I found this one: http://www.sthurlow.com/cvDocs/ Oh well. Belizan Feb 25, 2006, 10:11 PM I use them both. Plus that function I pasted. Haven't figured out how to get the args of a method. I'm not a Python guy. Only learned Python about a month ago (30 days as of three days ago!!! Yay me!.. er.. whatever), and I haven't found a really juicy, accessible presentation of the language in a manner that makes me smile basking in the glow of sudden comprehension 8). I have written enough scripting language compilers to believe that it must be possible. Even though it seems apparent that Python is implemented in C/C++, it has the *appearance* of a design developed in itself. Or most likely in a much (*cough*, *cough*) better language, like Smalltalk. As such presumably all the pieces you would need to make a function call should be accessible from within the language, even if it lacks formal Reflection. Sadly, even having the arg information will only get me so far, as Python, being weakly typed, won't have much information about the args other then default value, and it's name (given that it uses direct string keys in a dictionary for its namespaces). Crazy. 12monkeys Feb 27, 2006, 01:01 PM For those who stopped trying it : sthurlow is up again! |
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.