generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Gold value text thingamabob

Previous Thread :: Next Thread 
Zarkonan_Zenheart is not online. Zarkonan_Zenheart
Joined: 29 May 2012
Total Posts: 610
04 Feb 2017 03:36 PM
so if I have 100 gold
then I have 279 gold
I want my script to go
difference = 179
then essentially lerp between them. Any ideas?
Something like
100
200
210
220
.. etc
270
271
272
etc.

Not sure how to go about it though. Also what if I have to add or remove a digit EG from 100 to 10 or from 999 to 1000?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
04 Feb 2017 03:37 PM
What? Can you explain some more


Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
04 Feb 2017 03:38 PM
okay, how many steps should the lerp have? (how many loops before the goal is reached?)


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
04 Feb 2017 03:41 PM
local gold = 100

function AddGold(add)
local dir
goal = goal+add
if goal>gold then dir = 1 else dir = 0 end
if goal < 0 then goal = 0 end
for i = gold,goal,dir
gold = i
print(gold)
wait()
end
end

AddGold(5)
>101
>102
>103
>104
>105



Report Abuse
Zarkonan_Zenheart is not online. Zarkonan_Zenheart
Joined: 29 May 2012
Total Posts: 610
04 Feb 2017 03:49 PM
That'll do it in a linear fashion if I read it correctly.

I don't want it to go from 100 - 101 - 102 - ... 199 - 200, etc

100 - 200 - 210 - 220 - 230 - 240 - 250

basically, for the hundred, ten, one, etc I want it to go between those.
Report Abuse
Zarkonan_Zenheart is not online. Zarkonan_Zenheart
Joined: 29 May 2012
Total Posts: 610
04 Feb 2017 03:54 PM
I suppose I can try to formulate that better.

If I have the numbers 200 and 579

there are 3 differences:
300, 70, 9


I want my text to show these increments. For example,

200 --> 300 --> 400 --> 500
then
500 --> 510 --> 520 --> 530 (repeat until 570)
then
570 --> 571 --> 572 --> 573 (repeat until 579)
Report Abuse
Zarkonan_Zenheart is not online. Zarkonan_Zenheart
Joined: 29 May 2012
Total Posts: 610
04 Feb 2017 05:15 PM
bump
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
04 Feb 2017 05:45 PM
local v1 = 200
local v2 = 579

local total = 0

local dif = v2 - v1

local hundreds = math.floor(dif/100)
local tens = math.floor((dif-hundreds)/10)
local ones = dif - (hundreds + tens)

for i=1, hundreds, 100 do
total = total + i
print(total)
wait()
end
for i=1, tens, 10 do
total = total + i
print(total)
wait()
end
for i=1, ones do
total = total + i
print(total)
wait()
end


Report Abuse
Zarkonan_Zenheart is not online. Zarkonan_Zenheart
Joined: 29 May 2012
Total Posts: 610
04 Feb 2017 06:34 PM
What if the difference is greater than 999?
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
04 Feb 2017 07:04 PM
--whole numbers only local ### = 1573 ### = ############# local vals = ## local prev = 0 local total = 0 for ####### 1, -1 do local s = i-1 total = total + (vals[i+1] ## nil and vals[i+1] or 0) vals[i] = ############################# - total end for i=1, #vals do print(vals[i]) end
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
04 Feb 2017 07:05 PM
local dif = 1573

dif = tostring(dif)

local vals = {}

local prev = 0

local total = 0

for i=#dif, 1, -1 do
local s = i-1
total = total + (vals[i+1] ~= nil and vals[i+1] or 0)
vals[i] = math.floor(dif/(10^s))*(10^s) - total
end

for i=1, #vals do
print(vals[i])
end


Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
04 Feb 2017 07:06 PM
shortened (had one unused variable)

local dif = 1573
dif = tostring(dif)
local vals = {}

local total = 0

for i=#dif, 1, -1 do
local s = i-1
total = total + (vals[i+1] ~= nil and vals[i+1] or 0)
vals[i] = math.floor(dif/(10^s))*(10^s) - total
end

for i=1, #vals do
print(vals[i])
end


Report Abuse
Zarkonan_Zenheart is not online. Zarkonan_Zenheart
Joined: 29 May 2012
Total Posts: 610
05 Feb 2017 07:03 AM
Thanks :^) I don't understand it but I can see it works so yay! :p
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image