Skip to content

omar-othmann/dev-interaction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 

Repository files navigation

dev-interaction

interaction resource with keyboard keys icons for Alt:V

colors

black
alt text
green
alt text
red
alt text
blue
alt text
yellow
alt text
pink
alt text

function parameters

  • DrawSingleKey client side (key, text, color, position, rtl, timeout, onClick, onDestroyed)

  • DrawSingleKey server side (player, key, text, color, position, rtl, timeout, onClick, onDestroyed)

  • DrawMultipleKey client side (keys, text, color, position, rtl, timeout, onClick, onDestroyed)

  • DrawMultipleKey server side (player, keys, text, color, position, rtl, timeout, onClick, onDestroyed)

example

import * as inter from 'dev-interaction'
inter.DrawSingleKey(inter.KeyCodes.E, 'Open shop', inter.Color.BLUE, inter.Position.TOP_LEFT, false, 30000,
() => {
  console.log('Target key clicked')
},
() => {
  console.log('Timeout or view has replaced with other.')
})

// server side is same like client side but only the first parm should be player example
inter.DrawSingleKey(player, inter.KeyCodes.E, 'Open shop', inter.Color.BLUE, inter.Position.TOP_LEFT, false, 30000,
() => {
  console.log('Target key clicked')
},
() => {
  console.log('Timeout or view has replaced with other.')
})

alt text

// ~key~ to put key image on text position
inter.DrawSingleKey(inter.KeyCodes.E, 'Press ~key~ to open shop', inter.Color.BLACK, inter.Position.TOP_LEFT, false, 30000,
() => { /*clicked*/},() => {/*destroyed or timeout*/})

alt text

// put text before image
inter.DrawSingleKey(inter.KeyCodes.E, 'open shop ~key~', inter.Color.RED, inter.Position.TOP_LEFT, false, 30000,
() => { /*clicked*/},() => {/*destroyed or timeout*/})

alt text

// support rtl
inter.DrawSingleKey(inter.KeyCodes.E, 'أضغط ~key~ لفتح المتاجر', inter.Color.BLACK, inter.Position.TOP_LEFT, true, 30000,
() => { /*clicked*/},() => {/*destroyed or timeout*/})

alt text

multiple keys

const id = inter.DrawMultipleKey([inter.KeyCodes.ArrowUp, inter.KeyCodes.ArrowDown], 'Press some of this keys', inter.Color.BLACK, inter.Position.TOP_LEFT, false, 3000,
(key) => {
  console.log(`key ${key.icon} code: ${key.code} pressed.`) // some of target keys has been pressed.
  // hide it?
  inter.Hide(id)
  // key checker
  if(inter.isEquals(key, inter.KeyCodes.ArrowUp)){
    // arrow up has clicked.
  }
},
() => { /*timeout or destroyed.*/})

alt text

// also we can parse our keys positions.
const id = inter.DrawMultipleKey([inter.KeyCodes.ArrowUp, inter.KeyCodes.ArrowDown], 'Press ~key~ to move up or ~key~ to move down', inter.Color.BLACK, inter.Position.TOP_LEFT, false, 3000,
(key) => {
  console.log(`key ${key.icon} code: ${key.code} pressed.`) // some of target keys has been pressed.
  // hide it?
  inter.Hide(id)
  // key checker
  if(inter.isEquals(key, inter.KeyCodes.ArrowUp)){
    // arrow up has clicked.
  }
},
() => { /*timeout or destroyed.*/})

alt text

// or groub to text position.
const id = inter.DrawMultipleKey([inter.KeyCodes.ArrowUp, inter.KeyCodes.ArrowDown], 'Press some of this keys ~keys~ to do something.', inter.Color.BLACK, inter.Position.TOP_LEFT, false, 3000,
(key) => {
  console.log(`key ${key.icon} code: ${key.code} pressed.`) // some of target keys has been pressed.
  // hide it?
  inter.Hide(id)
  // key checker
  if(inter.isEquals(key, inter.KeyCodes.ArrowUp)){
    // arrow up has clicked.
  }
},
() => { /*timeout or destroyed.*/})

// serve side is also same like client side only first parm should be player
const id = inter.DrawMultipleKey(player, [inter.KeyCodes.E, inter.KeyCodes.F], 'Press ~key~ from server side ~key~ this also', inter.Color.BLACK, inter.Position.TOP_LEFT, false, 3000,
(key) => {
  console.log(inter.isEquals(key, inter.KeyCodes.E))
  inter.Hide(id)
})

alt text

  • q2apro thanks for icons

  • don't forget to install packages by npm for Alt:V client & server side

  • note: you can show key with text without background color. use inter.Color.NONE

About

interaction resource with keyboard keys icon

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published