How do I removed the decimal point and the decimals

0 favourites
  • 14 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • hey guys hey guys i really need to solve this problem i have,

    im doing a timemanagement game, that has a bunch of texts and prices and 1 multiple that increases the prices with each purchase so :

    here is my coding of the text

    Set Text to : " $ "&item1.price&newline&"Income : $ " & item1.income&" x "&item1count

    the problem is this :

    when i do a new purchase of the item1 the item1.price its multiplyed by 1.20 so every 3 purchases i get a trail of digits.

    i woldnt mind 1 digit (ex:N.N) but i have prices higher then the item1price (wich is 50) and they are in billions and millions and so on , so the decimals at that point will be insane the problem is i need to take even the . out without showing decimals, i need 103.75 to be shown as 103 and thats it any help?!

    was hoping fisholith can help me or someone that knows this problem

  • Try this: Set Text to : " $ "&round(item1.price)&newline&"Income : $ " & round(item1.income)&" x "&item1count

  • But of course it whould be better to use the round-function on the actuall variable instead.

  • Your awesome solved my issue DetteMan

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Glad i could help

  • Glad i could help

    you did helped me but dident tested till now further, .... i used floor , and works great for numbers under 10,000 but once i do more then 10,000 i tested it with millions and thousands so far , on under 1000 works good even with floor and also with Round, but when i get higher numbers

    as 1mil and . 212313 (exactly 6 decimals so im guessing when im gonna have billions the decimals will be 9

    so above 10,000 with round the decimals are still there, but if i use floor the same number as with round but without a dot between the first high number e.g. 2.123123 mil 25.123123mil someone knows this? i tried with floor(round(number)) but it only applyes as it is only floor

    is there anything as a command to or simple event line that tells to show only what is before the .?

    DetteMan

  • nevermind i found 1 solution its kinda not complete and involves alot of event lines and variables. so hard..... why isnt there a system that does this automatically without having me braking my little brain with math... ufff will add exta 20 event lines to my template i guess.. for 1 text that is gonna show on over 50 items that means will be around 1000 new event lines + an aditional 5 variants to each line of code per item that will be another 10 lines each so will be around 1500 more lines to add god.... hope my math is right oh and dident count the main text that shows the total currency and score that is again ....another 50 times ok must get cracking..... hope there is a simplistic way of doing this cause will add alot of events to the game im doing its not gonna lose frames cause i dont use every tick for displayng text but on command when smth is pressed that saves me more FPS but i guess in idle mode that thing will crack the game .... really need to implement this as a plugin or something.... sorry for calling on Ashley , , Tom but i tried to find a tutorial, plugin something there is none except the This tutorial https://www.scirra.com/tutorials/179/de ... in-a-float that i followed and kinda fixes my problem but i have to write 1500 event lines, so my simple almost eventless game will be not eventless anymore, in order to have this future without decimal points ....... sorry if im not being rational anymore in what im typing i dident sleept for 48 hrs almost ....

  • Did you check the comments? Most of us don't use events, we use

    floor(VARIABLE*100)/100[/code:3awzaat5] which means that:
    
    Input: 31265.3167
    Output: 31265.31
    
    Edit: I'm only not sure if using int or floor is best practice, or if it even matters.
  • Did you check the comments? Most of us don't use events, we use

    floor(VARIABLE*100)/100[/code:3u2xmzo3] which means that:
    
    Input: 31265.3167
    Output: 31265.31
    
    Edit: I'm only not sure if using int or floor is best practice, or if it even matters.
    

    thanks but i managed to get rid of the .decimal just when i use round or floor or int or str i just get the number 31265 now my next issue is when i try to show the text instead of 31265 as 31265/1000*"K" it should add a decimal point after 31 but not showing the 265 anymore because its just a split of the 1000

  • In C# programming we call this little trick "casting". Casting happens when you change the type of variable. If it has a decimal point, the variable is a "float", if it is a whole number then it is an "integer".

    You want to cast the Float into an integer. So there is an expression under system called int() , Anything in the "()" will be cast into an integer.

    Other ways to cast are :str() for String, and float() for float.

    int(random 1.2342,100.234234) will always return a whole number.

  • In C# programming we call this little trick "casting". Casting happens when you change the type of variable. If it has a decimal point, the variable is a "float", if it is a whole number then it is an "integer".

    You want to cast the Float into an integer. So there is an expression under system called int() , Anything in the "()" will be cast into an integer.

    Other ways to cast are :str() for String, and float() for float.

    int(random 1.2342,100.234234) will always return a whole number.

    thanks jojoe i understand now all that because i kinda learned it without even needing to, so... i solved the issue of the decimal my next problem is when i try to make the text write only 2 of the first numbers of the new hole rounded (or inted or floated number

    as an example : i rounded or floated or inted doesnt matter what i use cause all they do is remove decimals all of them tested it like 1000 times so the resulting number will be something like 1200 lets say now in my text i want to show 1.2K that will be a number value / at 1000 because its a a number with a 3 , zeros so i want to get rid of the last 2 zeros and write up 1.2K as in 1.2k money,honey , oil gallons etc.

    i solved it works now just, i used set variable= find(str(money), ".") then i call the set variable2=find(str(ValueLength), ".") then again setvariable3=find(str(ValueLength2), ".") then i set a last variable to float(left(str(money), (ValueLength3 + (3 +1)))) and then i setthetextto-" Account: $ "&ValueWithDecimal&"Bil." returns everything right if the vallue is =>then1bil but <=then999bil cause if i dont add this the c2 engine doesnt reconizes the range and i keep getting the wrong Bilion million, K, kbz, counts my diferent currencys in game.... so is there a plugin or a simple i mean simple code to do this without having to make it with those less then high then conditions? cause because of those i get like 10 lines per item cause i have like 10 different ranges and each event is composed out of 3 events and 2 subevents so i have 50 items that will require 5 events * 10 different ranges that will be 50 * 50 250 event codes only to code 1 part of those items and that isnt even usefull that much, only displays the money needed to upgrade , purchase and the income value of the items thats it and yea for each text type (price,income,stock so scratch that 250 event code lines its actually 3*50 * 50 thats 750 event lines to be coded for info display outside will kill my fps when i have all the items in idle activated, cause now they are triggered when i press a button but when idle mode is enabled then they will count add update every 0.02 and that will be over 700 events called in lerss then a second imagine that resource hog, the game will automatically crash... so its not a permanent solution what i did, i need a better one any ideeas?

  • i think il just make it look good till 1 point and then say hey u playd so far u can play more even if u dont see the numbers later right?!!!

  • I was just trying to help.

    Misquoting me with the Hannah Montana thing is really uncalled for, and will probably hinder other people from attempting to help you.

  • I was just trying to help.

    Misquoting me with the Hannah Montana thing is really uncalled for, and will probably hinder other people from attempting to help you.

    sorry was a bad joke... i know .. it was just frustrating the lines i had to do.. cant seem to find any other work around this problem, unless i do the long and tedious work, sorry again you are a good person im just an idiot most of the times

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)