Page 4 of 4 FirstFirst 1 2 3 4
Results 91 to 113 of 113

Thread: Initial Python reference

  1. #91
    MMC
    King MMC's Avatar
    Join Date
    30 Mar 2006
    Location
    of the wet little isle known as Britain
    Posts
    1,205
    Country
    This is MMC's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    Just a quickie...

    What does the file '<CivDir>\Assets\Python\Screens\CvDanQuayle.py' actually do? And why is it called Dan Quayle (I do know who he is)?

    Also, in reference to removing improvements, what about 'onPillage' or something? Is there a function like that?
    Ceeforee v0.1 - The Unofficial Civ 4 Editor -= Something no Civ Modder should ever be without =- Last Updated: 27/03/2009
    "Just because I'm paranoid doesn't mean there's no conspiracy"

  2. #92
    Locutus
    Deity Locutus's Avatar
    Join Date
    23 Nov 1999
    Location
    De Hel van Enschede
    Posts
    11,706
    Country
    This is Locutus's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    08:02
    Wow, forgot about this thread

    Not gonna bother answering questions that are more than 4 months old, I assume everyone either already found an anwer or gave up. If anyone still has any outstanding questions they want answered, just repeat them...

    Originally posted by MMC
    Just a quickie...

    What does the file '<CivDir>\Assets\Python\Screens\CvDanQuayle.py' actually do? And why is it called Dan Quayle (I do know who he is)?
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

  3. #93
    Elustrian
    Settler
    Join Date
    20 Feb 2006
    Posts
    12
    Country
    This is Elustrian's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02

    Event Logging

    Hi,

    Working on my first mod and one of the added features is a disease promotion that spreads to nearby units and eventually kills infected units - a bioterrorist element. This works fine but my playtesters are concerned that this is a very quiet event - no indications except for changing promotions which can be difficult to catch.

    I added the following:

    popup=PyPopup.PyPopup()
    popup.setBodyString('Your Unit has been infected')
    popup.launch()

    which works fine except that the message appears on everyone's screen.

    How would someone add messages to the events log that already are posted on individual's screens.

    Thanks for your help in advance,
    Cheers

  4. #94
    Locutus
    Deity Locutus's Avatar
    Join Date
    23 Nov 1999
    Location
    De Hel van Enschede
    Posts
    11,706
    Country
    This is Locutus's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    08:02
    Two ways to do that. If you want a popup like above, simply precede it by a check if the affected player is the active player, that is the player running the script on his pc:

    Code:
    if gc.getGame().getActivePlayer() == gc.getPlayer(iAffectedPlayer):
    Or, perhaps more elegantly and less intrusive, you could display a message in the top-left corner of the screen, like what happens when e.g. a religion spreads:

    Code:
    button = "[path to some icon you want to use for the arrow pointing to the unit in question]"
    CyInterface().addMessage(iAffectedPlayer, False, 0, "Your Unit has been infected", "", 0, button,     \
                CyGame().getReplayMessageColor(0), affectedUnit.getX(), affectedUnit.getY(), True, True)
    If you don't want to bother with arrows and icons and all that:

    Code:
    CyInterface().addMessage(iAffectedPlayer, False, 0, "Your Unit has been infected", "", 0, "",     \
                CyGame().getReplayMessageColor(0), 0, 0, False, False)
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

  5. #95
    Elustrian
    Settler
    Join Date
    20 Feb 2006
    Posts
    12
    Country
    This is Elustrian's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    Nice!

    Answered my question and the next step that I hadn't considered yet (the event button).

    Looking forward to implementing next hacking session.

    Many Thanks,
    Elustrian

  6. #96
    Scorpi40000
    Warlord Scorpi40000's Avatar
    Join Date
    01 Aug 2002
    Location
    Denmark
    Posts
    160
    Country
    This is Scorpi40000's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    07:02
    Is it possible to use onUnitMove() to charge x gold from any player every time any of his units moves one square?
    "Learn to overcome the crass demands of flesh and bone, for they warp the matrix through which we perceive the world. Extend your awareness outwards, beyond the self of body, to embrace the self of group and the self of humanity. The goals of the group and the greater race are transcendent, and to embrace them is to achieve enlightenment."

    -- Sheng-ji Yang, "Essays on Mind and Matter"

  7. #97
    Locutus
    Deity Locutus's Avatar
    Join Date
    23 Nov 1999
    Location
    De Hel van Enschede
    Posts
    11,706
    Country
    This is Locutus's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    08:02
    Yeah sure.

    Code:
    	def onUnitMove(self, argsList):
    		'unit move'
    		pPlot,pUnit = argsList
    		player = gc.getPlayer(pUnit.getOwner())
    		player.changeGold(-x)
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

  8. #98
    Tigga
    Settler
    Join Date
    04 Nov 2005
    Posts
    6
    Country
    This is Tigga's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    The API link on the first post is bad. The current one I'm using is http://civilization4.net/files/modding/PythonAPI_v160/ - is this the same as the 1.61 API?

    Also, the type-list link off the Updates tab doesn't work - you have to go through the legend or get to it by clicking on a type in the API.

  9. #99
    PJayTycy
    King
    Join Date
    23 Apr 2005
    Posts
    1,709
    Country
    This is PJayTycy's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    07:02
    Locutus, the link in the first post is still wrong.
    no sig

  10. #100
    wotan321
    Warlord wotan321's Avatar
    Join Date
    23 May 2001
    Location
    Nowheresville, Man
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    01:02
    I have a WBS file that has sleeping units..... in other words when the WBS scenario starts, all the units on the map are fortified, so I don't have to visit each one and give it orders. This is a good thing if you have dozens of units.

    But I have started another scenario, a WBS file, and put in the "Sleep" line with the unit, just like in the other WBS file, but when I start the scenario, I have to visit each unit.

    What is the difference? What python file needs to be imported for them to be asleep?

    Thanks for any help you can provide.
    Question Authority.......with mime...

  11. #101
    wotan321
    Warlord wotan321's Avatar
    Join Date
    23 May 2001
    Location
    Nowheresville, Man
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    01:02
    I just learned that the Sleep command in the WBS file didn't come around until the 1.61 update, so maybe my mod's globaldefines.xml file is out of date....?
    Question Authority.......with mime...

  12. #102
    MMC
    King MMC's Avatar
    Join Date
    30 Mar 2006
    Location
    of the wet little isle known as Britain
    Posts
    1,205
    Country
    This is MMC's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    I think you're asking in the wrong section. The WBS files are nothing to do with python. You could try creating a new thread for your problem.
    Ceeforee v0.1 - The Unofficial Civ 4 Editor -= Something no Civ Modder should ever be without =- Last Updated: 27/03/2009
    "Just because I'm paranoid doesn't mean there's no conspiracy"

  13. #103
    wotan321
    Warlord wotan321's Avatar
    Join Date
    23 May 2001
    Location
    Nowheresville, Man
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    01:02
    You are mostly correct, though I found some WBS code in some python files which is what originally inspired me to ask here. But later investigating turned up the aforementioned xml file as the solution, so you are right. Sorry about the confusion, and thanks for the very helpful advice.
    Question Authority.......with mime...

  14. #104
    wotan321
    Warlord wotan321's Avatar
    Join Date
    23 May 2001
    Location
    Nowheresville, Man
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    01:02
    Well, as it turns out, the globaldefines.xml files were all up to date. The problem is that the scenario I am trying to mod has numerous changes to other files that prevent the 1.61 changes from working.

    So... in a python related question..... what code could I add to my events file, so that at the beginning of the scenario, each unit is visited and set to "fortify"?

    Thanks.
    Question Authority.......with mime...

  15. #105
    Thror78
    Chieftain
    Join Date
    15 Aug 2006
    Posts
    36
    Country
    This is Thror78's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    Hoi U Pythons:

    I try to make sth like a KingUnit:

    In the StartYear i want to create a GreatGeneral with the name of the leader of the specific nation.
    This is what i got so long:

    //--- CvEventInterface.py -----------------------------------

    def onGameStart(self, argsList):
    if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR")):
    for iPlayer in range(gc.getMAX_PLAYERS()):
    pPlayer = gc.getPlayer(iPlayer)
    pPlayer.addFreeUnit((UnitTypes)91)

    //------------------------------------------------------------------

    i know that there was somewhere a function where you can tell a unit its name but hadn't found it again.
    The >addFreeUnit((UnitTypes)91)< -function works in C++ good don't know if it does with python...

    Any help in here would be pretty nice

    Thx Tom
    Last edited by Thror78; September 14, 2006 at 09:54.

  16. #106
    Thror78
    Chieftain
    Join Date
    15 Aug 2006
    Posts
    36
    Country
    This is Thror78's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    The code above doesn't work. Any idea how to change it.
    And how i can name the unit by python?
    Last edited by Thror78; September 15, 2006 at 22:35.

  17. #107
    Locutus
    Deity Locutus's Avatar
    Join Date
    23 Nov 1999
    Location
    De Hel van Enschede
    Posts
    11,706
    Country
    This is Locutus's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    08:02
    I'm not aware of the existance of any function called addFreeUnit, but just 91 without the cast should work fine. gc.getDefineINT should work for the unit name as well if you're looking for that.
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

  18. #108
    Locutus
    Deity Locutus's Avatar
    Join Date
    23 Nov 1999
    Location
    De Hel van Enschede
    Posts
    11,706
    Country
    This is Locutus's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    08:02
    Originally posted by wotan321
    So... in a python related question..... what code could I add to my events file, so that at the beginning of the scenario, each unit is visited and set to "fortify"?
    Probably something along the lines of:

    Code:
    def onGameStart(self, argsList):
    	if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR")):
    		for iPlayer in range(gc.getMAX_PLAYERS()):
    			pPlayer = gc.getPlayer(iPlayer)
    			for iGroup in range(pPlayer.getNumSelectionGroups()):
    				gGroup = pPlayer.getSelectionGroup(iGroup)
    				gGroup.pushMission(gc.getDefineINT("MISSION_FORTIFY", 0, 0, 0, false, false, -1, gGroup.plot(), gGroup.getHeadUnit())
    Disclaimer: untested, can't guarantee it'll do anything (or even that it doesn't contain typos)
    Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

  19. #109
    upon
    Settler
    Join Date
    24 Dec 2006
    Posts
    2
    Country
    This is upon's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    My problem is the same. I don't know how execute it!

    ________________________________
    admiral@digitalhardcore.us

  20. #110
    Gaurav0
    Settler
    Join Date
    10 Jan 2007
    Posts
    1
    Country
    This is Gaurav0's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    Is there a version of the python api updated to patch 2.08?

  21. #111
    MMC
    King MMC's Avatar
    Join Date
    30 Mar 2006
    Location
    of the wet little isle known as Britain
    Posts
    1,205
    Country
    This is MMC's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    06:02
    Will this API every be updated for BtS?
    Ceeforee v0.1 - The Unofficial Civ 4 Editor -= Something no Civ Modder should ever be without =- Last Updated: 27/03/2009
    "Just because I'm paranoid doesn't mean there's no conspiracy"

  22. #112
    nelson1234
    Settler
    Join Date
    08 Feb 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    01:02
    I like this thread.......

  23. #113
    nelson1234
    Settler
    Join Date
    08 Feb 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 21, 2013
    Local Time
    01:02
    i like it very much........

Page 4 of 4 FirstFirst 1 2 3 4

Similar Threads

  1. python import of external python question
    By DougM in forum Civilization IV Creation
    Replies: 0
    Last Post: February 8, 2006, 15:34
  2. Python reference question
    By vovan in forum Civilization IV Creation
    Replies: 4
    Last Post: November 1, 2005, 11:02
  3. CIV 4 - Initial Python Reference y una Utilidad
    By OBV in forum Civilization en Español
    Replies: 3
    Last Post: October 26, 2005, 19:34
  4. Replies: 14
    Last Post: March 23, 2003, 12:11
  5. mod cross-reference
    By seawolfe in forum CtP2-Creation/AI/Mods/Scenarios-Archive
    Replies: 4
    Last Post: February 15, 2002, 13:37

Visitors found this page by searching for:

powered by vBulletin reference

civ4 python api onsavegame

civilizaton 3 pyton scripti

initial python

techacquired civ5

civ iv cultural citystyles and roads

send string python to dll civfanatics

civilization 4 python reference

initial references page

CvUtil.pyPrint

civ4 trigger(gc.getInfoTypeForString position

CvUnitInfo civ4

civilization 4 onbeginplayerturn

civ4 colonization python addcombatmessage

civ5 add new promotion

civ4 python city object

cvi4 gc.getinfotypeforstring

civ 4 change specialistinfos

how to make a python map civ 4

civ4 python check player has tech

civilization iv cant start pyhton

civilization 5 pplayer

civ4 gc.getinfotypeforstring(improvement_farm)

civfanatics g&amp;k unitaitype

pplot documentation python

Bookmarks

Posting Permissions