ImageLabel doesn't display in BillboardGUI - lua

So, this is my problem.
This script works with one image id, but not any others.
I literally have no idea why this is happening.
This is the script >>
function newEntity(imgId, eName)
EntityBase = Instance.new("Part", workspace)
EntityBase.Transparency = 1
EntityBase.Size = Vector3.new(0.9, 0.1, 0.7)
EntityBase.Name = eName
EntityBillboardGui = Instance.new("BillboardGui", EntityBase)
EntityBillboardGui.StudsOffset = Vector3.new(0, 5, 0)
EntityBillboardGui.Size = UDim2.new(0,250,0,250)
EntityBillboardGui.MaxDistance = math.huge
EntityBillboardGui.Adornee = EntityBase
EntityImage = Instance.new("ImageLabel",EntityBillboardGui)
EntityImage.Size = EntityBillboardGui.Size
EntityImage.BackgroundTransparency = 1
EntityImage.Image = imgId
return EntityBase
end
troller = newEntity("rbxthumb://11954446780","imposter")
troller.Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
trololol = Instance.new("Sound", troller)
trololol.SoundId = "http://www.roblox.com/asset/?id=5677788502"
trololol:Play()
wait(2)
troller:Destroy()
game.Players.LocalPlayer.Character.Humanoid.Health = 0
Can anybody help fix it?

For starters I would recommend seperating the parent, like this:
EntityBase = Instance.new("Part") EntityBase.Parent = workspace
SECOND: I would recommend not using a seperate part, just put the billboardGui into the player's head
third you used rbxthumb wrong
rbxthumb://type=[ThumbnailType]&id=[TargetId]&w=[Width]&h=[Height]”
These are the supported sizes and types
example: rbxthumb://type=Avatar&id=123456789&w=720&h=720

Related

Why does all my emission mu of HMM in pyro converge to the same number?

I'm trying to create a Gaussian HMM model in pyro to infer the parameters of a very simple Markov sequence. However, my model fails to infer the parameters and something wired happened during the training process. Using the same sequence, hmmlearn has successfully infer the true parameters.
Full code can be accessed in here:
https://colab.research.google.com/drive/1u_4J-dg9Y1CDLwByJ6FL4oMWMFUVnVNd#scrollTo=ZJ4PzdTUBgJi
My model is modified from the example in here:
https://github.com/pyro-ppl/pyro/blob/dev/examples/hmm.py
I manually created a first order Markov sequence where there are 3 states, the true means are [-10, 0, 10], sigmas are [1,2,1].
Here is my model
def model(observations, num_state):
assert not torch._C._get_tracing_state()
with poutine.mask(mask = True):
p_transition = pyro.sample("p_transition",
dist.Dirichlet((1 / num_state) * torch.ones(num_state, num_state)).to_event(1))
p_init = pyro.sample("p_init",
dist.Dirichlet((1 / num_state) * torch.ones(num_state)))
p_mu = pyro.param(name = "p_mu",
init_tensor = torch.randn(num_state),
constraint = constraints.real)
p_tau = pyro.param(name = "p_tau",
init_tensor = torch.ones(num_state),
constraint = constraints.positive)
current_state = pyro.sample("x_0",
dist.Categorical(p_init),
infer = {"enumerate" : "parallel"})
for t in pyro.markov(range(1, len(observations))):
current_state = pyro.sample("x_{}".format(t),
dist.Categorical(Vindex(p_transition)[current_state, :]),
infer = {"enumerate" : "parallel"})
pyro.sample("y_{}".format(t),
dist.Normal(Vindex(p_mu)[current_state], Vindex(p_tau)[current_state]),
obs = observations[t])
My model is compiled as
device = torch.device("cuda:0")
obs = torch.tensor(obs)
obs = obs.to(device)
torch.set_default_tensor_type("torch.cuda.FloatTensor")
guide = AutoDelta(poutine.block(model, expose_fn = lambda msg : msg["name"].startswith("p_")))
Elbo = Trace_ELBO
elbo = Elbo(max_plate_nesting = 1)
optim = Adam({"lr": 0.001})
svi = SVI(model, guide, optim, elbo)
As the training goes, the ELBO has decreased steadily as shown. However, the three means of the states converges.
I have tried to put the for loop of my model into a pyro.plate and switch pyro.param to pyro.sample and vice versa, but nothing worked for my model.
I have not tried this model, but I think it should be possible to solve the problem by modifying the model in the following way:
def model(observations, num_state):
assert not torch._C._get_tracing_state()
with poutine.mask(mask = True):
p_transition = pyro.sample("p_transition",
dist.Dirichlet((1 / num_state) * torch.ones(num_state, num_state)).to_event(1))
p_init = pyro.sample("p_init",
dist.Dirichlet((1 / num_state) * torch.ones(num_state)))
p_mu = pyro.sample("p_mu",
dist.Normal(torch.zeros(num_state), torch.ones(num_state)).to_event(1))
p_tau = pyro.sample("p_tau",
dist.HalfCauchy(torch.zeros(num_state)).to_event(1))
current_state = pyro.sample("x_0",
dist.Categorical(p_init),
infer = {"enumerate" : "parallel"})
for t in pyro.markov(range(1, len(observations))):
current_state = pyro.sample("x_{}".format(t),
dist.Categorical(Vindex(p_transition)[current_state, :]),
infer = {"enumerate" : "parallel"})
pyro.sample("y_{}".format(t),
dist.Normal(Vindex(p_mu)[current_state], Vindex(p_tau)[current_state]),
obs = observations[t])
The model would then be trained using MCMC:
# MCMC
hmc_kernel = NUTS(model, target_accept_prob = 0.9, max_tree_depth = 7)
mcmc = MCMC(hmc_kernel, num_samples = 1000, warmup_steps = 100, num_chains = 1)
mcmc.run(obs)
The results could then be analysed using:
mcmc.get_samples()

Formating lua code - any tool?

Hi so i recently decoded some game scripts written in lua. But it looks like this
My code looks like this
PlayerTable = { JOGO = 0, BALANCE = 0, BALANCE_P = 0, PROFIT = 0, XXX = 0, XXX_Count = 0, XXX_Player = 0, AH, AL, NUM, LOSETOP = { Times = 0, Money = 0, Name }, WINTOP = { Times = 0, Money = 0, Name } } end if PlayerTable.JOGO == Games.NULL then if 0 < PlayerTable.BALANCE then if table.contains(words.H, Message) then PlayerTable.JOGO = Games.HIGH if HL_ENABLED then Last_Payout = os.time() MinOption = BetOption[PlayerTable.JOGO].Min MaxOption = BetOption[PlayerTable.JOGO].Max PayoutOption = BetOption[PlayerTable.JOGO].Payout else if not table.contains(LimitSay.DISABLED, name) then Self.Say(Disabled_G[PlayerTable.JOGO]) table.insert(LimitSay.DISABLED, name) end PlayerTable.JOGO = Games.NULL end elseif table.contains(words.L, Message) then PlayerTable.JOGO = Games.LOW if HL_ENABLED then
I know there are HTML, JS etc. beautifiers so Is there any tool i can use to beautify this code ?
Or do i need to do it manually ? Its almost 2000 lines of code so i would rather not to do this manually.
You could use ZeroBrane. Basically select the code and then Edit-> Source -> Correct Indentation

<IPython.core.display.HTML object> instead of graph

I am trying to achieve the following Twitter-Visualization project in iPython: http://www.amypeniston.com/web/visualizing-twitter-data
For the last step, my code is:
%pylab
dogs = pd.read_csv(' C:/Users/Alex/mongodb/bin/outputTweets.csv')
dogs['created_at'] = pd.to_datetime(pd.Series(dogs['created_at']))
dogs.set_index('created_at', drop=False, inplace=True)
dogs.index = dogs.index.tz_localize('GMT').tz_convert('EST')
dogs.index = dogs.index - DateOffset(hours = 12)
dogs.index
dogs1m = dogs['created_at'].resample('1t', how='count')
v.core.initialize_notebook()
area = v.Area(dogs1m)
area.colors(brew='Spectral')
area.display()
However, all I get in return is:
IPython.core.display.HTML object

OpenOffice Draw macro to find replace text

I'm looking to find replace text within multiple PDF documents using Draw. Thus far I've managed to open the PDF however
mydoc.createReplaceDescription
appears not to be a valid property / method on a Draw doc. Although oddly this is used in many examples for writer and calc.
Are there any alternatives?
Okay after some playing around with the recorder in the Writer I managed to record a macro that seems to be more general purpose than the createReplaceDiscription I was trying earlier.
It's got a lot of bumf that I guess could be cleaned up but it works...
REM ***** BASIC *****
Sub Main
End Sub
sub WriterFindReplace
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(18) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.StyleFamily"
args1(0).Value = 2
args1(1).Name = "SearchItem.CellType"
args1(1).Value = 0
args1(2).Name = "SearchItem.RowDirection"
args1(2).Value = true
args1(3).Name = "SearchItem.AllTables"
args1(3).Value = false
args1(4).Name = "SearchItem.Backward"
args1(4).Value = false
args1(5).Name = "SearchItem.Pattern"
args1(5).Value = false
args1(6).Name = "SearchItem.Content"
args1(6).Value = false
args1(7).Name = "SearchItem.AsianOptions"
args1(7).Value = false
args1(8).Name = "SearchItem.AlgorithmType"
args1(8).Value = 0
args1(9).Name = "SearchItem.SearchFlags"
args1(9).Value = 65536
args1(10).Name = "SearchItem.SearchString"
args1(10).Value = "<<THE WORD YOUR FINDING>>"
args1(11).Name = "SearchItem.ReplaceString"
args1(11).Value = "<< THE WORD YOUR USING TO REPLACE>>"
args1(12).Name = "SearchItem.Locale"
args1(12).Value = 255
args1(13).Name = "SearchItem.ChangedChars"
args1(13).Value = 2
args1(14).Name = "SearchItem.DeletedChars"
args1(14).Value = 2
args1(15).Name = "SearchItem.InsertedChars"
args1(15).Value = 2
args1(16).Name = "SearchItem.TransliterateFlags"
args1(16).Value = 1280
args1(17).Name = "SearchItem.Command"
args1(17).Value = 3
args1(18).Name = "Quiet"
args1(18).Value = true
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
end sub

Lua - Not displaying text in Corona SDK

In this app I'm creating with Corona SDK, when you win the text "You win" sould appear, but doesn't. I could post all the code, but I don't think the rest would be hepful, so here is only the essencial:
_H = display.contentHeight;
_W = display.contentWidth;
mRand = math.random;
o = 0;
time_remain = 20;
time_up = false;
total_orbs = 45;
total_secs = 20;
ready = false;
local backGround = display.newImage("media/bg.png");
backGround.xScale = 2;
backGround.yScale = 2;
loseMSG = display.newText("You Lose!", _W/2, _H/2, nil, 50)
loseMSG.isVisible = false
winMSG = display.newText("You Win!", _W/2, _H/2, nil, 50)
winMSG.isVisible = false
local countdowntxt = display.newText(time_remain, 0, 0, native.systemFont, 60);
countdowntxt.xScale = .5; countdowntxt.yScale = .5;
countdowntxt:setReferencePoint(display.BottomRightReferencePoint);
countdowntxt.x = _W-20; display.y = _H-20;
countdowntxt:setTextColor(0, 0, 0)
function winLose(condition)
if (condition == "Win") then
bgAlpha = display.newImage("media/bgAlpha.png");
bgAlpha.xScale = 2;
bgAlpha.yScale = 2;
winMSG.isVisible = true -- Here the win text should become visible, but doesn't
elseif (condition == "Fail") then
bgAlpha = display.newImage("media/bgAlpha.png");
bgAlpha.xScale = 2;
bgAlpha.yScale = 2;
loseMSG.isVisible = true
end
end
Any Ideas why?
You need to take a divide and conquer approach.
Does this work?
winMSG = display.newText("You Win!", _W/2, _H/2, nil, 50)
winMSG.isVisible = true <-- note this is set to true
It does?
Does winLose every get called? Put a print statement in it or a break point or whatever you use on your platform to debug.
It does?
What does the variable condition contain? Inspect it/print it out and verify that it is indeed "Win", same case, no spaces, etc. or you can put a print statement in the appropriate branch of that function to make sure it's being hit.
Is that OK?
Does it show up if you remove the bgAlpha code?
So on and so forth.
I don't know Corona, but Googling the docs for newText it's possible you have the parameters wrong (you're not passing a font).
I could post all the code
The less you post the better, because that means you've already gone through the steps shown above to try to isolate the problem. Nine times out of ten, doing that will reveal the problem all by itself.
Why have you given nil for font value?
Atleast pass the default system font
loseMSG = display.newText("You Lose!", _W/2, _H/2, native.systemFont, 50)
winMSG = display.newText("You Win!", _W/2, _H/2, native.systemFont, 50)

Resources