CSPL Code Examples - Unit Thread
The interest in CSPL seems to have subsided again, so lets take a look at specific examples of CSPL Events. In this case, every event comes from the Manual, which means Angelo has already written out every piece of Code for you. We'll start with Chapter 5, the Unit Thread. Angelo has created 9 functions that do different things to Units, specifically:
DeleteUnit : Deletes a unit from the game
WriteUnit : Replace last unit read from memory
ReadNextUnit : Read next unit in unit list
CreateUnit : Adds a new unit in game
UnitAt : Gets unit at a particular position
UnitType : Gets the first unit of a particular type
UnitID : Gets the unit with a particular ID number
ReWriteUnit : Replace a particular unit
ResetUnit : Reset unit list counter, restart scanning unit list
The specific example he uses here in Chapter 5 involves linking two ToT maps East-to-West. That might seem like an odd example for units, but after all, the only things that change location on a map are units. That said, I won't delve into the details, since this was one of the examples that's already coded in the Example Program I posted earlier - which means you can see the code in action.
I encourage you to look more closely at the list of functions, since they hint at the kinds of Events which are possible. For example, UnitType could be used to identify all your Roman Legion Units, and a "Marian Reforms Event" could (using ReWriteUnit) upgrade them all to "Improved Legions".
Caveat: The learning curve for this program is fairly steep - for example, the first four chapters of the manual are all about getting started - and it's complex stuff.
The interest in CSPL seems to have subsided again, so lets take a look at specific examples of CSPL Events. In this case, every event comes from the Manual, which means Angelo has already written out every piece of Code for you. We'll start with Chapter 5, the Unit Thread. Angelo has created 9 functions that do different things to Units, specifically:
DeleteUnit : Deletes a unit from the game
WriteUnit : Replace last unit read from memory
ReadNextUnit : Read next unit in unit list
CreateUnit : Adds a new unit in game
UnitAt : Gets unit at a particular position
UnitType : Gets the first unit of a particular type
UnitID : Gets the unit with a particular ID number
ReWriteUnit : Replace a particular unit
ResetUnit : Reset unit list counter, restart scanning unit list
The specific example he uses here in Chapter 5 involves linking two ToT maps East-to-West. That might seem like an odd example for units, but after all, the only things that change location on a map are units. That said, I won't delve into the details, since this was one of the examples that's already coded in the Example Program I posted earlier - which means you can see the code in action.
I encourage you to look more closely at the list of functions, since they hint at the kinds of Events which are possible. For example, UnitType could be used to identify all your Roman Legion Units, and a "Marian Reforms Event" could (using ReWriteUnit) upgrade them all to "Improved Legions".
Caveat: The learning curve for this program is fairly steep - for example, the first four chapters of the manual are all about getting started - and it's complex stuff.
Comment