Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Expression 2 v
« Previous 1 … 4 5 6 7 8 Next »
HELP: EGP Buttons
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
HELP: EGP Buttons
17-06-2014, 03:37 PM,
#4
Blackhawk Offline
GMod Admin
Posts: 204
Threads: 9
Joined: Sep 2013
RE: HELP: EGP Buttons
Don't forget to put your button function into "if(first() | changed(EGP)){}"

Here's a small Touch Screen Tutorial, it should help you:

Code:
@name EGP Touchscreen Tutorial @inputs EGP:wirelink @outputs @persist User:entity Cursor:vector2 Use B @trigger ##How to use the button() function by Link320 ##(Actually it's more of a 'the cursor is over this object' function, it doesn't actually make buttons) #We need an interval, or runOnTick(1), so that the E2 runs without you changing an input. interval(100) if(first() | changed(EGP)){ EGP:egpClear() #Define the function. function number wirelink:button(Cursor:vector2,ID:number){ local BPos = This:egpPos(ID) local BSize = This:egpSize(ID)/2 local Pressed = inrange(Cursor,BPos-BSize,BPos+BSize) return Pressed } #Create the box. This is going to be my button. Its index is 1. We create this before running EGP:button() EGP:egpBox(1,vec2(256, 180),vec2(128)) EGP:egpBox(2,vec2(256, 350),vec2(128)) } #Get the person using the screen User = EGP["User",entity] #Get the position of their cursor on the screen Cursor = EGP:egpCursor(User) #Get whether the person is pressing use Use = User:keyUse() #If I press use on the screen... if(changed(Use) & Use){ if(EGP:button(Cursor,1)){ soundPlay(1,0,"/ancient_button1.wav") } elseif(EGP:button(Cursor,2)){ B = !B #Note that B is in persists Color = B ? vec(200,0,0) : vec(255) # ^If you haven't come across this before, this is short for "if(B){vec(200,0,0)} else{vec(255)}" EGP:egpColor(2,Color) } }
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
HELP: EGP Buttons - by Alanzote - 17-06-2014, 01:36 AM
RE: HELP: EGP Buttons - by Cobra - 17-06-2014, 08:45 AM
RE: HELP: EGP Buttons - by Alanzote - 17-06-2014, 01:27 PM
RE: HELP: EGP Buttons - by Blackhawk - 17-06-2014, 03:37 PM
RE: HELP: EGP Buttons - by Alanzote - 17-06-2014, 04:56 PM

  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.