Need a little help scripting
#1
Question 
Well, I'm fresh here from ROBLOX. I been a 3 year veteran there, and still playing it. The Lua conversion is getting me a little. Here's the script I wrote:

while true do

newboxo = create("Box")
newboxo.Name = "newboxo"
newboxo.Size = Vector3.new(3,3)
newboxo.Parent = game.World
newboxo.Position = script.Parent.Position
newboxo.Fixed = false
sleep(2)
newboxo:remove()

end


What's suppose to happen is that a new "Box" appears at the position of the currently existing Box, then drop, then 2 seconds later, removes itself.

If something in the script is obsolete in Buildism, please tell me.

Yes I do know RBX.Lua. It's just much simpler in ROBLOX. Sad

[Image: Buildism%20ME.png]
Reply
#2
Vec2D(x, y)

not

Vector3.new(x, y, z)

Also, you might want to use [ lua ] tags around your code when you post it Tongue
Reply
#3
Oh, so it's Vec2D now? Thanks. And I'll keep the tag thing in mind.

I'm too use to ROBLOX. Sad
[Image: Buildism%20ME.png]
Reply
#4
I know; before Jacob_ started phasing out sleep() I regurlarly got it and wait() mixed up on BOTH sites. That and connect() and link().
Reply
#5
Eh, the scripts are still going funky. ._.

No dropping boxes. D:

Nevermind! I just can't rewind anymore, that's all! Big Grin
[Image: Buildism%20ME.png]
Reply
#6
Try this.

[lua]
function waitFor(time)
local oldtime = os.time()
while true do
sleep(0.01)
if os.time() - oldtime >= time then
break end end
end


while true do

newboxo = create("Box")
newboxo.Name = "newboxo"
newboxo.Size = Vec2D(3,3)
newboxo.Parent = game.World
newboxo.Position = script.Parent.Position
newboxo.Fixed = false
waitFor(2)
newboxo:remove()

end
[/lua]

As it says, sleep() for long periods will be disabled tommorrow.
Reply
#7
Thanks. Big Grin

Whenever I used "Sleep(1)", it spammed my chatbox with "Use os.time()" instead, even though I don't know what that is.
[Image: Buildism%20ME.png]
Reply
#8
(07-31-2011, 11:59 PM)Qwertygiy Wrote: Try this.

[lua]
function waitFor(time)
local oldtime = os.time()
while true do
sleep(0.01)
if os.time() - oldtime >= time then
break end end
end


while true do

newboxo = create("Box")
newboxo.Name = "newboxo"
newboxo.Size = Vec2D(3,3)
newboxo.Parent = game.World
newboxo.Position = script.Parent.Position
newboxo.Fixed = false
waitFor(2)
newboxo:remove()

end
[/lua]

As it says, sleep() for long periods will be disabled tommorrow.

Only in events, not everywhere.
Reply
#9
It says that in the output whenever I use sleep. Including in loops and regular scripts.
Reply
#10
(08-01-2011, 12:06 AM)Qwertygiy Wrote: It says that in the output whenever I use sleep. Including in loops and regular scripts.

I know, but it will only be disabled in events, which is stated in the message.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)