CHALKBOARD - UI FRAMEWORK (CUIF)
This just a small extension to enable UI customization based on math minigame, you can create some stupid quizzes, collect user preferences, or make some in-game trainer. To be honest, it was actually for my Advanced Trainer Mod, but it also might be useful to Anniversary Edition modders as an alternative way to print something like coordinates or action nodes. So.. i decided to develop some features along with the framework of in-game trainer mod.
(Bully: Scholarship Edition)
(Bully: Anniversary Edition)
HONEST PRINT COMPARISON
(Tested on Bully: Anniversary Edition)
For anyone who have interest using this framework, you have to read a small documentation first!
or see
SInitGl.lur source code.
Print something:
CB_Print(text, timer)
Print any information you may want user to see, can be skipped by clicking the timer or ended once the timer goes off
arguments :
- 1st : string, put any information (ex: "Unfortunately, you suck!")
- 2nd : number, set the timer (ex: 4)
results : none
Example of use:
if IsButtonBeingPressed(2, 0) then
CB_Print("Hello world!", 5)
end
Create Quiz:
CB_Quiz(question table, start from, randomize question)
Create multiple question, up to 4 answer, but only 1 answer can be the true one
arguments :
- 1st : table, must be filled precisely according to the following format
local TABLE = {
{Question = "What year was USA founded?", Answer = 2, Choice = {"1745", "1776", "1811"}},
{Question = "Who is President of USA in 2021?", Answer = 1, Choice = {"Joe Biden", "A. Lincoln", "D. Trump"}},
}
* Answer variable is the right index of answer among others in Choice's table
* The choice table is up to 4 option of answer
- 2nd : number, where the quiz starts from
- 3rd : boolean, set to true if you want to randomize your question table
results : number, quiz's score
Example of use:
-- the table must be filled precisely according to the following format
local TABLE = {
{Question = "What year was USA founded?", Answer = 2, Choice = {"1745", "1776", "1811"}}, --> the right answer is the second one which is 1776
{Question = "Who is President of USA in 2021?", Answer = 1, Choice = {"Joe Biden", "A. Lincoln", "D. Trump"}}, --> the right answer is the first one which is Joe Biden
}
-- execute
local SCORE = CB_Quiz(TABLE, 1, true) --> returns a number
One touch setting mod menu:
CB_Register(trigger button, button option 1, button option 2, menu table, option)
Create a selective menu user interface automatically based on your choice
arguments :
- 1st : number, 0-15 button id on Bully SE/AE
- 2nd : number, go see "../_RESOURCE/Single Auto Mod Menu + Detailed Comments.lua" or simply put 0
- 3rd : number, go see "../_RESOURCE/Single Auto Mod Menu + Detailed Comments.lua" or simply put 0
- 4th : table, input your table here and there must be a Name variable and Func variable. Ex:
local TABLE = {
{Name = "BRocket", ID = 307, Func = ProceedRequest},
{Name = "Spud Gun", ID = 305, Func = ProceedRequest},
}
- 5th : number, where the mod menu starts from
results : none
Example of use:
-- create function to proceed your choice
ProceedRequest = function(TABLE, OPTION)
PedSetWeapon(gPlayer, TABLE[OPTION].ID, 50, false)
end
-- the table must have "Name" variable and "Func" variable in order to work
local TABLE = {
{Name = "BRocket", ID = 307, Func = ProceedRequest},
{Name = "Spud Gun", ID = 305, Func = ProceedRequest},
}
-- execute
CB_Register(2, 0, 0, TABLE, 1) --> that's all, just press zoom in button to open the mod menu
Customized mod menu:
CBUI_Show(select timer)
Show UI only, must be used after CBUI_SetText and CBUI_SetOption or it will be empty
arguments : number, how many secs to menu get selected if CBUI_Select function used in the loop, if not then it's not neccessary
results : none
CBUI_Close()
Hide UI, can be used in any kind of situation
arguments : none
results : none
CBUI_Select()
Selecting menu mechanism with timer, according to CBUI_Show(timer)
arguments : none
results : boolean, true if after the timer goes off, otherwise it false
CBUI_0()
Set menu to the previous option
arguments : none
results : boolean, false if not pressed
CBUI_1()
Set menu to the previous option
arguments : none
results : boolean, false if not pressed
CBUI_SetText(text)
Setup text on Chalkboard UI, and the UI will be updated right after
arguments : string, put any information there (ex: "1. Apple")
results : none
CBUI_GetText()
Get a text from Chalkboard UI
arguments : none
results : string, current Chalkboard UI text
CBUI_SetOption(table option, true index)
Setup option on Chalkboard UI, and the UI will be updated right after
arguments :
- 1st : table, selectable options (ex: {"PREV", "", "NEXT"} or {"PREV", "", "", "NEXT"})
- 2nd : number, the index of right option (ex: 3)
results : none
CBUI_GetOption()
Get an option from Chalkboard UI
arguments : none
results : table options, true index
CBUI_IsActive()
Checking Chalkboard UI (manual) is active or not
arguments : none
results : boolean, true if Chalkboard UI (manual) is active
CBUI_ExitViaSpace()
Checking Chalkboard UI is exiting via space
arguments : none
results : boolean, true if Chalkboard UI is exiting via space
Example of use:
local ACTIVE_UI = false
local CUTSCENE = {
{Name = "Original Intro", Code = "1-01"},
{Name = "Welcome To The Bullworth", Code = "1-1-1"},
{Name = "Principal Intro", Code = "1-1-2"},
{Name = "Meet Gary", Code = "1-02B"},
{Name = "Meet Peter", Code = "1-02E"},
{Name = "This Is Your School", Code = "1-02D"},
{Name = "The Setup", Code = "1-03"},
}
local OPTION = 1
while true do
Wait(0)
-- ui
if CBUI_IsActive() and ACTIVE_UI then
-- prev
if CBUI_0() then
OPTION = OPTION - 1 < 1 and table.getn(CUTSCENE) or OPTION - 1
CBUI_SetText(OPTION..") "..CUTSCENE[OPTION].Name)
CBUI_SetOption({"PREV", "", "", "NEXT"}, 4)
end
-- next
if CBUI_1() then
OPTION = OPTION + 1 > table.getn(CUTSCENE) and 1 or OPTION + 1
CBUI_SetText(OPTION..") "..CUTSCENE[OPTION].Name)
CBUI_SetOption({"PREV", "", "", "NEXT"}, 4)
end
-- select
if CBUI_Select() then
CBUI_SetText("# EXIT OR PLAY #")
CBUI_SetOption({"EXIT", "", "PLAY"}, 3)
local PLAY = nil
while PLAY == nil do
Wait(0)
if CBUI_0() then PLAY = false end
if CBUI_1() then PLAY = true end
end
if CBUI_IsActive() then
CBUI_Close()
if PLAY then
PlayCutsceneWithLoad(CUTSCENE[OPTION].Code)
end
end
end
else
if ACTIVE_UI then
ACTIVE_UI = false
end
end
-- activate
if IsButtonBeingPressed(2, 0) and not PlayerIsInAnyVehicle() then
if not CBUI_IsActive() and CB_IsSafe() and not ACTIVE_UI then
CBUI_SetText(OPTION..") "..CUTSCENE[OPTION].Name)
CBUI_SetOption({"PREV", "", "", "NEXT"}, 4)
CBUI_Show(3)
ACTIVE_UI = true
end
end
end