Closed srichand2095 closed 1 year ago
Hi!
In terms of Godot functionality, you do stuff in Lua scripts the same way that you would in GDScript or C#, you just have to use the right objects/methods.
The different stuff is just the language. For example, in Lua, to call methods in the script instance, you have to use self:<your method name>(...)
instead of just <your method name>(...)
. To access properties, you need to use self.<your property name>
instead of just <your property name>
.
Check out Godot's documentation for more information on how to handle inputs (including keyboard and mouse): https://docs.godotengine.org/en/stable/tutorials/inputs/index.html
For example, here is a transcript in Lua of the first code sample from the "Events versus polling" section of the "Input examples" documentation (https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#events-versus-polling):
-- NOTE: just like the example in GDScript, this example assumes you
-- have the rest of the script's class defined, like the `jump` method,
-- `position` and `speed` properties
function MyClass:_input(event)
if event:is_action_pressed("jump") then
self:jump()
end
end
function MyClass:_physics_process(delta)
if Input:is_action_pressed("move_right") then
self.position.x = self.position.x + self.speed * delta
end
end
hey i still have some issues can please send a demo if you don't mind.
On Wed, 16 Mar 2022 at 18:27, Gil Barbosa Reis @.***> wrote:
Hi! In terms of Godot functionality, you do stuff in Lua scripts the same way that you would in GDScript or C#, you just have to use the right objects/methods. The different stuff is just the language. For example, in Lua, to call methods in the script instance, you have to use self:<your method name>(...) instead of just
(...). To access properties, you need to use self. instead of just <your property name>. Check out Godot's documentation for more information on how to handle inputs (including keyboard and mouse): https://docs.godotengine.org/en/stable/tutorials/inputs/index.html
For example, here is a transcript in Lua of the first code sample from the "Events versus polling" section of the "Input examples" documentation ( https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#events-versus-polling ):
-- NOTE: just like the example in GDScript, this example assumes you-- have the rest of the script's class defined, like the
jump
method,--position
andspeed
propertiesfunction MyClass:_input(event) if event:is_action_pressed("jump") then self:jump() endend function MyClass:_physics_process(delta) if Input:is_action_pressed("move_right") then self.position.x = self.position.x + self.speed * delta endend— Reply to this email directly, view it on GitHub https://github.com/gilzoide/godot-lua-pluginscript/issues/21#issuecomment-1069098344, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARS4H2CIJ2BCMMBFELPYCKLVAHLCZANCNFSM5QYAGXOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
You'll have to be more specific with what you're trying to make. I could make a demo, but it might not do exactly what you're trying to do, since Godot has more than one way of handling input and each project has their own requirements.
hi thanks for helping me out.i am a beginner and i have may doubts. i will reach out if anything goes wrong. i am thankful.
On Wed, 16 Mar 2022 at 18:27, Gil Barbosa Reis @.***> wrote:
Hi! In terms of Godot functionality, you do stuff in Lua scripts the same way that you would in GDScript or C#, you just have to use the right objects/methods. The different stuff is just the language. For example, in Lua, to call methods in the script instance, you have to use self:<your method name>(...) instead of just
(...). To access properties, you need to use self. instead of just <your property name>. Check out Godot's documentation for more information on how to handle inputs (including keyboard and mouse): https://docs.godotengine.org/en/stable/tutorials/inputs/index.html
For example, here is a transcript in Lua of the first code sample from the "Events versus polling" section of the "Input examples" documentation ( https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#events-versus-polling ):
-- NOTE: just like the example in GDScript, this example assumes you-- have the rest of the script's class defined, like the
jump
method,--position
andspeed
propertiesfunction MyClass:_input(event) if event:is_action_pressed("jump") then self:jump() endend function MyClass:_physics_process(delta) if Input:is_action_pressed("move_right") then self.position.x = self.position.x + self.speed * delta endend— Reply to this email directly, view it on GitHub https://github.com/gilzoide/godot-lua-pluginscript/issues/21#issuecomment-1069098344, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARS4H2CIJ2BCMMBFELPYCKLVAHLCZANCNFSM5QYAGXOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
No problem! ^^
hey how can i get input from keyboard and mouse.