![]() |
|
HELP: EGP Buttons - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html) +--- Forum: Expression 2 (https://teamscm.co.uk/forum-6.html) +--- Thread: HELP: EGP Buttons (/thread-359.html) |
HELP: EGP Buttons - Alanzote - 17-06-2014 I am trying to make EGP Buttons, I've based myself on BL4CKH4WK Ship Stats E2 Buttons but, It wasn't worked! Can someone give a base code for me? RE: HELP: EGP Buttons - Cobra - 17-06-2014 Show us what you have tried so far RE: HELP: EGP Buttons - Alanzote - 17-06-2014 (17-06-2014, 08:45 AM)Cobra Wrote: Show us what you have tried so farHere is the code If you noticed, I've copied the function! But I'll not post this E2 on this forum!)Code: ####FUNCTIONS#####
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
}
function click()
{
E:entity():soundPlay(1,20,"(SOMETHING)")
}
###BUTTON#########
User = E["User",entity]
Cursor = E:egpCursor(User)
Use = User:keyUse()
if(changed(Use) & Use)
{
click()
if(E:button(Cursor,10))
{
E:egpClear()
}
}RE: HELP: EGP Buttons - Blackhawk - 17-06-2014 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)
}
}RE: HELP: EGP Buttons - Alanzote - 17-06-2014 (17-06-2014, 03:37 PM)_BL4CKH4WK Wrote: Don't forget to put your button function into "if(first() | changed(EGP)){}"Thanks Bl4 It worked! |