This is coded in AMS, so you need to know lua.