Search the Community
Showing results for tags 'button'.
-
Hello everyone. After some frustrations, I've decided to give up and open a post here in hope I could get some help. I would like to make a button which needs to stay pressed for x sec / ms before calling its output. I don't know what my problem is, the script in itself is not complicated, but it seems I can't make it work... If you don't understand what I mean I made a little video which I hope will help you see the goal. rotbuttondemo.mp4 Another video of this kind of action can be found in this video at around 57 sec: I don't really care for the rotation of the button at the moment. I know the math and could easily implement it later. What I'm really interested in is the delay before the output and the detection of the player pressing the button. I've tried using the default button script and the trigger delay script but with no success. I could give you a scrap of code I made if it can help. Script.cleaningtime = 5000 --int "Cleaning time (ms)" function Script:Start() self.enable = true cleantimeleft=0 end function Script:Use() cleantimeleft = Time:GetCurrent() + self.cleaningtime while(window:KeyDown(Key.E))do --while the player is holding its use key down if Time:GetCurrent()>cleantimeleft and self.enable then System:Print("Clean!") self.component:CallOutputs("Used") end end end I don't know what I'm missing out. Whenever I try this the game freezes until the player release the use key... Anyway, thank you very much for the help.
- 6 replies
-
- timer
- help needed
-
(and 2 more)
Tagged with:
-
Hi, I was wondering that I couldn't find any tutorial about creating simple UI elements. I searched the web and the forum for a while, and because I couldnt find anything useful I started this thread. The problem is I dont get how to check whether my mouse cursor is hovering over an element or not. To give you an more exact example: I just finished a simple inventory generation system where you can choose how many columns and slots it has and some other stuff. This works very well. However now I want to implement that, if you click on one of the items collected and shown in the inventory, that they get used/activated. The method I know from previous game developing experience is that you cast a ray from your camera origin through the mouse position and grab the UI elements which get intersected. My questions so far: Info: I only code in LUA. - How to check if my mouse hovers an context object (for example an image drawn with context:DrawImage()) - How to unlock my mouse so that I can move it around freely You would do me a great favor, if you tell me how this works in Leadwerks. Phoenix