Ideas on how to determine the player who crafted an object

marceloSRmarceloSR Posts: 47 Seed
Currently I'm working on a mod to collect players' data to later analyze TUG players' behaviors. This is the first part of my masters thesis. The idea is to classify players according to their actions in the game, such as mining, building, harvesting, farming, etc..

Right now I'm trying to figure out the best way to determine the player that crafted an object. (player name, position, current biome, crafted object)

What I know right know is:
- LocalPlayer:OnBeginCraft, this functions is triggered in the client every time the player press the key G and request a craft to the server. It shows me the intention, but it does not show if the craft was done or not.

- BasePlayer:OnSuccesfulCraft, this function happens in the server when a craft was done successfully. However, as this happens in the server only, there is no way to determine the local player that triggered this function.

- CraftModel:Accumulate, this function is supposed to give experience to the player when he successfully craft an object. However, I could not work with this function. I'm not quite sure who call it and even if it is being called at all.

- ServerCraftingMixin:StartCrafting, this function should be the server giving an OK to the client and actually start the craft (from what I got it pass to the player the recipe name in order to display in the player UI, see function below) . However, the player can cancel the craft at any time, so it does not give me any information.

- ClientCraftingMixin:ClientEvent_StartCrafting, is the function called in the client by the previous function. This can give me the recipe the player is trying to craft and the player itself. However, again, the player can cancel the craft at any time.

- ClientCraftingMixin:InterruptCrafting(), this tells me if the player interrupted the craft.

- DefaultRecipe:BeginCrafting, I believe this tells me the same thing of the ClientCraftingMixin:ClientEvent_StartCrafting, as it happens after the server determine if the recipe can be done. So if I have trouble with the ClientCraftingMixin I might use this one to get when the player actually starts the craft.

My current solution would be to use the ClientCraftingMixin:ClientEvent_StartCrafting to get the recipe, player and time that it takes for the craft to finish. Then I could set a timer in my mod based on the recipe crafting time and if ClientCraftingMixin:InterruptCrafting() is called I cancel the timer and do not register the event. Otherwise, if the timer ends, I register a succesful craft event with the data from the ClientCraftingMixin:ClientEvent_StartCrafting.

Or I could try this other function

- DefaultRecipe:EndCrafting, this function calls OnSuccesfulCraft if the craft was done right. It receives the player as an argument so it can use the player position to spawn the object after the craft is done.

What do you think about these approaches?? There is any better way of doing this?
I want to avoid cross-relating data in the future as much as possible. That is why I want to record the data with all information that I'll need right now.

Comments

  • marceloSRmarceloSR Posts: 47 Seed
    i don't think the DefaultRecipe.EndCrafting actually receives the player as a argument .

    The function uses player:GetCurrentCraftingLocation()
    However, GetCurrentCraftingLocation() is a method in the ServerCraftingMixin class. So I guess this player has no reference with the LocalPlayer or BasePlayer...
  • marceloSRmarceloSR Posts: 47 Seed
    UPDATE:

    The solution with the timer is working fine. I'm able to get everything I need!
  • CharlockCharlock Posts: 293 Seed
    Color me very impressed. I am very intrigued in what sort of data you'll be able to collect and even more so intrigued to find out how you use it in your thesis! It's a very unique idea and I'm excited that you've chosen to use TUG as your data bed.

    PLEASE let me know if you need assistance from other players to gather your information! I would be both glad and privileged to be apart of your research!

    Good luck and I hope you'll share at least a portion of your findings when all is said and done!
    "I’ve been drunk for about a week now, and I thought it might sober me up to sit in a library."
  • marceloSRmarceloSR Posts: 47 Seed
    Thank you very much Charlock.
    All the help I can get to collect more data will greatly contribute to my research.

    As soon as I have more updates on it I'll let you know.
Sign In or Register to comment.