[BtS] [Python(?)] Taskmaster: Civ4lerts + Reminders = True

Stormreaver

Warlord
Joined
Nov 5, 2001
Messages
171
Location
Stockholm
Ok, I've played two games in BtS now, and I really do not want to go back to Vanilla or Warlords. However, playing without the Civ4lerts mod is a real pain in the arse for me, since I've become reliant on it. I haven't seen a BtS version of this mod yet, but am willing to put in time to make one.

Also, I'm a micromanager, but I'd like to streamline it as much as possible, so this is my idea for a mod, it will combine Civ4lerts and eotinbs Reminders.

Anyway, I want a window, like the score window where all tasks are kept. Each task has the following info: A description, a turn where it was initiated & a turn where it should be dealt with.

For example when I start building a Library in turn 64 producing 6 hammers/turn I want to manually add a reminder in 10 turns when I can whip it spending only one pop. Data for a manually entered task for this would be (exactly a reminder) "Whip Library in Moscow", 64, 74

As stuff happens (Civ4lert style: City grows and so on) a task is automatically added to the list. Say Moscow grows in turn 68: "Moscow grows to 5", 68, 68

So these would show up in a list to the right above (in place of?) the civ score list with all tasks sorted by trigger date, and tasks that should be dealt with this turn highlighted or differently colored. Also, each task has three buttons next to them making the list on turn 68 look something like:

Moscow grows, 68, 68 |1| |x| |D|
Whip Library in Moscow, 64, 74 |1| |x| |D|

The buttons do the following:
|1| = Push this tasks trigger turn up by one, if you for some reason needs to come back to it next turn
|x| = As above, but you get a popup asking you to reschedule it for x turns forward
|D| = Dismiss task, removing it from list

The benefits as I see it is that I don't anymore have to rely on the event log for stuff (sometimes you miss messages there when there's a lot going on, and the Event Log window is a pain to scroll through), and I get the peace of mind not having to recheck if I've tended to all events or reminders that occured this turn. If I've dismissed the task, I've taken care of it. If there are no highlighted tasks, I can confidently end the turn.
 
Now, since I'm not a Python coder, nor a Civ4 modder, I've run into some problems quite early. I've more or less used the Reminder mod code as a blueprint for adding tasks manually (I haven't gotten around to creating the task window yet, of course, first things first).

One thing I did want to do is to add a Task class, so I've added a self.tasks = [] array in CvEventManager.py, but when trying to add objects into the array using my selfdefined Task class they seem not to get there.

Code for my class below, exists in file Mods\Taskmaster\Assets\Python\TaskmasterTask.py
Spoiler :
Code:
class TaskmasterTask:
	text = "Generic Task"
	turnInit = 0
	turnTrigger = 1
	turnUpdate = 0
	
	def __init__(self,inText,inTurnInit,inTurnTrigger):
		self.text = inText
		self.turnInit = inTurnInit
		self.turnUpdate = inTurnInit
		self.turnTrigger = inTurnTrigger

	def getText(self):
		return self.text
	
	def getTurnTrigger(self):
		return self.turnTrigger
	
	def getTurnInit(self):
		return self.turnInit
	
	def getTurnUpdate(self):
		return self.turnUpdate


And I add events using the following code (The popup code is omitted as the popup appears as expected, after all the code is just more or less stolen... um... reused from the Reminder modcomp:
Spoiler :
Code:
initTurn = gc.getGame().getGameTurn()
  triggerTurn = popupReturn.getSpinnerWidgetValue(0) + gc.getGame().getGameTurn()
  taskText = popupReturn.getEditBoxString(1)
  newEntry = [COLOR="Blue"]TaskmasterTask.[/COLOR]TaskmasterTask(taskText, initTurn, triggerTurn)
  self.tasks.append(newEntry)

The following iteration gives no output
Spoiler :
Code:
for i in range(len(self.tasks)):
  messageDebug1 = self.tasks[i].getText()
  CyInterface().addImmediateMessage(iPlayer, True, 30, messageDebug1, 'AS2D_ALARM', 0, None, ColorTypes(11), 0, 0, False, False)

Do I need to include my .py file manually somewhere or is it automatically loaded as I've assumed? Something wrong with my class definition? I'm quite java-centered, since that's my profession, but I'm positive the tabs are alright. (Python uses tab indentation to decide scope, right?)
Edit: Added an import to CvEventManager ("import TaskmasterTask"). Did not help though..
Edit2: I had to qualify the constructor for a TaskmasterTask, code change in blue in spolier above. This problem solved...
 
Back
Top Bottom