Discuss Scratch

SuperDoom
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

ResExsention wrote:

kociara1232 wrote:

With Lua, a hello world program is only a single line:

print("Hello World!")
Same with Batch.
echo Hey, world! What's up?
ResExsention
New Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

dude341 wrote:

Nambaseking01 wrote:

If you want to create 2D games on Lua, check out Love, a ROBLOX game engine with which you can create 2D games on it. Install the software then see the scripts here: https://scratch.mit.edu/discuss/topic/354509/?page=1#post-3585826 (Love was suggested by bybb, a Scratcher who found this thread)
LOVE isn't related to Roblox at all.

This whole forum post is written as if Roblox invented Lua. You know that's not true, right?

I know.

This thread is tilted towards using Lua in Roblox Studio.

We never indicated that Roblox created Lua.
CatsUnited
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

ResExsention wrote:

dude341 wrote:

Nambaseking01 wrote:

If you want to create 2D games on Lua, check out Love, a ROBLOX game engine with which you can create 2D games on it. Install the software then see the scripts here: https://scratch.mit.edu/discuss/topic/354509/?page=1#post-3585826 (Love was suggested by bybb, a Scratcher who found this thread)
LOVE isn't related to Roblox at all.

This whole forum post is written as if Roblox invented Lua. You know that's not true, right?

I know.

This thread is tilted towards using Lua in Roblox Studio.

We never indicated that Roblox created Lua.
Nambase did say that Love was “a ROBLOX game engine…” when it's just it's own 2D based Lua programming program. I think that was a mistake on their part though
Nambaseking01
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

CatsUnited wrote:

…Nambase did say…

My imaginary city cannot talk.

Only Nammy can talk.
dude341
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

CatsUnited wrote:

ResExsention wrote:

dude341 wrote:

Nambaseking01 wrote:

If you want to create 2D games on Lua, check out Love, a ROBLOX game engine with which you can create 2D games on it. Install the software then see the scripts here: https://scratch.mit.edu/discuss/topic/354509/?page=1#post-3585826 (Love was suggested by bybb, a Scratcher who found this thread)
LOVE isn't related to Roblox at all.

This whole forum post is written as if Roblox invented Lua. You know that's not true, right?

I know.

This thread is tilted towards using Lua in Roblox Studio.

We never indicated that Roblox created Lua.
Nambase did say that Love was “a ROBLOX game engine…” when it's just it's own 2D based Lua programming program. I think that was a mistake on their part though
^
bybb
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

I don't get why Roblox still uses Lua and hasn't moved on to a better language for what their extensive API aims to achieve.
CatsUnited
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

bybb wrote:

I don't get why Roblox still uses Lua and hasn't moved on to a better language for what their extensive API aims to achieve.
I think Roblox knows that there's a lot of Roblox devs out there who write those generic popular games and make decent amount of money off it (I've seen images of a Roblox developer who owns a McLaren) who would probably make a big deal that Roblox is switching out from their perfect programming language, or that Lua is just so engrained into the Roblox community that it would take a lot to change that.
Morimop
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

I have a problem with scripting :p

local h = 1
function onClicked()
	if h < 2 then
		local h = 3
		print (h)
		game.Workspace.door.Transparency = 0.5
		game.Workspace.door.CanCollide = false
		wait (0.5)
	else
		game.Workspace.door.Transparency = 0
		game.Workspace.door.CanCollide = true
		local h = 1
		print (h)
		wait (0.5)
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
So here's my script. I want to use “local …” as variables in Scratch. When I click the door, if it's closed (or h is less than 2), door will be open and the “h” will be changed to “3”. If I click door and it's already opened (or h is greater than 2), door will be closed and “h” will be changed to “1”.

But when I click door and do this again after waiting few seconds, it always make “h” 3! So you can't close door!
How can I fix it?
Maple-Lace
Scratcher
100+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

I've tried making Roblox games and all I can figure out is that I need a script file. Is there a way to make stuff on Scratch(say a game) and then translate it to Lua?
CatsUnited
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

Maple-Lace wrote:

I've tried making Roblox games and all I can figure out is that I need a script file. Is there a way to make stuff on Scratch(say a game) and then translate it to Lua?
From what I know, there is no way to convert Scratch scripts into Lua, and Roblox and Scratch projects are constructed in very different ways, meaning you'd be better off just learning Lua than to try converting some Scratch code into Lua, since that itself would require Lua knowledge.
technoguyx
Scratcher
500+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

Maple-Lace wrote:

I've tried making Roblox games and all I can figure out is that I need a script file. Is there a way to make stuff on Scratch(say a game) and then translate it to Lua?
They're different things, but Scratch does give you a notion of what loops and other control structures are like. In Lua, and most programming languages, it's just a matter of knowing which objects and control structures you can use.

Morimop wrote:

I have a problem with scripting :p

(…)
Try removing the “local” from all lines inside your onClicked() function. In Lua, local variables are declared within the scope they're in — in this case, you're actually declaring two separate variables called “h”: one whose scope is the entire script, and another whose scope is just the “if” structure where you declared it. Here's an example script showing this.
ResExsention
New Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

Maple-Lace wrote:

I've tried making Roblox games and all I can figure out is that I need a script file. Is there a way to make stuff on Scratch(say a game) and then translate it to Lua?

Not files.

You use Script objects.

Unfortunately you get no shortcuts, so you will have to learn Lua.

I also recommend learning the difference between Scripts, LocalScripts, and ModuleScripts.

Additionally there is the 3D modeling part of making games, which is actually pretty easy in Roblox Studio.
Morimop
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

technoguyx wrote:

Morimop wrote:

I have a problem with scripting :p

(…)
Try removing the “local” from all lines inside your onClicked() function. In Lua, local variables are declared within the scope they're in — in this case, you're actually declaring two separate variables called “h”: one whose scope is the entire script, and another whose scope is just the “if” structure where you declared it. Here's an example script showing this.
Thanks! I will try it.
Morimop
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

technoguyx wrote:

morimop wrote:

(…)
Try removing the “local” from all lines inside your onClicked() function. In Lua, local variables are declared within the scope they're in — in this case, you're actually declaring two separate variables called “h”: one whose scope is the entire script, and another whose scope is just the “if” structure where you declared it. Here's an example script showing this.
Thanks! It works!

Last edited by Morimop (Oct. 2, 2019 17:53:46)

Nambaseking01
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

Up to you guys to continue this

I'm not online a lot on this thread
ResExsention
New Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

Morimop wrote:

technoguyx wrote:

morimop wrote:

(…)
Try removing the “local” from all lines inside your onClicked() function. In Lua, local variables are declared within the scope they're in — in this case, you're actually declaring two separate variables called “h”: one whose scope is the entire script, and another whose scope is just the “if” structure where you declared it. Here's an example script showing this.
Thanks! It works!

Glad we could help!

If you need a bit more clarification on the scope of variables, think of it this way:

When creating a Scratch variable, you have the option to set it for either all sprites in the project (global) or just for this sprite (local). When you choose the former option, you're essentially creating a global variable which will apply everywhere. This is why you can't create a “just for this sprite” (local) variable with the same name as a global variable.
maverick78921
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

CatsUnited wrote:

bybb wrote:

I don't get why Roblox still uses Lua and hasn't moved on to a better language for what their extensive API aims to achieve.
I think Roblox knows that there's a lot of Roblox devs out there who write those generic popular games and make decent amount of money off it (I've seen images of a Roblox developer who owns a McLaren) who would probably make a big deal that Roblox is switching out from their perfect programming language, or that Lua is just so engrained into the Roblox community that it would take a lot to change that.
roblox is aimed at kids so I imagine that they used Lua because it's simpler.
CatsUnited
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

maverick78921 wrote:

CatsUnited wrote:

bybb wrote:

I don't get why Roblox still uses Lua and hasn't moved on to a better language for what their extensive API aims to achieve.
I think Roblox knows that there's a lot of Roblox devs out there who write those generic popular games and make decent amount of money off it (I've seen images of a Roblox developer who owns a McLaren) who would probably make a big deal that Roblox is switching out from their perfect programming language, or that Lua is just so engrained into the Roblox community that it would take a lot to change that.
roblox is aimed at kids so I imagine that they used Lua because it's simpler.
I wouldn't consider Lua to be very kid friendly (Roblox Studio in general is though).
ResExsention
New Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

Quick scripting question:

Can LocalScripts be used to modify part positions without breaking everything?

So I have this GUI button with a LocalScript attached to it. Basically the LocalScript detects the Activated event of the GUI button and then proceeds to access the workspace and open a door. Is that valid code? I'm afraid that the door only opens for the person who clicked the button, and not the entire server.

The code:

local button = script.Parent
local door = game.Workspace.Doors.Door
local toggle = false
local moving = false
function onButtonActivated()
	if moving == false then
		moving = true
		if toggle == true then
			local i = 0
			while i < 37 do
				door.Position = door.Position - Vector3.new(0, 0.25, 0)
				wait(0.015)
				i = i + 1
			end
			toggle = false
			moving = false
		elseif toggle == false then
			local i = 0
			while i < 37 do
				door.Position = door.Position + Vector3.new(0, 0.25, 0)
				wait(0.015)
				i = i + 1
			end
			toggle = true
			moving = false
		end
	end
end
button.Activated:Connect(onButtonActivated)

So yeah, it's a toggle door.

btw the GUI is in StarterGui for those of you watching at home
Truck11111
Scratcher
1000+ posts

ROBLOX Lua Official Discussion [1K+ VIEWS]

how do i even use lua
edit: any guides?

Last edited by Truck11111 (Jan. 7, 2020 16:40:10)

Powered by DjangoBB