RollTheDice Object Oriented Edition

Credits to MadkillerMax for the effect code, it is basically the same as his, but with the entire code structure rewritten to use object oriented lua (and less functionality, sorry I’ve not gotten around to adding all the convars). This means, with some basic lua experience, it’s very easy to add or remove effects from it.
It should also work fine with the latest gmod and not throw up any errors, apart from a weird stack overflow thing which rarely happens and I don’t know how to replicate/fix.

Looks like you’re new with scripting! Awesome! here’s some
This looks like a syntax error (sv_dicerolling.lua):
[lua]you wAddCSLuaFile(“autorun/client/cl_dicerolling_effects.lua”)[/lua]

  • I wouldn’t make the dice table global, unless the dice script is a library.

  • The player.GetByUserID function is redundant. Player(number) does it for you :slight_smile:

  • Try to combine if statements so your code doesn’t look like a sideways pyramid:
    [lua]if v.effect.duration~=nil then

      	if CurTime()>v.effect.duration+v.started then

… [/lua]

[lua]if v.effect.duration~=nil and CurTime()>v.effect.duration+v.started then

  • Nice work on the OOP concepts!
  • Nice work on the localization of functions, that’s often hard for new scripters to get right!

Thanks fptje- I’ve mainly been around in the background but this is my first FP release. I’ll use your criticism, I’d wondered why there was no getbyuserid function but now I know better.