Trying to tweak a mod for my own megalomaniacal needs

racha

Prince
Joined
Jul 27, 2013
Messages
335
Location
Over there --->
I was particularly tickled by one of Whoward's mods, the herdsman, and I've been trying to tweak it to affect bison, before going on to including all the other animals from the resource mod pack that I use.

I can get the herdsman to show rustle as an option when standing on a bison tile, but clicking on it does nothing. I'm also able to spawn a herdsman with bison, using the IGE, but clicking on the un-rustle button does nothing, either, and the unit remains a herdsman with bison.

Not knowing the first thing about lua (I haven't had the time to read the tutorials on this site), I've simply looked through those files and wherever there was a reference to sheep or cows, copied those lines and amended them to bison. In the XML files, I've re-used the art stuff for the cattle rustler.

What am I missing / doing wrong?

Attached my edited version of the mod to this post, with my additions clearly labelled.
 

Attachments

  • Units - Herdsmen (v 10) (bison).zip
    111.5 KB · Views: 23
Not checked all the code, but a couple of obvious mistakes at the top of the Lua file

Code:
local iHerdsmanSheep = GameInfoTypes.UNIT_HERDSMAN_SHEEP
local [B][COLOR="Red"]iHerdsmanSheep[/COLOR][/B] = GameInfoTypes.UNIT_HERDSMAN_BISON		-- bison

local iImprovementPasture = GameInfoTypes.IMPROVEMENT_PASTURE
local [B][COLOR="red"]iImprovementPasture[/COLOR][/B] = GameInfoTypes.IMPROVEMENT_CAMP		-- bison

First one should be iHerdsmanBison, second should be iImprovementCamp
 
Now I feel... sheepish.

Corrected those errors, and I also found a missing space in this line:

Code:
if (pUnit:GetUnitType() == iHerdsmanHorses or pUnit:GetUnitType() == iHerdsmanCows or pUnit:GetUnitType() == iHerdsmanSheep[COLOR="Red"]or[/COLOR] pUnit:GetUnitType() == iHerdsmanBison) then		-- bison

but I'm getting the same result.

Edit: whatever I've broken, it's causing herdsmen to build pastures on sheep and cows, even outside my borders, when I hit the rustle button.
 
The second elseif block you modified is wrong, it should be

Code:
    -- Need to create resource XYZ
    if (pUnit:GetUnitType() == iHerdsmanHorses) then
      -- Special handling for horses, need to work out how many there were
      -- SNIP ...
    elseif (pUnit:GetUnitType() == iHerdsmanCows) then
      ChangeResource(pPlot, GameInfoTypes.RESOURCE_COW, 1, iImprovementPasture)
    elseif (pUnit:GetUnitType() == iHerdsmanBison) then										-- bison
      ChangeResource(pPlot, GameInfoTypes.RESOURCE_BISON, 1, iImprovementCamp)			-- bison
    else
      ChangeResource(pPlot, GameInfoTypes.RESOURCE_SHEEP, 1, iImprovementPasture)
    end
 
I copied and pasted your code (after the snip line) and overwrote what I already had. I'm still unable to rustle anything (not just bison). I can't find anything in lua.log or database.log that seems related.
 
So much easier when you turn off all the other mods:

[34970.541] Syntax Error: C:\Users\user\Documents\My Games\Sid Meier's Civilization 5\MODS\Units - Herdsmen (v 10) (bison)\LUA/UnitsHerdsmen.lua:73: ')' expected near 'pUnit'
 
It works! I'm off to sit in the dunce corner. Looks like I managed to go back to my copy of your original mod, forgetting about that darn typo I found.

Thanks for the help, as always!
 
Top Bottom