How to get SubtractAsync to fully slice off piece of the part - roblox

I'm trying to slice a part of this part, so that it matches the bottom part, and the method I'm trying is SubtractAsync.
When I do it however, the part gets sliced, but not so that the remaining part gets removed. Here's what I mean:
How do I edit my code to slice off the piece of the part?
My code:
local Brick = workspace.Brick
local Stack = Brick:Clone()
local TS = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, math.huge, true)
Stack.Position = Vector3.new(Brick.Position.X, Brick.Position.Y + Brick.Size.Y, Brick.Position.Z - 55)
local tween = TS:Create(Stack, tweenInfo, {Position = Vector3.new(Stack.Position.X, Stack.Position.Y, Stack.Position.Z + (55 * 2))})
Stack.Parent = workspace
tween:Play()
game.ReplicatedStorage.PlaceDown.OnServerEvent:Connect(function()
tween:Pause()
local PartA = Instance.new("Part")
local PartB = Instance.new("Part")
PartA.Transparency = 1
PartB.Transparency = 1
PartA.Parent = workspace
PartB.Parent = workspace
PartA.Orientation = Vector3.new(-90, 0, 0)
PartB.Orientation = Vector3.new(-90, 0, 0)
PartA.Size = Vector3.new(15, 0.051, 15)
PartB.Size = Vector3.new(15, 0.051, 15)
PartA.Position = Vector3.new(Brick.Position.X, Brick.Position.Y + 2.5, Brick.Position.Z - (Brick.Size.Z/2))
PartB.Position = Vector3.new(Brick.Position.X, Brick.Position.Y + 2.5, Brick.Position.Z + (Brick.Size.Z/2))
PartA.Anchored = true
PartB.Anchored = true
local SlicedStack = Stack:SubtractAsync({PartA, PartB})
SlicedStack.Position = Stack.Position
SlicedStack.Parent = workspace
Stack:Destroy()
PartA:Destroy()
PartB:Destroy()
end)

Related

Pillow new RGB screen not generating

I built a test program using import PIL.imagedraw etc etc and was able to use the draw.line command to draw various lines. All good. In a new program I added new code which built a matrix list of x/y/z points (and cosine/sine expressions with math.lib), an input command for some variables, and then the draw.line command as in the previous code, but now the RGB window is not showing at all. The program doesn’t end and gives no errors. (Pythonista on iOS iPad Pro)
The test program, a noob attempt at perspective projection (which works as expected):
import PIL.ImageDraw as ImageDraw,PIL.Image as Image, PIL.ImageShow as ImageShow
im = Image.new("RGB", (1200,800))
draw = ImageDraw.Draw(im)
GL_z = 0
PP_y = 0
SP_x = 300
SP_y = -400
SP_z = 600
org=600
answer=0
width=100
depth=500
height=500
SP_z1=SP_z+height
px_1 = org
py_1 = org
px_2 = org+90
py_2 = 50 + org
px_3 = -160 + org
py_3 = 550 + org
px_4 = -250 + org
py_4 = 500+org
while answer==0:
SP_z1=SP_z-height
px1_1 = ((px_1 - SP_x)/(py_1 - SP_y))*(py_1 - PP_y)
px1_2 = ((px_2 - SP_x)/(py_2 - SP_y))*(py_2 - PP_y)
px1_3 = ((px_3 - SP_x)/(py_3 - SP_y))*(py_3 - PP_y)
px1_4 = ((px_4 - SP_x)/(py_4 - SP_y))*(py_4 - PP_y)
py1_1 = ((SP_z-GL_z)/(py_1-SP_y))*(py_1-PP_y)
py1_2 = ((SP_z-GL_z)/(py_2-SP_y))*(py_2-PP_y)
py1_3 = ((SP_z-GL_z)/(py_3-SP_y))*(py_3-PP_y)
py1_4 = ((SP_z-GL_z)/(py_4-SP_y))*(py_4-PP_y)
py1_5 = ((SP_z1-GL_z)/(py_1-SP_y))*(py_1-PP_y)
py1_6 = ((SP_z1-GL_z)/(py_2-SP_y))*(py_2-PP_y)
py1_7 = ((SP_z1-GL_z)/(py_3-SP_y))*(py_3-PP_y)
py1_8 = ((SP_z1-GL_z)/(py_4-SP_y))*(py_4-PP_y)
px1_1old = px1_1
px1_2old = px1_2
px1_3old = px1_3
px1_4old = px1_4
py1_1old = py1_1
py1_2old = py1_2
py1_3old = py1_3
py1_4old = py1_4
py1_5old = py1_5
py1_6old = py1_6
py1_7old = py1_7
py1_8old = py1_8
SP_yold = SP_y
draw.line((0,SP_y,1200,SP_y),fill=(255,255,255))
draw.line((px1_1,py1_1,px1_2,py1_2),fill=(0,0,255))
draw.line((px1_2,py1_2,px1_3,py1_3),fill=(0,255,0))
draw.line((px1_3,py1_3,px1_4,py1_4),fill=(255,255,255))
draw.line((px1_4,py1_4,px1_1,py1_1),fill=(100,255,0))
draw.line((px1_1,py1_1,px1_1,py1_5),fill=(255,255,255))
draw.line((px1_1,py1_5,px1_2,py1_6),fill=(255,255,255))
draw.line((px1_2,py1_6,px1_3,py1_7),fill=(255,255,255))
draw.line((px1_3,py1_7,px1_4,py1_8),fill=(255,255,255))
draw.line((px1_4,py1_8,px1_4,py1_4),fill=(150,150,0))
#draw.line((px1_1,py1_1,px1_2,py1_2),fill=(255,255,255))
#draw.line((px1_2,py1_2,px1_3,py1_3),fill=(255,255,255))
#draw.line((px1_3,py1_3,px1_4,py1_4),fill=(255,255,255))
#draw.line((px1_4,py1_4,px1_1,py1_1),fill=(255,255,255))
im.show()
move = input("''")
if move == "w":
SP_y += 50
if move == "s":
SP_x -= 50
if move == "z":
SP_y -= 50
if move == "a":
SP_x += 50
if move == "-":
SP_z -= 50
if move == "=":
SP_z += 50
draw.line((0,SP_yold,1200,SP_yold),fill=(0,0,0))
draw.line((px1_1old,py1_1old,px1_2old,py1_2old),fill=(0,0,0))
draw.line((px1_2old,py1_2old,px1_3old,py1_3old),fill=(0,0,0))
draw.line((px1_3old,py1_3old,px1_4old,py1_4old),fill=(0,0,0))
draw.line((px1_4old,py1_4old,px1_1old,py1_1old),fill=(0,0,0))
draw.line((px1_1old,py1_1old,px1_1old,py1_5old),fill=(0,0,0))
draw.line((px1_1old,py1_5old,px1_2old,py1_6old),fill=(0,0,0))
draw.line((px1_2old,py1_6old,px1_3old,py1_7old),fill=(0,0,0))
draw.line((px1_3old,py1_7old,px1_4old,py1_8old),fill=(0,0,0))
draw.line((px1_4old,py1_8old,px1_4old,py1_4old),fill=(0,0,0))
And this is the code that refuses to draw anything:
import math
import decimal
decimal.getcontext().prec = 6
import PIL.ImageDraw as ImageDraw,PIL.Image as Image, PIL.ImageShow as ImageShow
im = Image.new("RGB", (1200,800))
draw = ImageDraw.Draw(im)
PP_y = 0
SP_x = 300
SP_y = -400
SP_z = 600
org=600
answer=0
dims=[]
for i in range (1, 5):
dim = int(input())
dims.append(dim)
dims[3] = (dims[3]*math.pi)/180
obj1 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24]]
y1 = [0,0,0,0,0,0,0,0]
y2 = [0,0,0,0,0,0,0,0]
y3 = [0,0,0,0,0,0,0,0]
x1 = [0,0,0,0,0,0,0,0]
z1 = [0,0,0,0,0,0,0,0]
ymod = [0,0,0,0,0,0,0,0]
xmod = [0,0,0,0,0,0,0,0]
obj1[0]=[0,0,0]
obj1[1]=[dims[0] * math.cos(dims[3]),dims[0] * math.sin(dims[3]),0]
obj1[2]=[obj1[1][0] - (dims[1] * math.sin(dims[3])),obj1[1][1] + (dims[1] * math.cos(dims[3])),0]
obj1[3]=[dims[1] * math.sin(dims[3]),dims[1] * math.cos(dims[3]),0]
obj1[4]=[0,0,dims[2]]
obj1[5]=[dims[0] * math.cos(dims[3]),dims[0] * math.sin(dims[3]),dims[2]]
obj1[6]=[obj1[1][0] - (dims[1] * math.sin(dims[3])),obj1[1][1] + (dims[1] * math.cos(dims[3])),dims[2]]
obj1[7]=[dims[1] * math.sin(dims[3]),dims[1] * math.cos(dims[3]),dims[2]]
for i in range (0,7):
y1[i]=obj1[i][1]-PP_y
y2[i]=obj1[i][1]-SP_y
y3[i]=y1[i]/y2[i]
x1[i]=obj1[i][0]-SP_y
z1[i]=obj1[i][2]-SP_z
obj1[i][0]=obj1[i][0] - (x1[i] * y3[i])
obj1[i][2]=obj1[i][2] - (z1[i] * y3[i])
#print(dims)
#print(obj1)
#print(y1,y2,y3,x1,z1,xmod,ymod)
while (True):
draw.line((obj1[0][0],obj1[0][2],obj1[1][0],obj1[1][2]),fill=(255,255,255))
Ah found the error, left out im.show(). Pretty fundamental…
reference
https://pillow.readthedocs.io/en/stable/reference/Image.html

Condition only run ONCE (instead on all bars)

On checking for condition gap(high-low) > 0.1%(which is met multiple times), the label only gets
rendered ONCE (instead of on relevant bars within 25 bar lookback).
Plz provide a solution.
CODE :
Historical Bars
//#version=5
indicator("PriceMomemtum",overlay = true,max_bars_back = 25)
gap = (math.abs(high - low)/low ) * 100
//var gap = (math.abs(high - low)/low ) * 100
if gap > 0.1
var lbl = label.new(x = bar_index,y = na , text = na ,text_font_family = font.family_default ,xloc = xloc.bar_index,yloc =yloc.abovebar,style = label.style_arrowdown ,textcolor = color.white,size =size.small,textalign = text.align_left,tooltip = na)
label.set_text(lbl,str.tostring(gap,"#.00")+"%")
label.set_xy(lbl,bar_index,high )
Realtime Bars
//#version=5
indicator("PriceMomemtum",overlay = true,max_bars_back = 25)
if barstate.isrealtime
gap = (math.abs(high - low)/low ) * 100
//var gap = (math.abs(high - low)/low ) * 100
if gap > 0.1
var lbl = label.new(x = bar_index,y = na , text = na ,text_font_family = font.family_default ,xloc = xloc.bar_index,yloc =yloc.abovebar,style = label.style_arrowdown ,textcolor = color.white,size =size.small,textalign = text.align_left,tooltip = na)
label.set_text(lbl,str.tostring(gap,"#.00")+"%")
label.set_xy(lbl,bar_index,high )
alert(str.tostring(time(syminfo.timezone)) + "(PriceMomentum)", alert.freq_once_per_bar)
Have you tried defining "lbl" variable without "var"?
result

Remove Marks on Charts

I have a problem with my code, I want to evaluate a Report with Charts.
What my Macro currently does is, Create for every single column a Row for a nominal, upper, lower tolerance. Then It creates with this values a chart.
After this it starts with the Sorting and then it removes the Marker Points, but here my Problems already start.
I would like to create the charts later for example on pos A100 or A50 or something.
Then the Marker Points, I would like to keep the Points on the result line but not on the 3 created, but I found no way 
Remove the Markers, but it removes all, i would really like to remove them only for
FullSeriesCollection(2).format.Line
FullSeriesCollection(3).format.Line
FullSeriesCollection(4).format.Line
Would be nice if someone would have an idea.. :)
Thanks in advance,
' Unload UFormTools
UFormTools.Hide
Application.ScreenUpdating = False
Sheets("Original Values").Select
Dim lngC As Long, lngR As Long
Dim i As Long
Dim c As Byte
Application.ScreenUpdating = False
With ActiveSheet
lngC = (.Cells(17, 4).End(xlToRight).Column - 4) * 4
For i = 4 To lngC Step 4
lngR = .Cells(.Rows.Count, i).End(xlUp).Row
For c = 1 To 3
.Columns(i + c).EntireColumn.Insert
Next c
.Cells(17, i).AutoFill Destination:=.Range(.Cells(17, i), .Cells(17, i + 3)), Type:=xlFillCopy
.Range(.Cells(28, i + 1), .Cells(lngR, i + 1)).Value = .Cells(18, i).Value
.Range(.Cells(28, i + 2), .Cells(lngR, i + 2)).Value = .Cells(18, i).Value + .Cells(19, i).Value
.Range(.Cells(28, i + 3), .Cells(lngR, i + 3)).Value = .Cells(18, i).Value + .Cells(20, i).Value
.Shapes.AddChart2(332, xlLineMarkers).Select
With ActiveChart
.SetSourceData Source:=Union(ActiveSheet.Range(ActiveSheet.Cells(17, i), ActiveSheet.Cells(17, i + 3)), _
ActiveSheet.Range(ActiveSheet.Cells(28, i), ActiveSheet.Cells(lngR, i + 3)))
' .Legend.Delete
.ChartTitle.Text = ActiveSheet.Cells(17, i).Value
.ChartTitle.format.TextFrame2.TextRange.Characters.Text = ActiveSheet.Cells(17, i).Value
With .ChartTitle.format.TextFrame2.TextRange.Characters(1, Len(ActiveSheet.Cells(17, i).Value)).ParagraphFormat
.TextDirection = msoTextDirectionLeftToRight
.Alignment = msoAlignCenter
End With
With .FullSeriesCollection(3).format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
End With
With .FullSeriesCollection(4).format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
End With
With .FullSeriesCollection(2).format.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
.Transparency = 0
.Visible = msoTrue
.DashStyle = msoLineDash
.Weight = 1.5
End With
With .FullSeriesCollection(1).format.Line
.Visible = msoTrue
.Weight = 3
End With
.FullSeriesCollection(1).Smooth = True
.Axes(xlValue).MinimumScaleIsAuto = True
.Axes(xlValue).MinimumScaleIsAuto = True
End With
Next i
End With
' Sort and Arrange Charts, but another Position to Start would be nice.. (for example A100)
Dim MyWidth As Single, MyHeight As Single
Dim NumWide As Long
Dim iChtIx As Long, iChtCt As Long
MyWidth = 300
MyHeight = 200
NumWide = 4
iChtCt = ActiveSheet.ChartObjects.Count
For iChtIx = 1 To iChtCt
With ActiveSheet.ChartObjects(iChtIx)
.Width = MyWidth
.Height = MyHeight
.Left = ((iChtIx - 1) Mod NumWide) * MyWidth
.Top = Int((iChtIx - 1) / NumWide) * MyHeight
End With
Next
' Remove the Markers, but it removes all, i would really like to remove them only for
' FullSeriesCollection(2).format.Line
' FullSeriesCollection(3).format.Line
' FullSeriesCollection(4).format.Line
Dim cht As ChartObject
Dim srs As Series
Dim MarkerCount As Long
For Each cht In ActiveSheet.ChartObjects
cht.Activate
For Each srs In ActiveChart.SeriesCollection
If srs.MarkerStyle <> xlMarkerStyleNone Then
srs.MarkerStyle = xlMarkerStyleNone
MarkerCount = MarkerCount + 1
End If
Next srs
Next cht
Range("A1").Select
Application.ScreenUpdating = True

whenever I try to run the code with Lua I get the error :Error Map.lua:107: attempt to call method 'makepyramid' (a nil value)

Map = Class{}
TILE_BRICK = 1
TILE_EMPTY = -1
POLE_TOP = 8
POLE_MIDDLE = 12
POLE_BOTTOM = 16
FLAG_TILE = 13
local SCROLL_SPEED = 62
function Map:init()
self.spritesheet = love.graphics.newImage('graphics/spritesheet.png')
self.sprites = generateQuads(self.spritesheet, 16, 16)
self.music = love.audio.newSource('sounds/music.wav', 'static')
self.tileWidth = 16
self.tileHeight = 16
self.mapWidth = 30
self.mapHeight = 28
self.tiles = {}
self.flag = self.mapWidth - 3
self.pyramid = self.mapWidth - 4
self.pyramidHeight = 8
self.gravity = 15
-- associate player with map
self.player = Player(self)
-- camera offsets
self.camX = 0
self.camY = -3
self.mapWidthPixels = self.mapWidth * self.tileWidth
self.mapHeightPixels = self.mapHeight * self.tileHeight
for y = 1, self.mapHeight do
for x = 1, self.mapWidth do
self:setTile(x, y, TILE_EMPTY)
end
end
local x = 1
while x < self.mapWidth do
if x == self.flag then
self:setTile(x, (self.mapHeight / 2) - 3, POLE_TOP)
self:setTile(x, (self.mapHeight / 2) - 2, POLE_MIDDLE)
self:setTile(x, (self.mapHeight / 2) - 1, POLE_BOTTOM)
self:setTile(x+1, (self.mapHeight / 2) - 3, FLAG_TILE)
for y = self.mapHeight / 2, self.mapHeight do
self:makepyramid(x, y, TILE_BRICK)
end
self:setTile(self.flag)
x = x+1
end
This the code that I have written it does require other files to work but the core problem exists within this code: most probably with "makepyramid" in "map init()"
please suggest some possible changes that I can make to make this code work properly. comment down if you need more chunks of code to try some solutions.

Roblox leaderstat only updates once

I'm trying to reward the player with exp every time they the punch a damageable object (punching bag, dummies, etc) Whenever the play punches something, it updates the exp leaderstat only once, does anyone know what i'm doing wrong?
My Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
script.Parent.Touched:Connect(function(hit)
local Char = hit.parent
local Hum = Char:FindFirstChild("Humanoid")
if Hum and Char.Name ~= script.Parent.Parent.Name then
local Indicator = require(game.ReplicatedStorage.DamageIndicator)
local Player = script.Parent.Parent
local LocalPlayer = game.Players:GetPlayerFromCharacter(Player)
local Exp = LocalPlayer.leaderstats.Experience.Value
Hum:TakeDamage(script.Dmg.Value)
Indicator.DamageActivate(script.Dmg.Value, hit)
Exp = Exp + 15
LocalPlayer.PlayerGui.UI.Experience.ExpBar.Size = UDim2.new((Exp / 100) * 0, 0, 0.02, 0)
LocalPlayer.PlayerGui.UI.Experience.ExpBackground.ExpAmt.Text = Exp.."/100"
script.Disabled = true
end
end)
You're having the same issue as this guy.
When you create a variable based on a NumberValue's Value, you are storing a copy of the value, not a reference to it. If you want to update the value, you need to manually assign it.
local Exp = LocalPlayer.leaderstats.Experience
Exp.Value = Exp.Value + 15
local ExpGui = LocalPlayer.PlayerGui.UI.Experience
ExpGui.ExpBar.Size = UDim2.new((Exp.Value / 100) * 0, 0, 0.02, 0)
ExpGui.ExpBackground.ExpAmt.Text = tostring(Exp.Value) .. "/100"