HarryCourt Posted October 18, 2022 Share Posted October 18, 2022 Hello all! Hope you're doing well. I'm currently making a mod that requires the use of another channel tab to operate. However, after looking through ISChat.lua and a few other mods, I still cannot figure out how to create another channel tab. I'm completely lost. What I've done is copied and pasted two functions; ISChat:onCommandEntered() and ISChat.onTabAdded = function(tabTitle, tabID). The former has been modified and runs perfectly fine should I only use the general tab. However, using ISChat.onTabAdded (Copied and pasted straight from ISChat.lua, no edits) produces TWO General tabs. Every edit that I can think of has resulted in the tab going missing or the chatbox producing errors and no longer functioning. Here is the code that is being used. I've left out the ISChat.onTabAdded function as it's a direct paste from ISChat.lua, and I'm not even 100% sure I'm supposed to be doing that. -- File name: ISChat_Harrison.lua ISChat.allChatStreams[8] = {name = "radio", command = "/radio ", shortCommand = "/r", tabID = 3}; ISChat.defaultTabStream[3] = ISChat.allChatStreams[8]; function ISChat:onCommandEntered() local command = ISChat.instance.textEntry:getText(); local chat = ISChat.instance; ISChat.instance:unfocus(); if not command or command == "" then return; end local commandProcessed = false; local chatCommand; local chatStreamName; for _, stream in ipairs(ISChat.allChatStreams) do chatCommand = nil; if luautils.stringStarts(command, stream.command) then chatCommand = stream.command; elseif stream.shortCommand and luautils.stringStarts(command, stream.shortCommand) then chatCommand = stream.shortCommand; end if chatCommand then if chat.currentTabID ~= stream.tabID then showWrongChatTabMessage(chat.currentTabID - 1, stream.tabID - 1, chatCommand); -- from one-based to zero-based commandProcessed = true; break; end chat.chatText.lastChatCommand = chatCommand; local originalCommand = command; command = string.sub(command, #chatCommand); if command ~= "" and command ~= " " then chat:logChatCommand(originalCommand); end chatStreamName = stream.name; break; end end if not chatCommand then if luautils.stringStarts(command, "/") then SendCommandToServer(command); chat:logChatCommand(command); commandProcessed = true; else local defaultStream = ISChat.defaultTabStream[chat.currentTabID]; chatStreamName = defaultStream.name; chat:logChatCommand(command); end end if not commandProcessed then if chatStreamName == "yell" then processShoutMessage(command); elseif chatStreamName == "whisper" then local username = proceedPM(command); chat.chatText.lastChatCommand = chat.chatText.lastChatCommand .. username .. " "; elseif chatStreamName == "faction" then proceedFactionMessage(command); elseif chatStreamName == "safehouse" then processSafehouseMessage(command); elseif chatStreamName == "admin" then processAdminChatMessage(command); elseif chatStreamName == "say" then processSayMessage(command); elseif chatStreamName == "general" then processGeneralMessage(command); -- Harrison here; If it's a general message, then let's check if we can actually have a radio elseif chatStreamName == "globalradio" then if getPlayer():getInventory():getItemsFromFullType("Radio.WalkieTalkie1"):size() ~= 0 or getPlayer():getInventory():getItemsFromFullType("Radio.WalkieTalkie2"):size() ~= 0 or getPlayer():getInventory():getItemsFromFullType("Radio.WalkieTalkie3"):size() ~= 0 or getPlayer():getInventory():getItemsFromFullType("Radio.WalkieTalkie4"):size() ~= 0 or getPlayer():getInventory():getItemsFromFullType("Radio.WalkieTalkie5"):size() ~= 0 or getPlayer():getInventory():getItemsFromFullType("Radio.WalkieTalkieMakeShift"):size() ~= 0 then print("RADIO!!") processGeneralMessage(command); else -- Else, just send a halo to the player print("no radio :(") getPlayer():setHaloNote("*I need a radio before I can do that...*", 255, 144, 0, 300) end end end doKeyPress(false); ISChat.instance.timerTextEntry = 20; end -- At the bottom here is the "ISChat.onTabAdded = function(tabTitle, tabID)" function found in ISChat.lua. This creates two "General" tabs, and I cannot figure out how to create a custom one. Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted October 18, 2022 Share Posted October 18, 2022 Never looked at this before, but can you just call: ISChat.onTabAdded("My Tab Name", X) - with a number instead of the X? (Not sure what number it wants, maybe just the next tab number, i.e. the current number of tabs + 1)? Link to comment Share on other sites More sharing options...
HarryCourt Posted October 18, 2022 Author Share Posted October 18, 2022 Unfortunately this doesn't work. It simply just creates the chat UI with no tab at all. Link to comment Share on other sites More sharing options...
CrystalChris Posted November 5, 2022 Share Posted November 5, 2022 Hey Harry. I was actually hoping to make a mod myself that adds more chat tabs, have you figured this out, or made any strides on figuring it out? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now