Jump to content
SubSpace Forum Network

Recommended Posts

Posted

Bak could you give me a bit of help with other functions instead of just the display an image tutorial, becouse i got that working fine?

Like for instance 'if a key is pressed do:' functions. And how to work with playerdata.

 

Since i have limited skills in C++, coz i only coded in MERVBot, its kinda irritating to learn this.

You can contact me on msn (look at my profile).

And if you dont have msn.. you may post it here if you want.

 

Thank you,

Witchie NL

Posted

Definately. I'll write up a tutorial soon (most likely tomorrow).

 

The basic idea behind controls, such as ones that involve the keyboard is the controls module:

 

/**
* tell the Controls modules you want a function to be called when a certain control is pressed,
* down is true iff we want the function to be called when the key is pressed down, if it’s false it will be
* called iff the key combo is lifted up.
*
* call this function in your handler for the CB_CONTROLSLOADED callback
*
* @param keyString the keyString cooresponding to the event, as defined in the settings (like "repel")
* @param funcToCall the function to call when the event occurs, down = true iff we're pressing the key combination
*/
void (*regControlEvent)(const char* controlString, void (*funcToCall)(bool down, const char* controlString));

 

now controlString here is specified in a conf file (along with the actual buttons that are needed to be pressed) as in conf/modules/Controls.h:

 

;; This section defines what controls map to what actions
;;; for keyboard controls, use SDLK_ constants minus the SLDK_ when using them 
[Controls]
;;; all of the key bindings in the section
;;; the rest of the section will be in the form of
;;; <name> = <binding> where <name> is one of the ones in this list and <binding> is a list of keys (the SDLK_ constants without the SDLK_ part)
;;; these can include + to use multiple keys to active this command, as in "repel = LSHIFT + LCTRL, RSHIFT + LCTRL"
Names = menu_toggle, menu_quit, menu_fps, specUp, specDown, specLeft, specRight, specFast, toggleCursor, chat_toggle, chat_left, chat_right, chat_ignore_modifier, chat_send_message, moveForward, moveBackward, turnLeft, turnRight, repel, burst, decoy, thor, brick, rocket, portal, gun, bomb, mine, stealth, cloak, xradar, antiwarp, playerlist change view, playerlist up, playerlist down

; from SpecMode module
;;; move up while spectating
specUp = UP
;;; move down while spectating
specDown = DOWN
;;; move left while spectating
specLeft = LEFT
;;; move right while spectating
specRight = RIGHT
;;; move quickly modifier for spectating, to be used in conjunction with specUp, specDown, specLeft, or specRight
specFast = RSHIFT,  LSHIFT

; from EscapeBox module
;;; toggle the escape menu
menu_toggle = ESCAPE
;;; the quit key while the escape menu is active
menu_quit = Q

...

 

As for per player data, look at the do!@#$%^&*entation in Modules/PerPlayerData/PerPlayerData.h, I'll get a tutorial on this one too.

×
×
  • Create New...