TheKkubas Posted June 23, 2015 Share Posted June 23, 2015 Hi. i'm new to Leadwerks and I started scrpiting in lua. When i try to make basic controller i discovered that bug (or my mistake). Here is one of scripts which i (try to) make. Script.player = "" --entity "Player" function Script:Start() end function Script:Update() if window:KeyDown(Key.D) then print("D Pressed") right() end end function Script:right() ppos = self.player:GetPosition() self.player:SetPosition(ppos+Vec3(3,0,0)) end When it launched i didn't get any console replys about pressed D and my character didn't move. At the end sorry for my English. That text could have errors. Quote Link to comment Share on other sites More sharing options...
diedir Posted June 23, 2015 Share Posted June 23, 2015 Hi sorry if i am wrong but isnt it "KEY_D" with underscore ? (not the dot .) edit: i feel so old, now... Quote AMD Ryzen 5900HX - Nvidia RTX 3070 - 32 Go - 1To SSD - W11 Link to comment Share on other sites More sharing options...
macklebee Posted June 23, 2015 Share Posted June 23, 2015 Hi sorry if i am wrong but isnt it "KEY_D" with underscore ? (not the dot .) No that was how keys were defined in LE2. As for the OP's issues: - the function is 'Script:UpdateWorld()' not 'Script:Update()' - the command to print in the LE log is 'System:Print()' not 'print()' - the function is 'right()' not 'Script:right()' or vice versa - need to pass the 'self.player' to the 'right()' function if used instead of 'Script:right()' function example lua code: Script.player = "" --entity "player" function Script:Start() end function Script:UpdateWorld() window = Window:GetCurrent() if window:KeyHit(Key.D) then System:Print("D Pressed") right(self.player) end end function right(player) ppos = player:GetPosition() player:SetPosition(ppos+Vec3(3,0,0)) end Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
TheKkubas Posted June 24, 2015 Author Share Posted June 24, 2015 No that was how keys were defined in LE2. As for the OP's issues: - the function is 'Script:UpdateWorld()' not 'Script:Update()' - the command to print in the LE log is 'System:Print()' not 'print()' - the function is 'right()' not 'Script:right()' or vice versa - need to pass the 'self.player' to the 'right()' function if used instead of 'Script:right()' function example lua code: Script.player = "" --entity "player" function Script:Start() end function Script:UpdateWorld() window = Window:GetCurrent() if window:KeyHit(Key.D) then System:Print("D Pressed") right(self.player) end end function right(player) ppos = player:GetPosition() player:SetPosition(ppos+Vec3(3,0,0)) end Thank you very much. Script worked but i must fix some bugs (I can do it alone). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.