Possible error when compiling program
I'm writing an interpreter and i'm trying to have the output bytecodes be 1:1 with the official
g1, g2 = 1, 2
local up1, up2, up3, up4 = 11, 12, 13, 14
local print = print
local function foo()
local l1, l2 = 101, 102
l1, g1 = g2, l2
print(l1, g1)
-- assign to upvalues
up1, up2, up3 = l1, g1, up4
print(up1, up2, up3)
-- assign by upvalues
l1, g1, up1 = up2, up3, up4
print(l1, g1, up1)
local inner = function()
-- assign to upvalues
up1, up2, up3 = 101, g2, up4
print(up1, up2, up3)
end
inner()
end
foo()
main <testlua/chapter9/upvalues.lua:0,0> (13 instructions at 0x1433ecd0)
0+ params, 7 slots, 1 upvalue, 6 locals, 4 constants, 1 function
1 [1] VARARGPREP 0
2 [1] LOADI 0 1
3 [1] SETTABUP 0 1 2k ; ENV "g2" 2
4 1 SETTABUP 0 0 0 ; ENV "g1"
5 [2] LOADI 0 11
6 [2] LOADI 1 12
7 [2] LOADI 2 13
8 [2] LOADI 3 14
9 [3] GETTABUP 4 0 3 ; ENV "print"
10 23 CLOSURE 5 0 ; 0x1433f550
11 25 MOVE 6 5
12 25 CALL 6 1 1 ; 0 in 0 out
13 25 RETURN 6 1 1k ; 0 out
constants (4) for 0x1433ecd0:
0 S "g1"
1 S "g2"
2 I 2
3 S "print"
locals (6) for 0x1433ecd0:
0 up1 9 14
1 up2 9 14
2 up3 9 14
3 up4 9 14
4 print 10 14
5 foo 11 14
upvalues (1) for 0x1433ecd0:
0 ENV 1 0
function <testlua/chapter9/upvalues.lua:4,23> (35 instructions at 0x1433f550)
0 params, 6 slots, 6 upvalues, 3 locals, 2 constants, 1 function
1 5 LOADI 0 101
2 5 LOADI 1 102
3 6 GETTABUP 2 0 1 ; ENV "g2"
4 [6] SETTABUP 0 0 1 ; ENV "g1"
5 6 MOVE 0 2
6 7 GETUPVAL 2 1 ; print
7 7 MOVE 3 0
8 7 GETTABUP 4 0 0 ; ENV "g1"
9 [7] CALL 2 3 1 ; 2 in 0 out
10 [10] MOVE 2 0
11 [10] GETTABUP 3 0 0 ; ENV "g1"
12 10 GETUPVAL 4 5 ; up4
13 10 SETUPVAL 4 4 ; up3
14 10 SETUPVAL 3 3 ; up2
15 10 SETUPVAL 2 2 ; up1
16 11 GETUPVAL 2 1 ; print
17 11 GETUPVAL 3 2 ; up1
18 11 GETUPVAL 4 3 ; up2
19 11 GETUPVAL 5 4 ; up3
20 11 CALL 2 4 1 ; 3 in 0 out
21 14 GETUPVAL 2 3 ; up2
22 14 GETUPVAL 3 4 ; up3
23 14 GETUPVAL 4 5 ; up4
24 14 SETUPVAL 4 2 ; up1
25 14 SETTABUP 0 0 3 ; ENV "g1"
26 [14] MOVE 0 2
27 [15] GETUPVAL 2 1 ; print
28 [15] MOVE 3 0
29 [15] GETTABUP 4 0 0 ; ENV "g1"
30 15 GETUPVAL 5 2 ; up1
31 15 CALL 2 4 1 ; 3 in 0 out
32 21 CLOSURE 2 0 ; 0x1433fa70
33 22 MOVE 3 2
34 22 CALL 3 1 1 ; 0 in 0 out
35 23 RETURN0
constants (2) for 0x1433f550:
0 S "g1"
1 S "g2"
locals (3) for 0x1433f550:
0 l1 3 36
1 l2 3 36
2 inner 33
I'm writing an interpreter and i'm trying to have the output bytecodes be 1:1 with the official
luac using the 5.4.7 luac on the following program gives me these output luac -l -l -p test_lua/chapter9/upvalues.luag1, g2 = 1, 2
local up1, up2, up3, up4 = 11, 12, 13, 14
local print = print
local function foo()
local l1, l2 = 101, 102
l1, g1 = g2, l2
print(l1, g1)
-- assign to upvalues
up1, up2, up3 = l1, g1, up4
print(up1, up2, up3)
-- assign by upvalues
l1, g1, up1 = up2, up3, up4
print(l1, g1, up1)
local inner = function()
-- assign to upvalues
up1, up2, up3 = 101, g2, up4
print(up1, up2, up3)
end
inner()
end
foo()
main <testlua/chapter9/upvalues.lua:0,0> (13 instructions at 0x1433ecd0)
0+ params, 7 slots, 1 upvalue, 6 locals, 4 constants, 1 function
1 [1] VARARGPREP 0
2 [1] LOADI 0 1
3 [1] SETTABUP 0 1 2k ; ENV "g2" 2
4 1 SETTABUP 0 0 0 ; ENV "g1"
5 [2] LOADI 0 11
6 [2] LOADI 1 12
7 [2] LOADI 2 13
8 [2] LOADI 3 14
9 [3] GETTABUP 4 0 3 ; ENV "print"
10 23 CLOSURE 5 0 ; 0x1433f550
11 25 MOVE 6 5
12 25 CALL 6 1 1 ; 0 in 0 out
13 25 RETURN 6 1 1k ; 0 out
constants (4) for 0x1433ecd0:
0 S "g1"
1 S "g2"
2 I 2
3 S "print"
locals (6) for 0x1433ecd0:
0 up1 9 14
1 up2 9 14
2 up3 9 14
3 up4 9 14
4 print 10 14
5 foo 11 14
upvalues (1) for 0x1433ecd0:
0 ENV 1 0
function <testlua/chapter9/upvalues.lua:4,23> (35 instructions at 0x1433f550)
0 params, 6 slots, 6 upvalues, 3 locals, 2 constants, 1 function
1 5 LOADI 0 101
2 5 LOADI 1 102
3 6 GETTABUP 2 0 1 ; ENV "g2"
4 [6] SETTABUP 0 0 1 ; ENV "g1"
5 6 MOVE 0 2
6 7 GETUPVAL 2 1 ; print
7 7 MOVE 3 0
8 7 GETTABUP 4 0 0 ; ENV "g1"
9 [7] CALL 2 3 1 ; 2 in 0 out
10 [10] MOVE 2 0
11 [10] GETTABUP 3 0 0 ; ENV "g1"
12 10 GETUPVAL 4 5 ; up4
13 10 SETUPVAL 4 4 ; up3
14 10 SETUPVAL 3 3 ; up2
15 10 SETUPVAL 2 2 ; up1
16 11 GETUPVAL 2 1 ; print
17 11 GETUPVAL 3 2 ; up1
18 11 GETUPVAL 4 3 ; up2
19 11 GETUPVAL 5 4 ; up3
20 11 CALL 2 4 1 ; 3 in 0 out
21 14 GETUPVAL 2 3 ; up2
22 14 GETUPVAL 3 4 ; up3
23 14 GETUPVAL 4 5 ; up4
24 14 SETUPVAL 4 2 ; up1
25 14 SETTABUP 0 0 3 ; ENV "g1"
26 [14] MOVE 0 2
27 [15] GETUPVAL 2 1 ; print
28 [15] MOVE 3 0
29 [15] GETTABUP 4 0 0 ; ENV "g1"
30 15 GETUPVAL 5 2 ; up1
31 15 CALL 2 4 1 ; 3 in 0 out
32 21 CLOSURE 2 0 ; 0x1433fa70
33 22 MOVE 3 2
34 22 CALL 3 1 1 ; 0 in 0 out
35 23 RETURN0
constants (2) for 0x1433f550:
0 S "g1"
1 S "g2"
locals (3) for 0x1433f550:
0 l1 3 36
1 l2 3 36
2 inner 33
36
upvalues (6) for 0x1433f550:
0 ENV 0 0
1 print 1 4
2 up1 1 0
3 up2 1 1
4 up3 1 2
5 up4 1 3
function <testlua/chapter9/upvalues.lua:17,21> (12 instructions at 0x1433fa70)
0 params, 4 slots, 6 upvalues, 0 locals, 1 constant, 0 functions
1 19 LOADI 0 101
2 19 GETTABUP 1 3 0 ; ENV "g2"
3 [19] GETUPVAL 2 4 ; up4
4 [19] SETUPVAL 2 2 ; up3
5 [19] SETUPVAL 1 1 ; up2
6 [19] SETUPVAL 0 0 ; up1
7 [20] GETUPVAL 0 5 ; print
8 [20] GETUPVAL 1 0 ; up1
9 [20] GETUPVAL 2 1 ; up2
10 [20] GETUPVAL 3 2 ; up3
11 [20] CALL 0 4 1 ; 3 in 0 out
12 [21] RETURN0
constants (1) for 0x1433fa70:
0 S "g2"
locals (0) for 0x1433fa70:
upvalues (6) for 0x1433fa70:
0 up1 0 2
1 up2 0 3
2 up3 0 4
3 ENV 0 0
4 up4 0 5
5 print 0 1
shouldn't this line
https://redd.it/1je7b26
@r_lua
upvalues (6) for 0x1433f550:
0 ENV 0 0
1 print 1 4
2 up1 1 0
3 up2 1 1
4 up3 1 2
5 up4 1 3
function <testlua/chapter9/upvalues.lua:17,21> (12 instructions at 0x1433fa70)
0 params, 4 slots, 6 upvalues, 0 locals, 1 constant, 0 functions
1 19 LOADI 0 101
2 19 GETTABUP 1 3 0 ; ENV "g2"
3 [19] GETUPVAL 2 4 ; up4
4 [19] SETUPVAL 2 2 ; up3
5 [19] SETUPVAL 1 1 ; up2
6 [19] SETUPVAL 0 0 ; up1
7 [20] GETUPVAL 0 5 ; print
8 [20] GETUPVAL 1 0 ; up1
9 [20] GETUPVAL 2 1 ; up2
10 [20] GETUPVAL 3 2 ; up3
11 [20] CALL 0 4 1 ; 3 in 0 out
12 [21] RETURN0
constants (1) for 0x1433fa70:
0 S "g2"
locals (0) for 0x1433fa70:
upvalues (6) for 0x1433fa70:
0 up1 0 2
1 up2 0 3
2 up3 0 4
3 ENV 0 0
4 up4 0 5
5 print 0 1
shouldn't this line
24 [14] SETUPVAL 4 2 ; up1 be 24 [14] SETUPVAL 2 4 ; up1?https://redd.it/1je7b26
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
lua noscript
Hi I'm looking for someone who can write a trigger bot for FiveM as a Lua noscript. If you can do that and it works in the end, I would also pay for it.
https://redd.it/1jee7sz
@r_lua
Hi I'm looking for someone who can write a trigger bot for FiveM as a Lua noscript. If you can do that and it works in the end, I would also pay for it.
https://redd.it/1jee7sz
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Put png file in lua file is possible ?
Hello, I'm a graphic designer (so you're talking to someone stupid, who's probably going to ask stupid questions)
For a project, I need to put PNG files inside a LUA file, so as not to provide any external files other than the LUA file, but I don't know if this is possible (I hear everything and its opposite on the internet).
can someone can answer my question ? :/
https://redd.it/1jegkf5
@r_lua
Hello, I'm a graphic designer (so you're talking to someone stupid, who's probably going to ask stupid questions)
For a project, I need to put PNG files inside a LUA file, so as not to provide any external files other than the LUA file, but I don't know if this is possible (I hear everything and its opposite on the internet).
can someone can answer my question ? :/
https://redd.it/1jegkf5
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Help
So ive done a few LUA tutorials online (trying to learn it for ROBLOX game development) but i have learnt everything cant figure out how to make stuff. like for example, i know stuff about lua but i have no idea how to make something random that helps me practice. like i dont know how to actually noscript this stuff but i know the language idk if u guys can understand that but help pls
https://redd.it/1jey7b1
@r_lua
So ive done a few LUA tutorials online (trying to learn it for ROBLOX game development) but i have learnt everything cant figure out how to make stuff. like for example, i know stuff about lua but i have no idea how to make something random that helps me practice. like i dont know how to actually noscript this stuff but i know the language idk if u guys can understand that but help pls
https://redd.it/1jey7b1
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Scribe
Scribe provides functions to convert Lua objects to readable strings and output methods that make printing Lua tables in various formats easy.
For example, if
Scribe gracefully handles complex tables, including ones with shared and cyclical references. The strings returned for those tables show the underlying structure in a way that is as readable as possible.
You can customise the strings returned for tables by passing a set of formatting options, and there are pre-defined options that will work for most applications. Those include printing tables on a single line, in a “pretty” format on multiple lines, or as JSON-like denoscriptors.
luarocks install scribe
We built the documentation site using Quarto.
The documentation includes a lengthy article describing how we built the module.
That tutorial might be a decent Lua 201 tutorial for those new to the language.
https://redd.it/1jf3n39
@r_lua
Scribe provides functions to convert Lua objects to readable strings and output methods that make printing Lua tables in various formats easy.
For example, if
arr = {1, 2, 3} then scribe.put("Array: %t", arr) will print "Array: [ 1, 2, 3 \]" to stdout.Scribe gracefully handles complex tables, including ones with shared and cyclical references. The strings returned for those tables show the underlying structure in a way that is as readable as possible.
You can customise the strings returned for tables by passing a set of formatting options, and there are pre-defined options that will work for most applications. Those include printing tables on a single line, in a “pretty” format on multiple lines, or as JSON-like denoscriptors.
scribe is available as a GitHub repo. It has a permissive MIT License.scribe can also be installed using luarocks:luarocks install scribe
scribe is fully documented here. We built the documentation site using Quarto.
The documentation includes a lengthy article describing how we built the module.
That tutorial might be a decent Lua 201 tutorial for those new to the language.
https://redd.it/1jf3n39
@r_lua
GitHub
GitHub - nessan/scribe: Scribe converts Lua objects to readable strings and has output methods to output tables in many different…
Scribe converts Lua objects to readable strings and has output methods to output tables in many different formats. - nessan/scribe
Beginner programmer looking for a teacher or tips
I am new to lua and coding in general, though I do have a little experience in python. I am trying to make a Roblox game. I am looking for someone to help me and teach me the coding language lua
https://redd.it/1jfgnb9
@r_lua
I am new to lua and coding in general, though I do have a little experience in python. I am trying to make a Roblox game. I am looking for someone to help me and teach me the coding language lua
https://redd.it/1jfgnb9
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Help! Roblox Studio Lua!
So, before I get into this, yes I used AI, no I can't code even a little, meaning no I do not have any idea what I'm doing, but brownie points for trying, I guess?
I don't currently want to get into learning code, (I have school and other stuff, but I really wanted to get into experimenting with Studio) but unfortunately, with trying to make a Roblox game, that's required for quality. Hoping someone can help me here.
By the way! This is all happening on a test world which has nothing but a part that I'm using as a baseplate, and a humanoid named DialogueNPC in the workspace (plus spawn). The dialogue in this code is random and only for testing purposes.
I'm trying to make a dialogue work, as you can tell by the NPC's name. I already have a noscript for tweening on-screen, and a noscript for tweening off-screen. By the grace of God, they work perfectly.Still, I'll provide you with everything I have, and everything these AI's have put me through lmao. I put an image of my hierarchy, assuming you'll need it. I'll sum up the noscripts, but pretty sure you guys could probably read these like books. I broke these into many noscripts because originally when there were just two big ones, it didn't work well and I couldn't try to use my very tiny coding brain to figure out what was the problem.
**Script #1: AnimScript. (Server Script) This noscript tweens the CinemaBar1 and 2 onto the screen for the player, no issues but I don't know if it conflicts with anything, so I'm giving it to you.**
\-- Script inside DialogueUI (AnimScript)
local Torso = workspace.DialogueNPC:WaitForChild("Torso")
local EPrompt = Torso:WaitForChild("EPrompt")
local dialogueUI = noscript.Parent -- Get DialogueUI from noscript.Parent
local CinemaBar1 = dialogueUI:WaitForChild("CinemaBar1")
local CinemaBar2 = dialogueUI:WaitForChild("CinemaBar2")
local startPosition1 = UDim2.new(0.5, 0, 1.851, 0)
local targetPosition1 = UDim2.new(0.5, 0, 0.851, 0)
local startPosition2 = UDim2.new(0.5, 0, -1, 0)
local targetPosition2 = UDim2.new(0.5, 0, 0.066, 0)
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local function onPromptTriggered(player) -- Player is passed in
local tweenService = game:GetService("TweenService")
local tween1 = tweenService:Create(CinemaBar1, tweenInfo, {Position = targetPosition1})
local tween2 = tweenService:Create(CinemaBar2, tweenInfo, {Position = targetPosition2})
CinemaBar1.Position = startPosition1
CinemaBar2.Position = startPosition2
tween1:Play()
tween2:Play()
\-- Signal Dialogue Script
local dialogueEvent = game.ReplicatedStorage:WaitForChild("StartDialogueEvent")
dialogueEvent:FireClient(player) -- Fire the event to the client
end
EPrompt.Triggered:Connect(onPromptTriggered)
**Script #2: AnimScriptReverse. (Server Script) This does what the name says. Just the reverse of the AnimScript. Brings CinemaBar1 & 2 off screen, then turns the GUI to false.**
off-screen.
\-- Script inside DialogueUI (AnimScriptReverse)
local dialogueUI = noscript.Parent
local dialogueScript = dialogueUI:WaitForChild("DialogueButtonScript")
local dialogueModule = require(dialogueUI:WaitForChild("DialogueModule")) -- Require the module
local CinemaBar1 = dialogueUI:WaitForChild("CinemaBar1")
local CinemaBar2 = dialogueUI:WaitForChild("CinemaBar2")
local startPosition1 = UDim2.new(0.5, 0, 1.851, 0)
local targetPosition1 = UDim2.new(0.5, 0, 0.851, 0)
local startPosition2 = UDim2.new(0.5, 0, -1, 0)
local targetPosition2 = UDim2.new(0.5, 0, 0.066, 0)
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local function resetDialogue()
dialogueUI.Enabled = true
dialogueModule.currentDialogueState = "Greeting" -- Use the module variable
dialogueScript.updateDialogue()
end
local function reverseAnimation()
local tweenService = game:GetService("TweenService")
local tween1 = tweenService:Create(CinemaBar1, tweenInfo, {Position =
So, before I get into this, yes I used AI, no I can't code even a little, meaning no I do not have any idea what I'm doing, but brownie points for trying, I guess?
I don't currently want to get into learning code, (I have school and other stuff, but I really wanted to get into experimenting with Studio) but unfortunately, with trying to make a Roblox game, that's required for quality. Hoping someone can help me here.
By the way! This is all happening on a test world which has nothing but a part that I'm using as a baseplate, and a humanoid named DialogueNPC in the workspace (plus spawn). The dialogue in this code is random and only for testing purposes.
I'm trying to make a dialogue work, as you can tell by the NPC's name. I already have a noscript for tweening on-screen, and a noscript for tweening off-screen. By the grace of God, they work perfectly.Still, I'll provide you with everything I have, and everything these AI's have put me through lmao. I put an image of my hierarchy, assuming you'll need it. I'll sum up the noscripts, but pretty sure you guys could probably read these like books. I broke these into many noscripts because originally when there were just two big ones, it didn't work well and I couldn't try to use my very tiny coding brain to figure out what was the problem.
**Script #1: AnimScript. (Server Script) This noscript tweens the CinemaBar1 and 2 onto the screen for the player, no issues but I don't know if it conflicts with anything, so I'm giving it to you.**
\-- Script inside DialogueUI (AnimScript)
local Torso = workspace.DialogueNPC:WaitForChild("Torso")
local EPrompt = Torso:WaitForChild("EPrompt")
local dialogueUI = noscript.Parent -- Get DialogueUI from noscript.Parent
local CinemaBar1 = dialogueUI:WaitForChild("CinemaBar1")
local CinemaBar2 = dialogueUI:WaitForChild("CinemaBar2")
local startPosition1 = UDim2.new(0.5, 0, 1.851, 0)
local targetPosition1 = UDim2.new(0.5, 0, 0.851, 0)
local startPosition2 = UDim2.new(0.5, 0, -1, 0)
local targetPosition2 = UDim2.new(0.5, 0, 0.066, 0)
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local function onPromptTriggered(player) -- Player is passed in
local tweenService = game:GetService("TweenService")
local tween1 = tweenService:Create(CinemaBar1, tweenInfo, {Position = targetPosition1})
local tween2 = tweenService:Create(CinemaBar2, tweenInfo, {Position = targetPosition2})
CinemaBar1.Position = startPosition1
CinemaBar2.Position = startPosition2
tween1:Play()
tween2:Play()
\-- Signal Dialogue Script
local dialogueEvent = game.ReplicatedStorage:WaitForChild("StartDialogueEvent")
dialogueEvent:FireClient(player) -- Fire the event to the client
end
EPrompt.Triggered:Connect(onPromptTriggered)
**Script #2: AnimScriptReverse. (Server Script) This does what the name says. Just the reverse of the AnimScript. Brings CinemaBar1 & 2 off screen, then turns the GUI to false.**
off-screen.
\-- Script inside DialogueUI (AnimScriptReverse)
local dialogueUI = noscript.Parent
local dialogueScript = dialogueUI:WaitForChild("DialogueButtonScript")
local dialogueModule = require(dialogueUI:WaitForChild("DialogueModule")) -- Require the module
local CinemaBar1 = dialogueUI:WaitForChild("CinemaBar1")
local CinemaBar2 = dialogueUI:WaitForChild("CinemaBar2")
local startPosition1 = UDim2.new(0.5, 0, 1.851, 0)
local targetPosition1 = UDim2.new(0.5, 0, 0.851, 0)
local startPosition2 = UDim2.new(0.5, 0, -1, 0)
local targetPosition2 = UDim2.new(0.5, 0, 0.066, 0)
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local function resetDialogue()
dialogueUI.Enabled = true
dialogueModule.currentDialogueState = "Greeting" -- Use the module variable
dialogueScript.updateDialogue()
end
local function reverseAnimation()
local tweenService = game:GetService("TweenService")
local tween1 = tweenService:Create(CinemaBar1, tweenInfo, {Position =
startPosition1})
local tween2 = tweenService:Create(CinemaBar2, tweenInfo, {Position = startPosition2})
tween1:Play()
tween2:Play()
tween2.Completed:Connect(function()
dialogueUI.Enabled = false
resetDialogue()
end)
end
\-- Connect to a RemoteEvent (we'll fire this from the dialogue noscript)
local reverseEvent = game.ReplicatedStorage:WaitForChild("ReverseDialogueEvent")
reverseEvent.OnServerEvent:Connect(reverseAnimation)
**Script #3: DialogueModule. (Module Script) I'll be honest. I have no idea what this does, or why it's needed. It's just there because the AI told me to.**
\-- DialogueModule
local DialogueModule = {}
DialogueModule.currentDialogueState = "Greeting" -- Starting state
return DialogueModule
**Script #4: DialogueButtonScript. (Local noscript) This is where the issue is. It's not a big part, something small that prevents the whole thing from working, but essentially it holds the dialogue, creates buttons using a button template I made, and is supposed to carry out the sequence of dialogue when an option other than nextState = nil or Goodbye is pressed.**
**Issue? ::** line 76, updateDialogue()
**What is the output error? ::** it is a nil error.
Players.R1NYP00H.PlayerGui.DialogueUI.DialogueButtonScript:76: attempt to call a nil value - Client - DialogueButtonScript:76
Apparently this means its trying to call a value that's undefined? I've tried anything I know, and anything these computers can give me, and its either going way too complicated for my understanding, or doesn't work and creates more errors. This error happens when you click a text button/option that leads to more dialogue instead of closing the UI. Once again, dialogue was generated random, just for testing.
\-- LocalScript inside DialogueUI
local OptionsList = noscript.Parent:WaitForChild("CinemaBar1"):WaitForChild("OptionsList")
local DialogueOptionTemplate = OptionsList:WaitForChild("DialogueOptionTemplate")
local NPCSpeechText = noscript.Parent:WaitForChild("CinemaBar1"):WaitForChild("NPCDialogueBar"):WaitForChild("NPCSpeechText")
local UIListLayout = OptionsList:WaitForChild("UIListLayout")
local dialogueModule = require(noscript.Parent:WaitForChild("DialogueModule")) -- Require the module
\-- // Dialogue Data (your data)
local dialogueData = {
["Greeting"\] = {
npcSpeech = "Hello there, adventurer!",
options = {
{text = "Who are you?", nextState = "WhoAreYou"},
{text = "What's going on?", nextState = "WhatsGoingOn"},
{text = "Goodbye.", nextState = nil}
}
},
["WhoAreYou"\] = {
npcSpeech = "I am the friendly local guide.",
options = {
{text = "Where can you guide me?", nextState = "WhereToGuide"},
{text = "Okay, thanks.", nextState = nil}
}
},
["WhatsGoingOn"\] = {
npcSpeech = "There's a bit of trouble in town...",
options = {
{text = "Tell me more.", nextState = "TellMeMore"},
{text = "I see.", nextState = nil}
}
},
["TellMeMore"\] = {
npcSpeech = "The goblins have been stealing pies!",
options = {
{text = "I'll help!", nextState = "Help"},
{text = "That's... unfortunate.", nextState = nil}
}
},
["WhereToGuide"\] = {
npcSpeech = "I can show you the old ruins.",
options = {
{text = "Take me there!", nextState = "Goodbye"}, -- Or another state
{text = "Maybe later.", nextState = nil}
}
},
["Help"\] = {
npcSpeech = "Thank you! The bakery is just over there.",
options = {
{text = "I'm on it!", nextState = nil}
}
},
["Goodbye"\] = {
npcSpeech = "Farewell!",
options = {} -- No more options, dialogue ends
}
}
\-- Move updateDialogue() before the click event handler
local function createDialogueOptions(options)
\-- Create new options from the provided table
for _, optionData in ipairs(options) do
local newOption = DialogueOptionTemplate:Clone()
newOption.Text = optionData.text
newOption.Name = "DialogueOption_" .. _ -- Unique name
\-- Parent the button before making it
local tween2 = tweenService:Create(CinemaBar2, tweenInfo, {Position = startPosition2})
tween1:Play()
tween2:Play()
tween2.Completed:Connect(function()
dialogueUI.Enabled = false
resetDialogue()
end)
end
\-- Connect to a RemoteEvent (we'll fire this from the dialogue noscript)
local reverseEvent = game.ReplicatedStorage:WaitForChild("ReverseDialogueEvent")
reverseEvent.OnServerEvent:Connect(reverseAnimation)
**Script #3: DialogueModule. (Module Script) I'll be honest. I have no idea what this does, or why it's needed. It's just there because the AI told me to.**
\-- DialogueModule
local DialogueModule = {}
DialogueModule.currentDialogueState = "Greeting" -- Starting state
return DialogueModule
**Script #4: DialogueButtonScript. (Local noscript) This is where the issue is. It's not a big part, something small that prevents the whole thing from working, but essentially it holds the dialogue, creates buttons using a button template I made, and is supposed to carry out the sequence of dialogue when an option other than nextState = nil or Goodbye is pressed.**
**Issue? ::** line 76, updateDialogue()
**What is the output error? ::** it is a nil error.
Players.R1NYP00H.PlayerGui.DialogueUI.DialogueButtonScript:76: attempt to call a nil value - Client - DialogueButtonScript:76
Apparently this means its trying to call a value that's undefined? I've tried anything I know, and anything these computers can give me, and its either going way too complicated for my understanding, or doesn't work and creates more errors. This error happens when you click a text button/option that leads to more dialogue instead of closing the UI. Once again, dialogue was generated random, just for testing.
\-- LocalScript inside DialogueUI
local OptionsList = noscript.Parent:WaitForChild("CinemaBar1"):WaitForChild("OptionsList")
local DialogueOptionTemplate = OptionsList:WaitForChild("DialogueOptionTemplate")
local NPCSpeechText = noscript.Parent:WaitForChild("CinemaBar1"):WaitForChild("NPCDialogueBar"):WaitForChild("NPCSpeechText")
local UIListLayout = OptionsList:WaitForChild("UIListLayout")
local dialogueModule = require(noscript.Parent:WaitForChild("DialogueModule")) -- Require the module
\-- // Dialogue Data (your data)
local dialogueData = {
["Greeting"\] = {
npcSpeech = "Hello there, adventurer!",
options = {
{text = "Who are you?", nextState = "WhoAreYou"},
{text = "What's going on?", nextState = "WhatsGoingOn"},
{text = "Goodbye.", nextState = nil}
}
},
["WhoAreYou"\] = {
npcSpeech = "I am the friendly local guide.",
options = {
{text = "Where can you guide me?", nextState = "WhereToGuide"},
{text = "Okay, thanks.", nextState = nil}
}
},
["WhatsGoingOn"\] = {
npcSpeech = "There's a bit of trouble in town...",
options = {
{text = "Tell me more.", nextState = "TellMeMore"},
{text = "I see.", nextState = nil}
}
},
["TellMeMore"\] = {
npcSpeech = "The goblins have been stealing pies!",
options = {
{text = "I'll help!", nextState = "Help"},
{text = "That's... unfortunate.", nextState = nil}
}
},
["WhereToGuide"\] = {
npcSpeech = "I can show you the old ruins.",
options = {
{text = "Take me there!", nextState = "Goodbye"}, -- Or another state
{text = "Maybe later.", nextState = nil}
}
},
["Help"\] = {
npcSpeech = "Thank you! The bakery is just over there.",
options = {
{text = "I'm on it!", nextState = nil}
}
},
["Goodbye"\] = {
npcSpeech = "Farewell!",
options = {} -- No more options, dialogue ends
}
}
\-- Move updateDialogue() before the click event handler
local function createDialogueOptions(options)
\-- Create new options from the provided table
for _, optionData in ipairs(options) do
local newOption = DialogueOptionTemplate:Clone()
newOption.Text = optionData.text
newOption.Name = "DialogueOption_" .. _ -- Unique name
\-- Parent the button before making it
visible
newOption.Parent = OptionsList
newOption.Visible = true
\-- Connect the button click event (add your logic here)
newOption.MouseButton1Click:Connect(function()
if optionData.nextState then
dialogueModule.currentDialogueState = optionData.nextState -- Use the module variable
updateDialogue() -- THIS LINE HERE , other comments were ai, but this is me
else
\-- End dialogue and reverse animation
local reverseEvent = game.ReplicatedStorage:WaitForChild("ReverseDialogueEvent")
reverseEvent:FireServer()
end
end)
end
end
\-- Move updateDialogue() outside of createDialogueOptions()
local function updateDialogue()
local currentStateData = dialogueData[dialogueModule.currentDialogueState\] -- Use the module variable
if currentStateData then
NPCSpeechText.Text = currentStateData.npcSpeech
createDialogueOptions(currentStateData.options)
else
\-- Handle invalid state (e.g., end dialogue or show an error)
NPCSpeechText.Text = "Dialogue error."
createDialogueOptions({})
end
end
\-- Start the dialogue
updateDialogue()
pls help I beg you very very smart awesome programming people. I'm a teen with no job and no moneys I can't afford to pay for an actual noscripter for my currently nonexistent game. (under NPCDialogueBar is NPCSpeechText, its a text label and it holds the NPC's end of the dialogue. forgot that drop-down)
https://redd.it/1jfijs2
@r_lua
newOption.Parent = OptionsList
newOption.Visible = true
\-- Connect the button click event (add your logic here)
newOption.MouseButton1Click:Connect(function()
if optionData.nextState then
dialogueModule.currentDialogueState = optionData.nextState -- Use the module variable
updateDialogue() -- THIS LINE HERE , other comments were ai, but this is me
else
\-- End dialogue and reverse animation
local reverseEvent = game.ReplicatedStorage:WaitForChild("ReverseDialogueEvent")
reverseEvent:FireServer()
end
end)
end
end
\-- Move updateDialogue() outside of createDialogueOptions()
local function updateDialogue()
local currentStateData = dialogueData[dialogueModule.currentDialogueState\] -- Use the module variable
if currentStateData then
NPCSpeechText.Text = currentStateData.npcSpeech
createDialogueOptions(currentStateData.options)
else
\-- Handle invalid state (e.g., end dialogue or show an error)
NPCSpeechText.Text = "Dialogue error."
createDialogueOptions({})
end
end
\-- Start the dialogue
updateDialogue()
pls help I beg you very very smart awesome programming people. I'm a teen with no job and no moneys I can't afford to pay for an actual noscripter for my currently nonexistent game. (under NPCDialogueBar is NPCSpeechText, its a text label and it holds the NPC's end of the dialogue. forgot that drop-down)
https://redd.it/1jfijs2
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
do you think i can optimise this code?
\--lua 5.4.2
print("write only numbers")
for i = 1,io.read() do
local file = io.open("words.txt", "r")
local word = ""
for i = 1,math.random(1,19999) do
word = file:read("*l")
end
local generated = {}
for i = 1, #word do
generated[i\] = word:sub(i, i)
end
local word_G = {}
for i = 1, #generated do
word_G[i\] = generated[math.random(#generated)\]
end
print(i..": "..word.." to "..table.concat(word_G))
end
https://redd.it/1jfw1ud
@r_lua
\--lua 5.4.2
print("write only numbers")
for i = 1,io.read() do
local file = io.open("words.txt", "r")
local word = ""
for i = 1,math.random(1,19999) do
word = file:read("*l")
end
local generated = {}
for i = 1, #word do
generated[i\] = word:sub(i, i)
end
local word_G = {}
for i = 1, #generated do
word_G[i\] = generated[math.random(#generated)\]
end
print(i..": "..word.." to "..table.concat(word_G))
end
https://redd.it/1jfw1ud
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
What is the return function?
I'm learning how to code, but I've reached a roadblock on what the return function is, as in I don't understand the explanation on what a return function does. I believe it's where you set a variable to the end of a sum? I'm pretty sure I'm wrong, so could you lovely people please help me?
https://redd.it/1jgntc2
@r_lua
I'm learning how to code, but I've reached a roadblock on what the return function is, as in I don't understand the explanation on what a return function does. I believe it's where you set a variable to the end of a sum? I'm pretty sure I'm wrong, so could you lovely people please help me?
https://redd.it/1jgntc2
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Need help with URI-encoded link pattern
So I wanted to create a URI encode/decode library and I am stuck on my function "IsUri"
I can't figure out how to return true/false correctly, because:
A URI encoded link will have %HEX for special characters like " " (space)
A non URI-encoded link can also contain "%" which messes up my pattern.
I tried to do these 2 steps but failed:
find if there are any special characters without "%" in a string (return false early)
find if "%" has a valid syntax (return false/true)
I have also searched google and your subreddit for it. No answers....
https://redd.it/1jgsmxf
@r_lua
So I wanted to create a URI encode/decode library and I am stuck on my function "IsUri"
I can't figure out how to return true/false correctly, because:
A URI encoded link will have %HEX for special characters like " " (space)
A non URI-encoded link can also contain "%" which messes up my pattern.
I tried to do these 2 steps but failed:
find if there are any special characters without "%" in a string (return false early)
find if "%" has a valid syntax (return false/true)
I have also searched google and your subreddit for it. No answers....
https://redd.it/1jgsmxf
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
How do I create a website using HTML, CSS, & Lua?
I have tried EVERYTHING, Lapis, OpenResty, Luasocket, LuaJit, Luarocks, EVERYTHING, but NOTHING will work, I just want an index.lua file, with embedded HTML & CSS, & then I can use Lua as the back-end stuff such as button clicking.
I don't get it, why does it work for EVERYBODY but me.
I am on Windows-11, & I use Visual Studio Code.
https://redd.it/1jgtoye
@r_lua
I have tried EVERYTHING, Lapis, OpenResty, Luasocket, LuaJit, Luarocks, EVERYTHING, but NOTHING will work, I just want an index.lua file, with embedded HTML & CSS, & then I can use Lua as the back-end stuff such as button clicking.
I don't get it, why does it work for EVERYBODY but me.
I am on Windows-11, & I use Visual Studio Code.
https://redd.it/1jgtoye
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Run other lua noscripts without knowing the name
Hi, so i’m making a lua noscript and it has a gui, and i want to make it so people can make addons for that gui, people keep saying it’s risky or they wouldn’t do it, they don’t even give a tip on how to do it, can anyone help?
https://redd.it/1jgvzl9
@r_lua
Hi, so i’m making a lua noscript and it has a gui, and i want to make it so people can make addons for that gui, people keep saying it’s risky or they wouldn’t do it, they don’t even give a tip on how to do it, can anyone help?
https://redd.it/1jgvzl9
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Making an Game Editor on the iPad
https://www.youtube.com/watch?v=4ohmJjPK46U
https://redd.it/1jhlso1
@r_lua
https://www.youtube.com/watch?v=4ohmJjPK46U
https://redd.it/1jhlso1
@r_lua
YouTube
Game Editor I am coding on my iPad
Should I learn Lua over Python as a non-dev ? (For macro / Scripting in Davinci Resolve)
Hello !
So I'm working with Davinci Resolve on a daily basis and I want to learn how to make my own noscript and macro. Resolve support both Lua and Python, but I don't know which language I should invest my time into. I don't really need to code outside this usecase, so I want to keep things simple and efficient.
I know that both are (relatively) easy to learn and from what I've heard the main advantage of Lua is its speed and simplicity while Python have a bigger community / ecosystem. I might be wrong or miss some elements tho, so I would like to know your opinion or advice !
https://redd.it/1jielaz
@r_lua
Hello !
So I'm working with Davinci Resolve on a daily basis and I want to learn how to make my own noscript and macro. Resolve support both Lua and Python, but I don't know which language I should invest my time into. I don't really need to code outside this usecase, so I want to keep things simple and efficient.
I know that both are (relatively) easy to learn and from what I've heard the main advantage of Lua is its speed and simplicity while Python have a bigger community / ecosystem. I might be wrong or miss some elements tho, so I would like to know your opinion or advice !
https://redd.it/1jielaz
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Fastest way to execute Lua?
Is there any method to execute Lua at it's highest speed?
Right now I'm using Zerobrane studio to execute Lua noscripts. It's very handy.
But it's probably not the fastest way to run it. I wonder if there are any faster methods for running Lua?
https://redd.it/1jif3h5
@r_lua
Is there any method to execute Lua at it's highest speed?
Right now I'm using Zerobrane studio to execute Lua noscripts. It's very handy.
But it's probably not the fastest way to run it. I wonder if there are any faster methods for running Lua?
https://redd.it/1jif3h5
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community