I am quite a bit new ad Lua modding, how would you go about limiting something to human players only?
Like lets take the snippet from the get artifact from excavation function
If I'm understanding it correctly I could add something like
Between the end and for lines in
Am I correct in thinking it works like this?
I've been fiddling with the code for a while and though it's obvious when it breaks I'm not really sure if this is working
Like lets take the snippet from the get artifact from excavation function
function ArtifactUtilities.GetAvailableArtifactTypesByCategory(playerType : number, artifactCategoryType : number)
local artifactIDs : table = {};
local player = Players[playerType];
if(player == nil) then
error("player was nil");
end
for artifactInfo : table in GameInfo.Artifacts() do
local categoryID : number = GameInfo.ArtifactCategories[artifactInfo.Category].ID;
if(artifactCategoryType == categoryID) then
if(Game.CanAcquireArtifactType(artifactInfo.ID) == true) then
local numArtifactsWithPreferedReward : number = ArtifactUtilities.GetNumPlayerArtifactsWithPreferedReward(player, artifactInfo.RewardPreference);
local chanceToAcquire : number = 100 / (numArtifactsWithPreferedReward + 1);
local roll : number = Game.Rand(100, "rolling to recieve artifact type that shared prefered reward with existing library type.");
if(roll <= chanceToAcquire) then
table.insert(artifactIDs, artifactInfo.ID);
end
end
end
end
return artifactIDs;
end
If I'm understanding it correctly I could add something like
if (not player:IsHuman()) then
return artifactIDs
end
Between the end and for lines in
And it should prevent an AI controlled player from getting any artifacts or reducing the number available.if(player == nil) then
error("player was nil");
end
for artifactInfo : table in GameInfo.Artifacts() do
Am I correct in thinking it works like this?
I've been fiddling with the code for a while and though it's obvious when it breaks I'm not really sure if this is working