TheGameCreators / GameGuruRepo

The GameGuru Repository For Community Collaboration
http://www.game-guru.com
138 stars 56 forks source link

GGMAX DEVTEST - Error when hurt if MyArmourToughness set higher than 10 #5591

Open Necrym59 opened 2 weeks ago

Necrym59 commented 2 weeks ago

This errore will pop up when hurt in gameplay. gameplayererror

AmenMoses commented 1 week ago
 local user_defined_global_toughness = "MyArmourToughness"
 if user_defined_global_toughness > "" then 
  if _G["g_UserGlobal['"..user_defined_global_toughness.."']"] ~= nil then 
   chanceofarmourdegredation = math.random(1,10 / _G["g_UserGlobal['"..user_defined_global_toughness.."']"])

If g_UserGlobal.MyArmourToughness is 0 then 10/0 will give infinity and result in a NaN error in the parameter to math.random, that would cause the error shown.

I could suggest a fix if I knew what MyArmourToughness is supposed to represent!

Necrym59 commented 1 week ago

Iv discovered it only seems happen if the "MyArmourToughness" value is set to higher than 10, so it wasnt a random thing at all i just happened by accident to set the value higher than 10, perhaps a check not to exceed that number in the global created would suffice.

AmenMoses commented 1 week ago

Ahh, that makes sense as then the second parameter to random will be less than the first, maybe that is what is generating the error.