From 7b2556bd8c97986145d82d7c1dd80e78ed278e98 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 5 Jun 2022 14:42:18 +0200 Subject: [PATCH] Update mouseEvents.md --- docs/events/mouseEvents.md | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/docs/events/mouseEvents.md b/docs/events/mouseEvents.md index f40d13b..d113114 100644 --- a/docs/events/mouseEvents.md +++ b/docs/events/mouseEvents.md @@ -61,39 +61,3 @@ function buttonOnScroll() end button:onScroll(buttonOnScroll) ``` - -# Beginner Tips - -## 1 -Not everyone knows that a function (or in other words a method) does not need to have a name. Instead of a function name you are also able to add the function itself as a argument. - -Both do the exact same thing: -```lua -local function clickButton() - basalt.debug("I got clicked!") -end -button:onClick(clickButton) -``` - -```lua -button:onClick(function() - basalt.debug("I got clicked!") -end) -``` - -## 2 -there is also a function with which you can check if the user is holding a key down, it is called `basalt.isKeyDown()`. It's especially useful for click events. -Let us say you want a button to execute something, but if you are holding ctrl down, something in the execution should get changed. This is how you would -achieve that: - -```lua -button:onClick(function() - if(basalt.isKeyDown(keys.leftCtrl)then - basalt.debug("Ctrl is down!") - else - basalt.debug("Ctrl is up!") - end -end) -``` - -Make sure to always use the available `keys` table: https://computercraft.info/wiki/Keys_(API)