Native UI API
The Native UI API provides functions for interacting with the game's user interface elements in Schedule 1. This includes displaying notifications, showing dialog boxes, and managing in-game messages.
Implementation Status: Partially implemented. Basic functionality works, but some advanced features are still in development.
Overview
The Native UI API focuses on built-in game UI elements that allow your script to communicate with the player. For custom UI elements (windows, controls, styling), please refer to the Custom UI API.
Available Functions
Notifications
ShowNotification(title, message)
- Shows a notification with title and messageShowNotificationWithIcon(title, message, iconPath)
- Shows a notification with a custom iconShowNotificationWithTimeout(message, timeout)
- Shows a notification with a custom timeoutShowNotificationWithIconAndTimeout(title, message, iconPath, timeout)
- Shows a notification with both an icon and timeout
Dialogs
ShowDialogue(title, text)
- Shows a dialogue box with a title and textShowDialogueWithTimeout(title, text, timeout)
- Shows a dialogue box that disappears after a specified timeShowChoiceDialogue(title, text, choices, callback)
- Shows a dialogue with choicesCloseDialogue()
- Closes the current dialogueSetCustomerDialogue(npcId, newText)
- Sets dialogue text for a Customer NPCSetDealerDialogue(npcId, newText)
- Sets dialogue text for a Dealer NPCSetShopDialogue(npcId, newText)
- Sets dialogue text for a ShopWorker NPC
Phone UI
IsPhoneOpen()
- Checks if the phone UI is currently openOpenPhone()
- Opens the in-game phone interfaceClosePhone()
- Closes the in-game phone interfaceTogglePhoneFlashlight()
- Toggles the phone flashlightIsPhoneFlashlightOn()
- Checks if the phone flashlight is on
Tooltips
ShowTooltip(text, x, y, worldspace)
- Shows a tooltip at specified position
UI Items
GetHoveredItemName()
- Gets the name of the item currently being hoveredIsItemBeingDragged()
- Checks if an item is currently being dragged
Storage Entities
CreateStorageEntity(name, slotCount, rowCount)
- Creates a storage entity with specified slotsOpenStorageEntity(entityId)
- Opens a storage entity UICloseStorageEntity(entityId)
- Closes a storage entity UIAddItemToStorage(entityId, itemId, quantity)
- Adds an item to a storage entityGetStorageItems(entityId)
- Gets all items in a storage entityIsStorageOpen(entityId)
- Checks if a storage entity is openSetStorageName(entityId, name)
- Sets the name of a storage entitySetStorageSubtitle(entityId, subtitle)
- Sets the subtitle of a storage entityClearStorageContents(entityId)
- Clears all items from a storage entityGetStorageEntityCount()
- Gets the total number of storage entities created
Custom GUI
CreateWindow(id, title, x, y, width, height)
- Creates a new windowSetWindowPosition(windowId, x, y)
- Sets window positionSetWindowSize(windowId, width, height)
- Sets window sizeShowWindow(windowId, visible)
- Shows or hides a windowIsWindowVisible(windowId)
- Checks if a window is visibleDestroyWindow(windowId)
- Destroys a window
Controls
AddButton(windowId, id, text, callback)
- Adds a button to a windowAddLabel(windowId, id, text)
- Adds a label to a windowAddTextField(windowId, id, text)
- Adds a text field to a windowGetControlText(controlId)
- Gets the text of a controlSetControlText(controlId, text)
- Sets the text of a controlSetControlPosition(controlId, x, y)
- Sets control positionSetControlSize(controlId, width, height)
- Sets control sizeShowControl(controlId, visible)
- Shows or hides a controlDestroyControl(controlId)
- Destroys a control
UI Style Functions
SetWindowStyle(colorName, r, g, b, a)
- Sets window style colorsSetButtonStyle(colorName, r, g, b, a)
- Sets button style colorsSetLabelStyle(colorName, r, g, b, a)
- Sets label style colorsSetTextFieldStyle(colorName, r, g, b, a)
- Sets text field style colorsSetBoxStyle(colorName, r, g, b, a)
- Sets box style colorsSetFontSize(styleName, size)
- Sets the font size for a UI element styleSetFontStyle(styleName, fontStyle)
- Sets the font style for a UI elementSetTextAlignment(styleName, alignment)
- Sets the text alignment for a UI elementSetBorder(styleName, left, right, top, bottom)
- Sets the border for a UI element styleSetPadding(styleName, left, right, top, bottom)
- Sets the padding for a UI element style
Global UI Functions
EnableGUI(enable)
- Enables or disables GUI renderingIsGUIEnabled()
- Checks if GUI is enabled
Example Usage
Basic Notification
lua
function OnPlayerReady()
-- Show a simple welcome notification
ShowNotification("Welcome", "Welcome to my custom script!")
-- Show an energy warning when energy is low
if GetPlayerEnergy() < 20 then
ShowNotification("Warning", "Low energy!")
end
return true
end
-- Notification that disappears after 5 seconds
function OnPlayerHealthChanged(newHealth)
if newHealth < 50 then
ShowNotificationWithTimeout("Your health is low!", 5.0)
end
end
Interactive Dialog
lua
function OfferPlayerChoice()
local choices = {
"Accept the quest",
"Decline",
"Ask for more information"
}
ShowChoiceDialogue(
"New Quest Available",
"A stranger needs your help finding a lost item. Will you help?",
choices,
function(choiceIndex)
if choiceIndex == 1 then
ShowNotification("Quest", "Quest accepted!")
StartQuest()
elseif choiceIndex == 2 then
ShowNotification("Quest", "Quest declined.")
elseif choiceIndex == 3 then
ShowDialogue(
"Quest Details",
"The stranger lost a valuable watch somewhere in the Downtown area. " ..
"They will pay you 100 credits if you can find it."
)
-- Ask again after showing more info
Wait(3.0, function()
OfferPlayerChoice()
end)
end
end
)
end
-- Register a command to start the dialogue
RegisterCommand("quest", "Starts a sample quest dialogue", "quest", function(args)
OfferPlayerChoice()
end)
Custom Window UI
lua
function CreateInventoryUI()
-- Create main window
local windowId = CreateWindow("inventory", "Player Inventory", 100, 100, 400, 300)
-- Add title and instructions
AddLabel(windowId, "title", "Manage your items")
SetControlPosition("title", 150, 30)
-- Add a button to close the window
AddButton(windowId, "closeBtn", "Close", function()
ShowWindow(windowId, false)
end)
SetControlPosition("closeBtn", 150, 250)
-- Show the window
ShowWindow(windowId, true)
return windowId
end
-- Register a command to toggle the inventory UI
RegisterCommand("inventory", "Shows inventory UI", "inventory", function(args)
if IsWindowVisible("inventory") then
ShowWindow("inventory", false)
else
if not _G.inventoryWindowId then
_G.inventoryWindowId = CreateInventoryUI()
else
ShowWindow(_G.inventoryWindowId, true)
end
end
end)
Best Practices
- User experience: Keep notifications brief and only show when necessary
- Dialog usage: Use dialogs for important information that requires attention
- Avoid spam: Don't overuse notifications, as they can become annoying
- Timeouts: Consider using timed notifications for transient information
- Clear dialogs: Always close dialogs when they're no longer needed
- Resource management: Destroy windows and controls when no longer needed
Explore the sections in the sidebar for detailed documentation of each function.