ULX

Author Topic: Always round numbers  (Read 4510 times)

0 Members and 2 Guests are viewing this topic.

Offline Reese

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Always round numbers
« on: May 23, 2016, 10:19:53 AM »
Hello guys,
I would like to know if ULib.cmds.NumArg could be 0.5 (like not rounded)
Here's the code :

cmd = ULib.cmds.TranslateCommand( "ugm slap", ULib.slap )
cmd:addParam{ type=ULib.cmds.PlayerArg, target="*", default="^", ULib.cmds.optional }
cmd:addParam{ type=ULib.cmds.NumArg, min=0, default=0, ULib.cmds.optional }

It is always 0 for 0.4 and always 1 for 0.5 !
Thank you guys

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Always round numbers
« Reply #1 on: May 23, 2016, 10:26:50 AM »
From the docs, it doesn't look like it usually rounds. Maybe this is a bug?
Can you try your command with 1.5? Or anything >1?
Maybe also try .5 instead of 0.5? I would doubt that's the issue, but I don't know.
bw81@ulysses-forums ~ % whoami
Homepage

Offline Reese

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Always round numbers
« Reply #2 on: May 23, 2016, 10:51:35 AM »
Still rounds up man

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Always round numbers
« Reply #3 on: May 23, 2016, 01:12:24 PM »
I will need to double check, but it should not be rounding. Are you rounding in the destination function?
Experiencing God's grace one day at a time.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Always round numbers
« Reply #4 on: May 23, 2016, 01:16:12 PM »
Wait, I just noticed. OP, that code doesn't look like code you'd be using to write a command of your own. If it is, that doesn't look correct.
Please post the entirety of the code you're using to test using [code=lua][/code] to surround it.

Also, Meg, it doesn't seem to unless it's cut off before parsing: https://github.com/TeamUlysses/ulib/blob/master/lua/ulib/shared/commands.lua#L254
« Last Edit: May 23, 2016, 01:21:15 PM by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

Offline Reese

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Always round numbers
« Reply #5 on: May 27, 2016, 03:13:00 PM »
I just took an exemple code but I did the same kind of code

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Always round numbers
« Reply #6 on: May 27, 2016, 03:31:11 PM »
I just took an exemple code but I did the same kind of code
Could you post your code as I suggested? It would really help us in figuring out what your issue is. Thanks.
bw81@ulysses-forums ~ % whoami
Homepage

Offline Reese

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Always round numbers
« Reply #7 on: May 28, 2016, 01:33:07 AM »
Thank you
« Last Edit: May 28, 2016, 02:16:25 PM by Reese »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Always round numbers
« Reply #8 on: May 28, 2016, 09:20:56 AM »
Have you tried printing the scale variable to verify that it is being rounded?
Experiencing God's grace one day at a time.

Offline Reese

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Always round numbers
« Reply #9 on: May 28, 2016, 09:37:36 AM »
what do you mean ? I may be not understnading everything

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given