Instructional Buttons

Instructional Buttons, also known as Prompts are UI elements that are displayed at the bottom-right corner of the screen, which show what actions certain keys and controls can do. You can make them clickable with your cursor, add multiple buttons, icons and much more.

Simple non-clickable buttons example

Lua

CreateThread(function()
	-- Request the buttons GFX to be loaded
	local ButtonsHandle = RequestScaleformMovie('INSTRUCTIONAL_BUTTONS')
	-- Wait for the buttons GFX to be fully loaded
	while not HasScaleformMovieLoaded(ButtonsHandle) do
		Wait(0)
	end

	-- Clear previous buttons
	CallScaleformMovieMethod(ButtonsHandle, 'CLEAR_ALL')
	-- Disable mouse buttons
	CallScaleformMovieMethodWithNumber(ButtonsHandle, 'TOGGLE_MOUSE_BUTTONS', 0)

	-- Begin setting a button slot
	BeginScaleformMovieMethod(ButtonsHandle, 'SET_DATA_SLOT')
	-- Position of the button
	ScaleformMovieMethodAddParamInt(0)
	-- Add the Enter keyboard icon
	ScaleformMovieMethodAddParamPlayerNameString('~INPUT_FRONTEND_ACCEPT~')
	-- Add the text before icon
	ScaleformMovieMethodAddParamPlayerNameString('Select')
	-- End the function
	EndScaleformMovieMethod()
	-- Sets buttons ready to be drawn
	CallScaleformMovieMethod(ButtonsHandle, 'DRAW_INSTRUCTIONAL_BUTTONS')

	local selectPressed = false
	-- Display instructional buttons while enter hasn't been pressed
	while not selectPressed do
		Wait(0)

		-- Draw the instructional buttons this frame
		DrawScaleformMovieFullscreen(ButtonsHandle, 255, 255, 255, 255, 1)

		-- Is Enter just released
		if IsControlJustReleased(2, 201) then
			selectPressed = true

			print('Enter has been pressed!')
		end
	end

	-- Unload the scaleform movie after enter has been pressed
	SetScaleformMovieAsNoLongerNeeded(ButtonsHandle)
end)


Code Result

Simple clickable buttons example

Lua

CreateThread(function()
	-- Request the buttons GFX to be loaded
	-- Note: RequestScaleformMovieInstance prevents the buttons being stretched on wide-screen
	local ButtonsHandle = RequestScaleformMovieInstance('INSTRUCTIONAL_BUTTONS')

	-- Wait for the buttons GFX to be fully loaded
	while not HasScaleformMovieLoaded(ButtonsHandle) do
		Wait(0)
	end

	-- Clear previous buttons
	CallScaleformMovieMethod(ButtonsHandle, 'CLEAR_ALL')
	-- ENABLE mouse buttons
	CallScaleformMovieMethodWithNumber(ButtonsHandle, 'TOGGLE_MOUSE_BUTTONS', 1)

	-- Begin setting a button slot
	BeginScaleformMovieMethod(ButtonsHandle, 'SET_DATA_SLOT')
	-- Position of the button
	ScaleformMovieMethodAddParamInt(0)
	-- Add the Enter keyboard icon
	ScaleformMovieMethodAddParamPlayerNameString('~INPUT_FRONTEND_ACCEPT~')
	-- Add the text before icon
	ScaleformMovieMethodAddParamPlayerNameString('Select')
	-- Note: Adding last 2 SET_DATA_SLOT parameters while TOGGLE_MOUSE_BUTTONS 
	-- is disabled can cause buttons to bug out
	
	-- Whether or not this button can be clicked by the mouse
	ScaleformMovieMethodAddParamBool(true)
	-- Which control will be triggered when this button is clicked by the mouse (INPUT_FRONTEND_ACCEPT in this case)
	ScaleformMovieMethodAddParamInt(201)
	-- End the function
	EndScaleformMovieMethod()

	-- Sets buttons ready to be drawn
	CallScaleformMovieMethod(ButtonsHandle, 'DRAW_INSTRUCTIONAL_BUTTONS')

	local selectPressed = false
	-- Display instructional buttons while enter hasn't been pressed
	while not selectPressed do
		Wait(0)

		-- Show the mouse this frame
		SetMouseCursorActiveThisFrame()

		-- Disable camera moving left and right
		DisableControlAction(0, 1, true)
		-- Disable camera moving up and down
		DisableControlAction(0, 2, true)
		-- Disable attacking by mouse click
		DisableControlAction(0, 24, true)

		-- Draw the instructional buttons this frame
		DrawScaleformMovieFullscreen(ButtonsHandle, 255, 255, 255, 255, 1)

		-- Is Enter just released
		if IsControlJustReleased(2, 201) then
			selectPressed = true

			print('Select has been pressed!')
		end
	end

	-- Disable mouse buttons so they don't bug out for other scripts
	CallScaleformMovieMethod(ButtonsHandle, 'TOGGLE_MOUSE_BUTTONS', 0)
	-- Unload the scaleform movie after enter has been pressed
	SetScaleformMovieAsNoLongerNeeded(ButtonsHandle)
end)

Code Result

Simple buttons with icons example

Lua

CreateThread(function()
	-- Request the buttons GFX to be loaded
	local ButtonsHandle = RequestScaleformMovie('INSTRUCTIONAL_BUTTONS')
	-- Wait for the buttons GFX to be fully loaded
	while not HasScaleformMovieLoaded(ButtonsHandle) do
		Wait(0)
	end

	-- Clear previous buttons
	CallScaleformMovieMethod(ButtonsHandle, 'CLEAR_ALL')

	-- Begin setting a button slot
	BeginScaleformMovieMethod(ButtonsHandle, 'SET_DATA_SLOT')
	-- Position of the button
	ScaleformMovieMethodAddParamInt(0)
	-- Add the arrow up/down icon
	ScaleformMovieMethodAddParamInt(45)
	-- Note: You can add up to 20 keys and icons
	---- Add the text before the icon
	ScaleformMovieMethodAddParamPlayerNameString('Scroll')
	-- End the function
	EndScaleformMovieMethod()

	-- Begin setting a button slot
	BeginScaleformMovieMethod(ButtonsHandle, 'SET_DATA_SLOT')
	-- Position of the button
	ScaleformMovieMethodAddParamInt(1)
	-- Add the loading icon
	ScaleformMovieMethodAddParamInt(50)
	-- Note: You can add up to 20 keys and icons
	---- Add the text before the icon
	ScaleformMovieMethodAddParamPlayerNameString('Loading')
	-- End the function
	EndScaleformMovieMethod()

	-- Sets buttons ready to be drawn
	CallScaleformMovieMethod(ButtonsHandle, 'DRAW_INSTRUCTIONAL_BUTTONS')

	local startedLoading = GetGameTimer()
	-- Display instructional buttons for 3 seconds (3000 ms)
	while GetGameTimer() - startedLoading < 3000 do
		Wait(0)

		-- Draw the instructional buttons this frame
		DrawScaleformMovieFullscreen(ButtonsHandle, 255, 255, 255, 255, 1)
	end

	-- Unload the scaleform movie after enter has been pressed
	SetScaleformMovieAsNoLongerNeeded(ButtonsHandle)
end)


Code Result

Icon list

IDName
0Arrow Up
1Arrow Down
2Arrow Left
3Arrow Right
4Dpad up
5Dpad down
6Dpad left
7Dpad right
8Dpad
9Dpad all
10Dpad up down
11Dpad left right
12Left stick up
13Left stick down
14Left stick left
15Left stick down
16Left stick
17Left stick
18Left stick up down
19Left stick left right
20Left stick clockwise
21Right stick up
22Right stick down
23Right stick left
24Right stick right
25Right stick
26Right stick
27Right stick up down
28Right stick left right
29Right stick clockwise
30A
31B
32X
33Y
34RB
35LT
36RB
37RT
38Start
39Select
40Invalid
41Invalid
42Invalid
43Invalid
44Clockwise Spinner
45Arrow up down
46Arrow left right
47Arrow left right up down
48Clockwise spinner
49Cloud save spinner (Yellow, Clockwise)
50Counter-clockwise spinner

INSTRUCTIONAL_BUTTONS Scaleform Movie Methods

These are all the movie methods you can call on INSTRUCTIONAL_BUTTONS, after they have been requested. You can use scaleform movie method natives (shown above) to call them.

TOGGLE_MOUSE_BUTTONS(bool toggle)
Toggles clickable buttons

SET_SAVING_TEXT(int iconEnum, string saveStr)
Sets a text with loading icon

REMOVE_SAVING()
Removes the loading icon text

CLEAR_ALL()
Clears all instructional button slots

CLEAR_RENDER()
Stops rendering buttons

OVERRIDE_POSITION(float x, float y, bool alignBottomRight)
Overrides buttons' position.

SET_CLEAR_SPACE(float clearSpace)

SET_DATA_SLOT(int index, any icon, string text, bool clickable, int controlIndex)
Adds a button slot. You can add up to 20 icons, those can be either input strings (e.g ~INPUT_FRONTEND_ACCEPT~ for enter) or icon id's.
Note: Make sure to not add last two parameters if TOGGLE_MOUSE_BUTTONS is FALSE to prevent glitchy buttons.

SET_DATA_SLOT_EMPTY()
Alias for CLEAR_ALL()

CLEAR_BACKGROUNDS()
Removes background for the buttons.

DRAW_INSTRUCTIONAL_BUTTONS(int layoutType)
Sets buttons to be drawn.

GET_NUMBER_OF_ROWS()
Returns number of rows. Note: You need to use scaleform movie method return value natives for this.

SET_BACKGROUND()
Adds background.

SET_PADDING(int top, int right, int bottom, int left)

SET_BACKGROUND_COLOUR(int r, int g, int b, int a)
Overrides background colour.

OVERRIDE_RESPAWN_TEXT(int index, string text)
Overrides text for a button.

FLASH_BUTTON_BY_ID(int buttonID, int alpha, int duration)
Flashes a button

SET_MAX_WIDTH(float maxWidth)
Sets max width for buttons. This prevents buttons from being off-screen if there are too many data slots set. Instead, they will stack up.

SET_HIT_AREA_VISIBLE(bool isVisible)
Shows debug hit area for mouse visible. This hit area is used for native 0x3d9acb1eb139e702, which returns wether or not the mouse cursor is above instructional buttons if TOGGLE_MOUSE_BUTTONS is true.