Lua Tutorial not working. Am i doing something wrong?

0

Hello,

I'm doing the tutorial one by one but now I'm stuck for several hour on one of the component tutorials with lua scripting. I've done all according to the tutorial documentation but it does not work. This is the code in the tutorial:

local trigger_test =

{

properties =

{

}

}

function trigger_test:OnActivate()

self.TriggerBusHandler = TriggerAreaNotificationBusHandler:Connect(self, self.entityId);

end

function trigger_test:OnTriggerAreaEntered(enteringEntityId)

Debug.Log("[TRIGGER] Entity ".. tostring(enteringEntityId) .." ENTERED");

end

function trigger_test:OnTriggerAreaExited(exitingEntityId)

Debug.Log("[TRIGGER] Entity ".. tostring(exitingEntityId) .." EXITED");

end

function trigger_test:OnDeactivate()

self.triggerBusHandler:Disconnect();

end

return trigger_test

However when I try to launch it, it comes up with the error: "[Error] Lua error (2 - scripts/testscripts/trigger_test.luac:9: attempt to index global 'TriggerAreaNotificationBusHandler' (a nil value)) during call to OnActivate". I know what it means but since I dont know much about scripting i dont know how to fix this. Can anyone help?

asked 7 years ago513 views
31 Answers
0
Accepted Answer

Hey @REDACTEDUSER

REMOVEDUPLOAD

Let us know if this fixes it :)

Cheers!

answered 7 years ago
profile picture
EXPERT
reviewed a month ago
0

@REDACTEDUSER

"It looks like the problem could be the Lua basics structure. It's missing a comma after the closing bracket of Properties. Also looks like the "P" in Properties sub-table isn't capitalized. These are crucial for lua to function."

Can you try that?

answered 7 years ago
0

Ok I finely found a solution. It turns out you need to have the script in the location where lua is and as well in the project folder. Eg.:

c:\Amazon\Lumberyard\1.7.0.1\dev\Bin64vc120\

and

c:\Amazon\Lumberyard\1.7.0.1\dev\Cache\SamplesProject\pc\samplesproject\scripts\

don't know how to make it so that you only need one location though, but now its outputting this:

[TRIGGER] Entity [17156986295506254569] ENTERED

[TRIGGER] Entity [17156986295506254569] EXITED

Lua error (2) during call trigger_test:OnDeactivate: [string "c:/amazon/lumberyard/1.7.0.1/dev/samplespro..."]:21: attempt to index field 'triggerBusHandler' (a nil value)

[Error] Lua error (2) during call trigger_test:OnDeactivate: [string "c:/amazon/lumberyard/1.7.0.1/dev/samplespro..."]:21: attempt to index field 'triggerBusHandler' (a nil value)

so there is one more error i need to find a solution for. Any ideas?

answered 7 years ago
0

Have you tried to use just the .lua file? The .luac file is just a precompiled version and I don't think renaming it will work.

http://docs.aws.amazon.com/lumberyard/latest/developerguide/lua-scripting-ces.html

answered 7 years ago
0

Thank you for the fast response. I hope so i see more scripting stuff in the next tutorial and they all seem to have some error. I already browsed the net to try and find a solution but nothing has worked so far.

answered 7 years ago
0

Is it possible that I'm missing some kind of a plugin?

answered 7 years ago
0

One thing that I forgot to mention is that Lua makes files with .lua but lumberyard wants files with .luac. I have just been renaming them so dont know if that could also cause the issue.

answered 7 years ago
0

Well i checked and all should be installed OK. I even restarted the whole lumberyard engine and opened a clean map and redone the whole process but still the same result:

Error] Lua error (2 - scripts/triggertest.luac:9: attempt to call field 'connect' (a nil value)) during call to OnActivate

and

[Error] Lua error (2) during call to OnDeactivate: scripts/triggertest.luac:21: attempt to index field 'triggerBusHandler' (a nil value)

answered 7 years ago
0

Yop i tried to use the .lua file but lumberyard just has one option of files to choose and its .luac. I'm trying to reinstall the whole engine see if it helps

answered 7 years ago
0

Ok so i reinstalled lumberyard 1.8 but same problem and still lumberyard wants only files with .luac and does not let me to select others. So i installed lumberyard 1.7 and there it is ok and accepts .lua. the lest problem im now facing is:

Can't load the script with invalid asset (not loaded or null)!

the current script i have there is:

triggertest =

{

}

function triggertest:OnActivate()

self.triggerBusHandler = triggerAreaNotificationBusHandler.connect(self, self.entityId)

end

function triggertest:OnTriggerAreaEntered(enteredEntityId)

Debug.Log("[Trigger]Entity ".. tostring(enteredEntityId) .." Entered")

end

function triggertest:OnTriggerAreaEnxited(exitedEntityId)

Debug.Log("[Trigger]Entity ".. tostring(enxitedEntityId) .." Enexited")

end

function triggertest:OnDeactivate()

self.triggerBusHandler:Disconnect()

end

so what am i doing wrong now? :D

answered 7 years ago
0

Well i reinstalled lumberyard and now im having the same issues and nothing helps at the moment

answered 7 years ago
0

Sorry to hear you are having issues with the tutorial. I'm filing a ticket to have someone take a look and help. Just a heads up that with GDC this week, support may be a little slower than normal. Hopefully someone here in the community can answer in the meantime.

answered 7 years ago
0

That is very odd. I haven't seen any other people reporting issues. I'll add that to the ticket.

answered 7 years ago
0

It is possible. You might want to run Setup Assistant and made sure all the SDKs and plugins have the green check.

answered 7 years ago
0

Tryed that alraedy but i can try again.

answered 7 years ago
0

No joy still same errors:

Access to undeclared global variable 'triggerAreaNotificationBusHandler'!---------- START STACK TRACE ---------- =C: ?:/amazon/lumberyard/1.7.0.1/dev/samplesproject/scripts/components/triggertest.lua(9): ? ---------- END STACK TRACE ----------

[Error] Access to undeclared global variable 'triggerAreaNotificationBusHandler'!---------- START STACK TRACE ---------- =C: ?:/amazon/lumberyard/1.7.0.1/dev/samplesproject/scripts/components/triggertest.lua(9): ? ---------- END STACK TRACE ----------

Lua error (2 - [string "c:/amazon/lumberyard/1.7.0.1/dev/samplespro..."]:9: attempt to index global 'triggerAreaNotificationBusHandler' (a nil value)) during call triggertest:OnActivate

[Error] Lua error (2 - [string "c:/amazon/lumberyard/1.7.0.1/dev/samplespro..."]:9: attempt to index global 'triggerAreaNotificationBusHandler' (a nil value)) during call triggertest:OnActivate

Lua error (2) during call triggertest:OnDeactivate: [string "c:/amazon/lumberyard/1.7.0.1/dev/samplespro..."]:21: attempt to index field 'triggerBusHandler' (a nil value)

[Error] Lua error (2) during call triggertest:OnDeactivate: [string "c:/amazon/lumberyard/1.7.0.1/dev/samplespro..."]:21: attempt to index field 'triggerBusHandler' (a nil value)

answered 7 years ago
0

One more thing though. When i save a script for the first time it comes with the warning: "Performance is down. File will be saved. You must reconcile with performance later!"

answered 7 years ago
0

Hello,

I'm having similar troubles with the same tutorial. I have very little knowledge of coding and scripting so I don't even know where to look at.

The error I get is "The script asset 0xddd88d20 doesn't contain a table with name trigger_test"

I also sometimes get the "Perforce is down!..." -error message.

Any suggestions?

answered 7 years ago
0

"The script asset 0xddd88d20 doesn't contain a table with name trigger_test"

means that the script dosnt have a variable (all complex lua variables are tables really) named: "trigger_test" make sure the top line is "trigger_test" all capitalized correctly and that it matches the same name on the file.

answered 7 years ago
0

I got that same issue today, I found out that creating a new lua file and not putting "local" on the top table (so "trigger_test") works for me.

answered 7 years ago
0

@REDACTEDUSER the first error you are getting is because the main table, eg.:

trigger_test =

{

}

must also be the name of the lua script, eg.: trigger_test.lua

If you are using the 1.7 version of the engine you can not have local trigger_test in the script just trigger_test

answered 7 years ago
0

I need help with this too. I cannot attach a script because I can't get anything other than .lua scripts but the Lua Script component won't let me attach anything but a .luac file.

answered 7 years ago
0

@REDACTEDUSER

any news?

answered 7 years ago
0

Ok I just reinstalled my whole Win 10 system, installed lumberyard 1.8 and still same issue:

Warning] Access to undeclared global variable 'TriggerAreaNotificationBusHandler'---------- START STACK TRACE ---------- =C: ?scripts/trigger_test.luac(9): ? ---------- END STACK TRACE ----------

Lua error (2 - scripts/trigger_test.luac:9: attempt to index global 'TriggerAreaNotificationBusHandler' (a nil value)) during call to OnActivate

[Error] Lua error (2 - scripts/trigger_test.luac:9: attempt to index global 'TriggerAreaNotificationBusHandler' (a nil value)) during call to OnActivate

general.exit_game_mode

Returned:

general.clear_selection

Returned: 1

general.exit_game_mode

Returned:

Lua error (2) during call to OnDeactivate: scripts/trigger_test.luac:21: attempt to index field 'triggerBusHandler' (a nil value)

[Error] Lua error (2) during call to OnDeactivate: scripts/trigger_test.luac:21: attempt to index field 'triggerBusHandler' (a nil value)

Enable Accelerators

At this point there is one last thing that comes to mind that i could do but i don't think that it will help. Im thinking of downloading the latest Lua script and overwriting the one in the engine but i think this bug comes from the Engine itself not the script. Anyone else has some idea what i could do here?

answered 7 years ago
0

actually tried that already as i suspected it at one point but let me try again. Though is it ok when i rewrite the file from .lua to .luac? cause when i want to open a script from the engine in the entity inspector it only allowes me to choose .luac

answered 7 years ago
0

IT WOOOOOOORKEEEEEEDDDDD!!!!! finally after a week i can go on! :D :D

answered 7 years ago
0

Sure will thanks again. I think that reinstalling the Win 10 helped too as i had U4 engine installed before and as i mentioned i tried it without the "Handler" before with no luck. But at least its working now so thanks you ever so much!

answered 7 years ago
0

Excellent!! Again, sorry for this issue — we'll update the Lua tutorial as fast as humanly possible :)

There is a strange event happening with the extension names. We save the files as .lua but the editor actually stores it as .luac. This is basically the compiled format of the .lua file. This compile process occurs in Asset Processor when it detects the new / updated version of said .lua file. There shouldn't be an issue with saving the extension out as .lua if you're using an external lua editor. But if you do come across any bugs like that, please let us know!

Cheers!

answered 7 years ago
0

Ignore: Looks like you got it working. Awesome!

answered 7 years ago
0

Hi now i have a problem in the tutorial with Tags :D. its giving me the error:

[Warning] Lua execute error (2) on EBus (TickBus): trying to bind to a non-table value : scripts/tutorial_tag.luac:24: attempt to get length of local 'DynamicTaggedEntities' (a userdata value)---------- START STACK TRACE ---------- ---------- END STACK TRACE ----------

the 2 boxes scale correctly on the Z axis as they should however they do not scale on the Y axis

answered 7 years ago
0

Are you still getting this error? It might be better to start a new thread. @REDACTEDUSER

answered 7 years ago

This post is closed: Adding new answers, comments, and votes is disabled.