Lua Script not working

0

I am attempting to make my own moving mechanics in my own project (which i have built and added all the gems i desire) and i have the following code: (i have made the Input Mapping files)


local move =
{
Properties =
{
movementSpeed = .03
}
}
function move:OnActivate()
self.forwardId = InputEventNotificationID("Forward")
self.ForwardBus = InputEventNotificationBus.Connect(self, self.forwardId);
self.backwardId = InputEventNotificationID("Backward")
self.BackBus = InputEventNotificationBus.Connect(self, self.backwardId);
self.leftId = InputEventNotificationID("Left")
self.LeftBus = InputEventNotificationBus.Connect(self, self.leftId);
self.rightId = InputEventNotificationID("Right")
self.RightBus = InputEventNotificationBus.Connect(self, self.rightId);
end
function move:OnHeld(floatvalue)
if(InputEventNotificationBus.GetCurrentBusId() == self.forwardId)then
TransformBus.Event.MoveEntity(self.entityId, Vector3(0,self.Properties.movementSpeed,0));
end
end

The problem is that it doesn't work in game and i get these errors:


general.enter_game_mode
Returned:
[Warning] (Cloud Canvas) [Cloud Canvas] Resource manager was invoked but there are no deployments or resource groups.
Disable Accelerators
[Warning] Access to undeclared global variable 'InputEventNotificationID'---------- START STACK TRACE ---------- =[C](-1): ?code/movement.lua(14): ? ---------- END STACK TRACE ----------
code/movement.lua:14: attempt to call global 'InputEventNotificationID' (a nil value)---------- START STACK TRACE ---------- =[C](-1): InputEventNotificationIDcode/movement.lua(14): ? ---------- END STACK TRACE ----------
[Error] code/movement.lua:14: attempt to call global 'InputEventNotificationID' (a nil value)---------- START STACK TRACE ---------- =[C](-1): InputEventNotificationIDcode/movement.lua(14): ? ---------- END STACK TRACE ----------
2 animation-assets loade`
general.exit_game_mode
Returned:
general.exit_game_mode
Returned:
code/movement.lua:42: attempt to index field 'InputEventNotificationBus' (a nil value)---------- START STACK TRACE ---------- =[C](-1): ?code/movement.lua(42): ? ---------- END STACK TRACE ----------
[Error] code/movement.lua:42: attempt to index field 'InputEventNotificationBus' (a nil value)---------- START STACK TRACE ---------- =[C](-1): ?code/movement.lua(42): ? ---------- END STACK TRACE ----------
Enable Accelerators
2 animation-assets loaded (total assets: 1)

and :


Traffic control: We did not received any packets for the last second 1498067124084!
Traffic control: We did not received any packets for the last second 1498067125095!
Traffic control: We did not received any packets for the last second 1498067126072!
Connection 000001892B2C5DF8 rtt 31.41 ms (max. 500.00) and packetLoss 0.32 (max. 0.30). Disconnecting...
[928a9f08] Disconnecting 127.0.0.1|58566 to due to bad traffic conditions!
Disconnect 192.168.0.13|50205 => (127.0.0.1|58566,Bad connection)
Member 000001893D412108(Peer) leaving TM session 000001899230BDC8.
Lost contact with node from member c43b3364.
Disabling debugging for script context(0x0000018967A42578).
Remote debugger LuaIDE has detached from context 0x0000018967A42578.
general.exit_game_mode
Returned:
general.exit_game_mode

What am I doing wrong? Help would be appreciated!

asked 7 years ago171 views
3 Answers
0
Accepted Answer

it should be "InputEventNotificationId" not "InputEventNotificationID"

answered 7 years ago
0

Fixed it! I forgot to use this code for every movement since right now it only does it for forward. Thanks for your help!:


    if(InputEventNotificationBus.GetCurrentBusId() == self.forwardId)then
TransformBus.Event.MoveEntity(self.entityId, Vector3(0,self.Properties.movementSpeed,0));

answered 7 years ago
0

@REDACTEDUSER


code/movement.lua:42: attempt to index field 'InputEventNotificationBus' (a nil value)---------- START STACK TRACE ---------- =[C](-1): ?code/movement.lua(42): ? ---------- END STACK TRACE ----------
[Error] code/movement.lua:42: attempt to index field 'InputEventNotificationBus' (a nil value)---------- START STACK TRACE ---------- =[C](-1): ?code/movement.lua(42): ? ---------- END STACK TRACE ----------
<br>
answered 7 years ago

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