About key command (lua script)

Asked

Viewed 1,225 times

1

Is there any way I can put something in the moon script, so that if I press a key, it will respond with some command? If so, how?

  • In what context? Certainly has but every place that the script used can be a different way.

  • 1

    Like what does LÖVE do? Give more details of your problem.

  • I wanted to make a script for Garry’s mod 13, so I’d like it to answer with a key, such as: if crtl Say hello

  • You have to see the API of this game, it is she who can invoke the script Moon. I don’t even know if the problem is about Moon. As I don’t know the API I can’t help.

  • To clarify a little what others have already said: Lua is a programming language designed to be embedded in larger projects. What usually happens is that a game like Gary’s mod will implement a lot of basic functions in C and make these functions available for you to use from inside the Moon (because programming in Lua is much easier for Modder than C). The standard Lua library is super lean so anything non-trivial you want will have to be via one of these functions that Gary’s mod added to the Lua environment.

1 answer

1

On the platform for creating games called Love 2d it is possible to do this.

Example:

function love.keypressed(key)
    print(string.format("você apertou a letra '%s'", key)
end

Reference: https://love2d.org/wiki/love.keypressed

Browser other questions tagged

You are not signed in. Login or sign up in order to post.