EgoMooseOldProjects / Rbx_CustomFont

A custom font management system for Roblox
MIT License
21 stars 17 forks source link

Sometimes text does not change? #4

Closed Jjx003 closed 8 years ago

Jjx003 commented 8 years ago

This might be an issue that I only have though.

local fonts = require(replicated:WaitForChild('Rbx_CustomFont')) ... local theme_text_pseudo = fonts.Replace("Helsinki_shadow", theme:WaitForChild('TextLabel')); local theme_text = theme_text_pseudo()---at this point it properly displays the new font ... for i = 1,string.len(to) do wait(.1) theme_text.Text = string.sub(to,1,i) --does not change the text :/ end Edit: It also crashes the game sometimes

EgoMoose commented 8 years ago

I'll look into it.

I just updated a lot of the code recently (past weekend) so this may be a bug I missed. Will post back after I've tested it a bit.

EgoMoose commented 8 years ago

Yep, I'm going to guess this is a problem on your end. I'd love to help you solve it, but as far as the module goes it seems to be working fine for me:

example

This is the code I used:

local fonts = require(game.Workspace:WaitForChild('Rbx_CustomFont'))

local theme_text_pseudo = fonts.Replace("Helsinki_shadow", script.Parent:WaitForChild('TextLabel'));
local theme_text = theme_text_pseudo();

while true do
    theme_text.Text = "banana!";
    wait(5);

    local to = "orange!";
    for i = 1,string.len(to) do
        wait(.1);
        theme_text.Text = string.sub(to, 1, i);
    end;
    wait(2);
end;

It's basically the same so that shouldn't be a problem.

Jjx003 commented 8 years ago

Oh yeah, it's my own problem thing. My local script resets itself (disable/re-enable to keep running even after errors), so sometimes the font stuff overlaps; I thought that clearing the children of the textlabel would remove it, but it just makes the new font appear blank some reason (the image labels and everything are there, even in correct positions, and visible=true, but its not showing up :/). Maybe the ZIndex is too low, brb checking that

Jjx003 commented 8 years ago

Okay I don't know anymore :/ Can you take a look at this model? http://www.roblox.com/Font-Seems-To-Be-Transparent-item?id=323970977 It's the frame of my GUI For some reason all the imagelabels are there and set to visible, but I can't see any of them?

Gskartwii commented 8 years ago

Sounds like you used Replace() on a TextLabel that has TextTransparency=2, which is something the custom font model does to keep track of changes.
Also, about the crashing code, what else do you have in the script?

EgoMoose commented 8 years ago

Yep, it looks as though you're trying to use the replace function on an object that already has its text set completely transparent.

I manually reverted up the model you posted and then simply replaced the text in its default form: example

Also be aware that you were using text scaled on the text frame that was larger (at least for me) than the screen. As a result in the example above I fixed the text to size 24. I'd recommend re-sizing the frames for your actual game. -- This has nothing to do with the module, it's just general GUI tips

Jjx003 commented 8 years ago

Oh watttt.. I have no idea how my texttransparency was set to 2 ._. No where in my code do I have that, wut And I'm uncertain of what you meant with your gui tip? My frame was too large? huh I can show you all the code, although there's a lot to it (lots of other unrelated stuff)

Jjx003 commented 8 years ago

Oh yeah, thanks for all the help provided so far :D

Jjx003 commented 8 years ago

Okay I fixed the transparency issue and the font works fine! When I reset the localscript, it causes a bunch of weird bugs, so yeah... I decided to remove the disable/re-enable. Thanks guys! Is there a better way to contact you guys if I just need help on scripting in general?

EgoMoose commented 8 years ago

All I meant was that you need to adjust how you size and position your scaled-based size frames. This is how it shows on my screen: desktop 27-11-2015 4-30-58 pm-654

You should use something like this (for lack of a better example):

function posFrom(frame, pos, x, y)
    frame.Position = UDim2.new(
        pos.X.Scale - frame.Size.X.Scale * x,
        pos.X.Offset - frame.Size.X.Offset * x,
        pos.Y.Scale - frame.Size.Y.Scale * y,
        pos.Y.Offset - frame.Size.Y.Offset * y
    );
end;

posFrom(frame, UDim2.new(1, -50, 1, -25), 1, 1);

As for contacting me you can pm me. However, if you need general scripting help go to the scripters sub-section of the forums. I'm not a huge fan of that place because I consistently get called a "dumbass" in some shape or form, but hey it's part of the experience and we all gotta learn to go through it to get better.

Jjx003 commented 8 years ago

Oh, I think I have something similar implemented every frame:

theme.Position = U2(1,-theme.AbsoluteSize.X-1,1,-theme.AbsoluteSize.Y-1)

How do the "x" and "y" args affect that function?

EgoMoose commented 8 years ago

They're percentages of where the frame will be moved from and on which axis. Here are some examples:

posFrom(frame, UDim2.new(0.5, 0, 0.5, 0), 0, 0); --  Top left corner; default
posFrom(frame, UDim2.new(0.5, 0, 0.5, 0), 0, 1); --  bottom left corner
posFrom(frame, UDim2.new(0.5, 0, 0.5, 0), 1, 0); --  Top right corner
posFrom(frame, UDim2.new(0.5, 0, 0.5, 0), 1, 1); --  bottom right corner
posFrom(frame, UDim2.new(0.5, 0, 0.5, 0), 0.5, 0.5); --  centre of frame

The method you posted seems inefficient as your computer has to do a calculation every frame. By using the method I'm suggesting scripts don't have to do anything because the combination of scale and offset will do it automatically.