Created
April 12, 2022 16:09
-
-
Save caillef/489475464f2b4da9a9b02a129d19cc8f to your computer and use it in GitHub Desktop.
[Particubes 0.42] d3d - DIGIT 3D V1 - A simple system to print numbers on your screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Don't forget to add "caillef.empty" in the Config.Items | |
-- Paste the following block at the top of your file, under Config | |
-- DIGIT 3D v1 (d3d) -- caillef 12 Apr. 2022 | |
-- Private | |
local EMPTY = Items.caillef.empty | |
local ADD,MS,FLR = table.insert, MutableShape, math.floor | |
local d3dD = "XXXX XX XX XXXX XX X X X XXXX XXXXX XXXXXX XXXX XXXXX XX XXXX X XXXXX XXX XXXXXXXX XXXX XXXXXXX X X X XXXXX XXXXX XXXXXXXX XXXX XXXX" | |
d3dSD = function(o,v,c,di) for i=1,15 do if d3dD:sub(i+v*15,i+v*15)=="X"then o:AddBlock(c,{0,4-FLR((i-1)/3),(i-1)%3+(di-1)*4})end end end | |
d3dGList = function(n) local d,l=1,{}while FLR(n/(d*10))>=1 do d=d*10 end while d>=1 do ADD(l,FLR(n/d))n,d=n%d,d/10 end return l end | |
-- Public | |
-- d3d_Spawn3DNumber: spawn a mutable shape from a number (n, only positive integers) with a color (c) (example 123 white: local obj = d3d_Spawn3DNumber(123, 229)) | |
d3d_Spawn3DNumber = function(n,c) local o=MS(EMPTY)o:GetBlock({0,0,0}):Remove()for i,v in ipairs(d3dGList(n))do d3dSD(o,v,c,i)end return o end | |
-- Use this part in your code to display a number on your screen (line 20 to 25) | |
Client.OnStart = function() | |
World:AddChild(Player) | |
local WHITE = 229 | |
local hp = 37 | |
local obj = d3d_Spawn3DNumber(hp, WHITE) | |
obj.LocalPosition = { 0, 0, 10 } -- Place in front of the camera | |
-- Advanced rotation to face the camera, lower /9 and /15 to increase the rotation of the number on the border of the screen | |
obj.LocalRotation = { 0, 1.57 + obj.LocalPosition[1]/9, -obj.LocalPosition[2]/15 } -- Face the camera and rotate if on the edge of the screen | |
obj.Scale = 0.15 -- Scale of the text | |
Camera:AddChild(obj) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment