Inspired by Hopscript: Hopscotch Text Language (Concept)
A more detailed OP will be written in the future
Examples
those are frequently updated, unlike any code in the conversation in this topic
feel free to ask any question if you do not understand those two code snippets
the following code snippet is based on this project:
When game_starts:
background.color = rgb(0, 0, 0)
save_input = noformat_number, "type a big number"
noformat_number = round(noformat_number)
if (noformat_number MATCHES /e\+/):
set_text =
"the number you provided is too big; hopscotch is reading it as scientific notation now (7e+12 for example).",
hsb(28,100,100)
else:
# "section one: adding comma to long numbers"
custom_ability (
"Format Number",
recursion = floor((length(round(noformat_number)) - 1) / 3),
noformat_number = round(noformat_number)
):
if (recursion == 0):
self.Return = noformat_number
else:
custom_ability this:
recursion - 1,
noformat_number
self.Return = join(
join(
Return[0, length(Return) - (recursion * 3 + (recursion - 1))],
","[noformat_number[0] == "-"]
),
Return[length(Return) - (recursion * 3 + (recursion - 1)), length(Return)]
)
formatted_long_number = self.Return
# "section two: cuttin long numbers down followed by an abbreviation"
power = floor((length(noformat_number) - (1 + noformat_number[0] == "-")) / 3)
number_w_abbr = join(
round((noformat_number * 100) / (10 ^ (3 * power))) / 100,
"KMBtqQsSondUDT"[power - 1]
)
set_text =
join(join(formatted_long_number, "\n or "), number_w_abbr),
rgb(255, 255, 255)
this custom rule can be found in this project:
custom_rule:
name: "Movement Spring"
args: "Stiffness", "Mass", "Damping"
values: 0.4, 7.5, 1.5
content:
SpeedX = 0
SpeedY = 0
_cstm.FPS_Calculator
When (o.Spring_Able == 1):
# "Calculate the distance between the target point and the object itself"
DistanceX = self.x_position - self.TargetX
DistanceY = self.y_position - self.TargetY
# "Calculate the acceleration to apply on the current speed"
AccelerationX = (-1 * Stiffness * DistanceX + -1 * Damping * SpeedX) / Mass
AccelerationY = (-1 * Stiffness * DistanceY + -1 * Damping * SpeedY) / Mass
# "Add up the current speed to the acceleration"
SpeedX += AccelerationX * game.Project_Speed
SpeedY += AccelerationY * game.Project_Speed
# "Apply the new position of the object"
set_position = ...
self.x_position + SpeedX * game.Project_Speed,
self.y_position + SpeedY * game.Project_Speed
_cstm:
custom_rule:
name: "FPS_Calculator"
content:
LastT = Time
When game_is_playing:
# "Code Provided by @Spy_Guy_96"
game.FPS = min(1000 / (Time - LastT), 60)
game.Project_Speed = min(max(60 / game.FPS, 1), 3)
LastT = Time