Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Help pls

ngame
Registered User
Quote
2020-12-14 19:36:38

var 11 = [Math.floor(Math.random()*100)]
var 22 = [Math.floor(Math.random()*100)]
var 33 = [Math.floor(Math.random()*100)]
var 44 = [Math.floor(Math.random()*100)]
I have a variable "11" and I want to remove its fractional value. For example, for the variable 11 to be equal to 3.14 instead of 3.14.


Robo
Guest
Quote
2020-12-15 01:10:24

Your question isnt clear - this statement doesnt make sense: "For example, for the variable 11 to be equal to 3.14 instead of 3.14."

I would not use brackets around math calculations - incorrect syntax.

use something like this if you want from 0 - 99.
var number = Math.floor(Math.random()*100);

If you want 1- 100 just add 1 to the end result.


ngame
Registered User
Quote
2020-12-15 15:15:36

Robo wrote:
Your question isnt clear - this statement doesnt make sense: "For example, for the variable 11 to be equal to 3.14 instead of 3.14."

I would not use brackets around math calculations - incorrect syntax.

use something like this if you want from 0 - 99.
var number = Math.floor(Math.random()*100);

If you want 1- 100 just add 1 to the end result.

I need the numbers after the dot to be removed. for example, if the variable x is equal to 3.004, then after executing the command, it will simply be equal to 3


Robo
Guest
Quote
2020-12-17 06:23:40

easy - use

Math.round(put variable in here);


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "I?ternational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact