This stays on whatever random chance it chooses instead of actually being random. if u…
Private research annotation
Sign in to add a private research label or note.
- User
This stays on whatever random chance it chooses instead of actually being random.
if u then if math.random() <= 0.4 then for _, n in pairs({ "ray_arcane" }) do local t = T(n) if t and t.bullet then t.bullet.mod = "mod_ray_arcane_blast" end end elseif math.random() >= 0.4 then for _, n in pairs({ "ray_arcane" }) do local t = T(n) if t and t.bullet then t.bullet.mod = "mod_ray_arcane" end end end end
- Assistant
The issue with your code lies in the way you are using
math.random()to determine which block of code to execute. You are callingmath.random()twice, which means you are generating two separate random numbers. This can lead to unexpected behavior because each call tomath.random()generates an independent random value, so the conditions can be inconsistent.In your
if-elseifstructure, the first condition checks ifmath.random() <= 0.4and the second condition checks ifmath.random() >= 0.4. To resolve this issue, you should generate the random number once and store it in a variable, then use this variable in both conditions. Here’s how you can modify your code:lua - User
I don't think this is even functioning for some reason. Can you try to make the code simpler?
- Assistant
Certainly! I can give you a simplified version of the code. By streamlining the logic, we can ensure that it functions correctly. Here is a simpler approach:
luaif u then local rand = math.random() local modName -- Decide the mod name based on the random number if rand <= 0.4 then modName = "mod_ray_arcane_blast" else modName = "mod_ray_arcane" end -- Apply the chosen mod to the specified bullets for _, n in pairs({"ray_arcane"}) do local t = T(n) if t and t.bullet then t.bullet.mod = modName end end endExplanation: