Are scripts functioning yet?
#1
Question 
If so, could I get just a couple of examples of something to get started on? From what I can gather, it looks like this'll be using Java instead of Lua, so I'll have to learn an entirely new language. haha.
LISTEN TO THE ALBUMS I PUT IN MY SIGNATURE
___________________________
[Image: 511873.jpg][Image: 744241_isls_vapours.jpg]
Reply
#2
I use Lua for the scripting. You can type in the command bar, or use Edit>Insert Script to add a script, double click to edit it, then right click>Run Script to test it.

Events don't work yet, but you can do a lot of simple things.

Code:
p =  create("Box"); p. Size = Vec2D(10, 10); p.Position = game.Camera.Position; p.Parent = game.World
[/code]
Code:
while true do game.World.Ground.Color = Color(math.random(0, 255), math.random(0, 255), math.random(0, 255)); sleep(1); end

Code:
step = 0.5
while true do
game.Camera.ScaleFactor = game.Camera.ScaleFactor + step
if game.Camera.ScaleFactor > 16 then
step = -0.5
end
if game.Camera.ScaleFactor < 1 then
step = 0.5
end
sleep(0.05)
end

Code:
game.TaskScheduler:schedule(function() --This makes sure the simulation won't step in the middle of the script
p1 = create("Box")
p1.Position = game.Camera.Position
p1.Parent = game.World

p2 = create("Box")
p2.Position = Vec2D(game.Camera.Position.x, game.Camera.Position.y + 2)
p2.Parent = game.World

w = create("Hinge")
w.Part1 = p1
w.Part2 = p2
w.Anchor = game.Camera.Position
w.Parent = game.JointsService
end)
Reply
#3
oh god thank you.
I'm going to experiment around a bit more now that I know this. I'll post a bit later once I make something really silly.
LISTEN TO THE ALBUMS I PUT IN MY SIGNATURE
___________________________
[Image: 511873.jpg][Image: 744241_isls_vapours.jpg]
Reply
#4
oh goodie, now i can make waffle runners 2d mode
Reply
#5
Here is a simple script, used in the "Raining parts" game[/code]:
Code:
while true do
p = create("Box");
p.Position = Vec2D(math.random(450, 550), 100)
p.Size = Vec2D(math.random(5, 20), math.random(5, 20))
p.Color = Color(math.random(0, 255), math.random(0, 255), math.random(0, 255))
p.Parent = game.World
s = create("Script")
s.Source = "sleep(5); while script.Parent.Transparency < 1 do script.Parent.Transparency = script.Parent.Transparency + 0.2; sleep(0.1); end; script.Parent:remove();"
s.Parent = p
sleep(1)
end
Reply
#6
are there ways to make the script run when a player/object appears or dissapears?

like the connection in RBLX LUA?
Reply
#7
Like an onChildAdded/onChildRemoved event? I just added events, so it should be pretty easy to do.
Reply
#8
The latest version has ChildAdded and ChildRemoved events.
Reply
#9
sleep() is generally used to make the application go to "sleep", meaning, freezing it for a given amount of time (useful for game over screens or save & loads)

Therefore, imo, it's kinda confusing. But I should stop whining and praise the fact you're a one man team. Big Grin
Reply
#10
(10-15-2010, 05:04 AM)Patacorow Wrote: sleep() is generally used to make the application go to "sleep", meaning, freezing it for a given amount of time (useful for game over screens or save & loads)

Therefore, imo, it's kinda confusing. But I should stop whining and praise the fact you're a one man team. Big Grin

In Java sleep(time) means to wait a certain number of seconds, wait() means the current thread should wait until another thread notifies it to do something.

Seems kind of backwards to me, but that's how it is...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)