This is to solve a Tropico 4's annoyance.

It seems that Tropico 4 uses Xinput detection + LUA scripting, I used a script/mod that worked fine, but the latest expansion (Modern Times) broke everything.

This is the code that calls the XBOX functions. What I need, as I said, is to disable both left and right thumbs.

Shit, SG needs a markdown help right here... bleh.


`

-- Call as early as we could reasonably be expected to be called ...

-- Stop this from loading more than once
local FiredOnce = false
local ExpansionMode = false

-- Style it up like we're on an XBox ;)
AreScreensXboxStyle = function()
return true
end

function DoXBoxMod()
-- Fake Xbox compatibility
const.XBOX = true

-- Enable XInput
config.XInput = true

-- Invoke XInput
    -- Load base game
    dofile("HGE/UI/xinput.lua")
    dofile("Game/xinput.lua")

    if ExpansionMode then
        -- Load MT version (shouldn't matter)
        dofile("ex/HGE/UI/xinput.lua")
        dofile("ex/Game/xinput.lua")    
    end
-- End XInput loading

-- Force a few things
XInput.CurrentState = {}

-- "Reset" position
XInput.defaultState = {
    Left = false,
    Right = false,
    Up = false,
    Down = false,
    A = false,
    B = false,
    X = false,
    Y = false,
    LeftThumbClick = false,
    RightThumbClick = false,
    Start = false,
    Back = false,
    LeftShoulder = false,
    RightShoulder = false,
    LeftTrigger = 0,
    RightTrigger = 0,
    LeftThumb = point(0, 0),
    RightThumb = point(0, 0)
}

XInput.defaultState.__index = XInput.defaultState

XInput.UpdateStateFunc = XInput.__GetState

-- Terminal notifications
XInput.NotifyTerminal = {true, true, true}
XInput.NotifyTerminal[0] = true

XInput.Callback = {}
XInput.ComboCache = {}
XInput.RepeatButtons = {}
XInput.RepeatButtonTimeSpecific = {}
XInput.IncompatibleButtons = {}

-- Dirty, but it works.
ShowMouseCursor = function(reason) HideMouseCursor(reason) end

-- Turn off compatibility now that we have binds
const.XBOX = false

-- Save old version
oldGameTerminalXButtonCapture = gameTerminalTarget.OnXButtonDown

-- Make a new one
gameTerminalTarget.OnXButtonDown = function(self, button, nCtrlId)
    -- Add the left shoulder press
    if button == "LeftShoulder" then
        if IsInfoPanelOpened() and IsAlmanacOpened() then
            CloseInfoPanel(true)
            return
        end
        if CloseInGameUITools() and not IsPopUpNotificationDlgOpen() then
            return
        end
        if GameType == "ChallengeTest" then
            return
        end
        if GetDialog("InGameMainMenuWizard") then
            GetDialog("InGameMainMenuWizard"):ActivateState("idBack")
        elseif GetMap() and GetMap() ~= "" and not GetDialog("SelectTrait") and not GetDialog("AvatarTraits") and not GetDialog("SelectAvatarDlg") and not GetDialog("CreateAvatar") then
            OpenDialog("InGameMainMenuWizard")
        end
    else
        -- Use the old binds
        oldGameTerminalXButtonCapture(self, button, nCtrlId)
    end
end

-- Back up the old menu
oldMainMenuInit = MainMenu.Init

-- Create our own based on what we actually want.
MainMenu.Init = function(self)
    AreScreensXboxStyle = function() return false end
    oldMainMenuInit(self)
    AreScreensXboxStyle = function() return true end
end

end

-- Load it early/fast. We'll reload for MT, so it's not a problem.
OnMsg.ClassesGenerate = function()
DoXBoxMod()
end

-- MT Compatibility "Boot" loader
OnMsg.UASetMode = function(actions,mode)
if not FiredOnce then
if(mode == "Boot") then
FiredOnce = true
CreateRealTimeThread(function()
-- Expansion
OnMsg.ReloadLua = function()
ExpansionMode = true
end
-- Setup post-load
OnMsg.XPlayerSignin = function()
-- Modern Times loader :3
if FiredOnce and ExpansionMode then
DoXBoxMod()
end
end
end)
end
end
end
`


So, using my very poor logical skills, I should take this following part (changing LeftShoulder for LeftThumb) and nullify it somehow. Problem is, I have no idea how to do that or where to look for research. So any help appreciated.


if button == "LeftThumb" then ??????????? return end

11 years ago*

Comment has been collapsed.

Yeah, markdown is completely broken too.

11 years ago
Permalink

Comment has been collapsed.

if button == "LeftShoulder" then return end

...

11 years ago
Permalink

Comment has been collapsed.

lol, I just made that edit but for reading purposes. I'll try it and see what actually happens.

*edit: doesn't work

11 years ago
Permalink

Comment has been collapsed.

.

11 years ago
Permalink

Comment has been collapsed.

11 years ago
Permalink

Comment has been collapsed.

Closed 11 years ago by DrDudePhD.