|Tom Endeman (Unknown)||05.07.2015 13:15|
|a friend of mine makes a animalmod ,
now who is looking for the information when you buy an animal through the shop ,
the game report that it is purchased through the shop .
This information is publicly available ?
|Emil Drefers (Unknown)||06.07.2015 08:02|
your friend does know the script documentation?
But OK, there i sno information about the shop or event of buying an animal.
So maybe this can help him:
The gui for the shop is located in the follwoing global variable:
and it has a function which gets called if an animal has been bought:
He should not change it in any case.
But he can hook in to that function and get his own code working.
By the way, what is he planning to do with that information?
|Dirk Peeters (Unknown)||06.07.2015 09:57|
i'm the friend.
i was looking in the g_shopScreen for a clue but thx for the function.
Wy i need this information is as followed:
i'm creating a LifeCycle script that works on the default animalTypes. on all maps, runs in background like a dayNightCycle.
the LifeCycle will have ageing, breeding as main goal of the script and will incl. dayOfBirth, maxAge, breedAge, ancestry,......
- you go to shop and buy a animal.
- we check if animalsOwned is bigger/smaller than the ingameOwnedAnimal.
- if so, add/remove the animal to/from the lifeCycle table
- check and update the current AnimalAge, breedStatus, endDay
- check and update if breedStatus and we match the conditions to start breeding
- start breeding prosess
- end breeding prosess and add animal to lifeCycle
- if animal reaches maxAge, it dies (maby later add a sickness system behind it, in case you forgot to feed the animals)
once you buy a animal its added to the LifeCycle table and the ancestry could be "store", "other" or "breed".
i now check like 'g_currentMission.husbandries.cow.totalNumAnimals > G_AnimalMod.LifeCycle.cowOwned'.
but i wanted a more correct check if the animal comes from the store or at the moment is from a saved game. (i have not yet a load/save function set up).
Are the animals that you buy indexed by a ID? to link the animalID to the lifeCylce.ID for correct removement
quick not tested code
if(g_currentMission.husbandries.cow.totalNumAnimals > G_AnimalMod.LifeCycle.cowOwned and ShopScreen:onAnimalBought()) then
ancestry = "Shop";
elseif(g_currentMission.husbandries.cow.totalNumAnimals > G_AnimalMod.LifeCycle.cowOwned) then
ancestry = "other";
|Dirk Peeters (Unknown)||06.07.2015 10:13|
|i'm still learning lua, but at the moment i have the lifecylce working in SP mode
|Emil Drefers (Unknown)||07.07.2015 08:05|
sounds like an interesting mod.
But probably hard to set up correctly without access to all scripts.
Eventually it might be easier to apply it to a completly modded cow system and not try to interfer with the original system.
The animals are not indexed, only the total amount is saved.
Your 'quick code' won't work ; )
The onAnimalBought is a function which gets called once as soon as an animal has been bought.
So it's kind of senseless to call it every frame.
|Dirk Peeters (Unknown)||07.07.2015 10:24|
i will keep you informed on the status of this project,
here is a link to my post about the mod on fs-uk
Note: Log in to post. Create a new account here.