JimPanzee Posted June 26, 2015 Share Posted June 26, 2015 Hi, maybe I missed it, but I didn't found a way to effectively test out lua code in the game.Is there a way to type lua code in some kind of console and have it executed in a running game? Or do I have to write it in my mod files and reload the mod (and than the game) every time I make a change? Link to comment Share on other sites More sharing options...
Suomiboi Posted June 26, 2015 Share Posted June 26, 2015 There's the lua debugger. You can load edited lua files while playing. But you still have to edit the files outside of the game. It won't always work/glitches at times, but it's a very useful tool for testing simple value changes for example. JimPanzee 1 Link to comment Share on other sites More sharing options...
ethanwdp Posted June 26, 2015 Share Posted June 26, 2015 Hi, maybe I missed it, but I didn't found a way to effectively test out lua code in the game.Is there a way to type lua code in some kind of console and have it executed in a running game? Or do I have to write it in my mod files and reload the mod (and than the game) every time I make a change?The Let Me Speak mod I'm testing has a very basic lua interpreter that interprets one line. I've almost completed the interpreter, so if you want I could give you the code for it.It's basically a singleplayer chat bar, and you can type /lua codehere to launch some code. You can take advantage of this to launch (global) functions from your mod, or from the CheatCore provided, or just run some code in-game. You can also define variables with it. Edit: Here you go. For each of the spoilers is a new lua file, FYI. letmespeakwindowLMSWindow = ISPanel:derive("LMSWindow");function LMSWindow:initialise() ISPanel.initialise(self);endfunction LMSWindow:new(x, y, width, height) local o = {}; o = ISPanel:new(x, y, width, height); setmetatable(o, self); self.__index = self; o.title = ""; o.pin = false; o:noBackground(); return o;endfunction LMSWindow:createChildren() ISPanel.createChildren(self); self.LMSChatBar = ISTextEntryBox:new("", 0, 15, 500, 20) self.LMSChatBar:initialise(); self:addChild(self.LMSChatBar)endfunction LMScreate() LMSWindow = LMSWindow:new(35, getCore():getScreenHeight() - 100, 500, 40) LMSWindow:addToUIManager(); LMSWindow:setVisible(false);endfunction KeyListener(_keyPressed) if _keyPressed == 20 and not LMSWindow.LMSChatBar:getText() ~= nil then if not LMSWindow:getIsVisible() then LMSWindow:setVisible(true); LMSWindow.LMSChatBar:focus() else LMSWindow:setVisible(false); LMSWindow.LMSChatBar:clear() end endendEvents.OnGameStart.Add(LMScreate);Events.OnKeyPressed.Add(KeyListener); letmespeakcommands(unfinished, but the Lua part works) function ISTextEntryBox:onCommandEntered() local LMSText = LMSWindow.LMSChatBar:getText() local LMSTable = {} local LMSKey = 0 if LMSWindow:getIsVisible() then if not string.find(LMSText, "/", 1) then getPlayer():Say(LMSText); elseif string.match(LMSText, "/") and not string.match(LMSText, "/lua ") then for i in string.gmatch(LMSText, "%S+") do LMSTable[LMSKey] = i LMSKey = LMSKey + 1 end if string.match(LMSText, "/godmode") then CheatCore.HandleToggle("God Mode", "CheatCore.IsGod", nil) end if string.match(LMSText, "/creative") then CheatCore.HandleToggle("Creative Mode", "ISBuildMenu.cheat") end for i = 1,3 do print(LMSTable) print("Table key is"..tostring(i)) end elseif string.match(LMSText, "/lua ") then local LMSTextToLua = string.gsub(LMSText, "/lua ", "") loadstring(LMSTextToLua)() end LMSWindow.LMSChatBar:clear(); LMSWindow.LMSChatBar:unfocus(); LMSWindow:setVisible(false); endend CheatCore -------------------------------------------------------------- ---- ________ __ ______ ---- / ____/ /_ ___ ____ _/ /_ / ____/___ ________ ---- / / / __ \/ _ \/ __ `/ __/ / / / __ \/ ___/ _ \ ----/ /___/ / / / __/ /_/ / /_ / /___/ /_/ / / / __/ ----\____/_/ /_/\___/\__,_/\__/ \____/\____/_/ \___/ ---- ---- --------------------------------------------------------------CheatCore = {}------------------------------------------------Needs/stats/whatever they're called toggle------------------------------------------------CheatCore.ToggleAllStats = false----------------------------------------------function CheatCore.HandleToggle(DisplayName, VariableToToggle, Optional) -- CheatType is the string to add to the getPlayer():Say() function, VariableToToggle is the variable to toggle (woah, right?) in string form, and Optional is the optional function to call. if VariableToToggle ~= nil then if loadstring("return "..VariableToToggle)() == nil then loadstring(VariableToToggle.." = false")() end if loadstring("return "..VariableToToggle)() == false then loadstring(VariableToToggle.." = true")() -- concatenates the VariableToToggle string into the " = true" statement, so that I no longer need dedicated toggle functions for every cheat. getPlayer():Say(DisplayName.." cheat enabled.") else loadstring(VariableToToggle.." = false")() getPlayer():Say(DisplayName.." cheat disabled.") end end if Optional ~= nil then -- checks if the OptionalCall argument was passed loadstring(Optional)() endendfunction CheatCore.SetTime(TimeToSet, DayOrMonth) local time = getGameTime() -- gets game time if DayOrMonth == "Time" then time:setTimeOfDay( TimeToSet ) -- sets game time to whatever was passed to it. getPlayer():Say("Time successfully changed to "..TimeToSet..":00.") end if DayOrMonth == "Day" then time:setDay( time:getDay() + TimeToSet ) if time:getDay() == TimeToSet and TimeToSet <= 30 then getPlayer():Say("Day successfully changed to "..TimeToSet) else if time:getDay() >= time:daysInMonth(time:getYear(), time:getMonth()) then time:setMonth( time:getMonth() + 1 ) time:setDay( 0 ) end end end if DayOrMonth == "Month" then time:setMonth( TimeToSet ) if time:getMonth() > 12 then time:setYear( time:getYear() + 1 ) time:setMonth( time:getMonth() + TimeToSet - 12) end end if DayOrMonth == "Year" then time:setYear( time:getYear() + TimeToSet ) endendCheatCore.DoRefillAmmo = function() local primaryHandItemData = getPlayer():getPrimaryHandItem():getModData(); primaryHandItemData.currentCapacity = primaryHandItemData.maxCapacityendCheatCore.DoMaxSkill = function(worldobjects, SkillToSet, ToLevel) getPlayer():getXp():setXPToLevel(SkillToSet, ToLevel); getPlayer():setNumberOfPerksToPick(ToLevel);endCheatCore.DoGhostMode = function(worldobjects) if not getPlayer():isGhostMode() then -- checks if player is already ghostmode getPlayer():Say("Ghost Mode cheat enabled.") getPlayer():setGhostMode(true) else getPlayer():Say("Ghost Mode cheat disabled.") getPlayer():setGhostMode(false) endendCheatCore.DoRepair = function() getPlayer():Say("Weapon repaired!") local ToolToRepair = getPlayer():getPrimaryHandItem() -- gets the item in the players hand ToolToRepair:setCondition( getPlayer():getPrimaryHandItem():getConditionMax() ) -- gets the maximum condition and sets it to itendCheatCore.SpawnZombieNow = function() if CheatCore.ZombieBrushEnabled == true then local mx = getMouseXScaled(); local my = getMouseYScaled(); local player = getPlayer(); local wz = player:getZ(); local wx, wy = ISCoordConversion.ToWorld(mx, my, wz); local versionNumber = tonumber(string.match(getCore():getVersionNumber(), "%d+")) -- saves version number to variable, for checking versions if versionNumber <= 31 then -- checks for build 31 and below for i = 1,CheatCore.ZombiesToSpawn do getVirtualZombieManager():createRealZombieNow(wx,wy,wz); end else if versionNumber >= 32 then -- handles this differently if it is build 32 or above spawnHorde(wx,wy,wx,wy,wz,CheatCore.ZombiesToSpawn) end end endendCheatCore.DoHeal = function(_player) getPlayer():Say("Player healed.") getPlayer():getBodyDamage():RestoreToFullHealth();endCheatCore.DoDelete = function(_keyPressed) if CheatCore.IsDelete == true and _keyPressed == 45 then local mx = getMouseXScaled(); local my = getMouseYScaled(); local player = getPlayer(); local wz = getPlayer():getZ(); local wx, wy = ISCoordConversion.ToWorld(mx, my, wz); wx = math.floor(wx); wy = math.floor(wy); local cell = getWorld():getCell(); local sq = cell:getGridSquare(wx, wy, wz); local sqObjs = sq:getObjects(); local sqSize = sqObjs:size(); for i = sqSize-1, 0, -1 do local obj = sqObjs:get(i); if i > 0 then -- checks for floor, otherwise it'd leave a gaping hole sq:getSpecialObjects():remove(obj); sq:getObjects():remove(obj); end end endendCheatCore.DoFireNow = function() if CheatCore.FireBrushEnabled == true then local mx = getMouseXScaled(); local my = getMouseYScaled(); local player = getPlayer(); local wz = math.floor(player:getZ()); local wx, wy = ISCoordConversion.ToWorld(mx, my, wz); wx = math.floor(wx); wy = math.floor(wy); local cell = getWorld():getCell(); local GridToBurn = cell:getGridSquare(wx, wy, wz) GridToBurn:StartFire(); endendCheatCore.AllStatsToggle = function(_player) if CheatCore.ToggleAllStats == false then getPlayer():Say("Infinite stats enabled.") CheatCore.IsHunger = true CheatCore.IsThirst = true CheatCore.IsPanic = true CheatCore.IsSanity = true CheatCore.IsStress = true CheatCore.IsBoredom = true CheatCore.IsAnger = true CheatCore.IsPain = true CheatCore.IsSick = true CheatCore.IsEndurance = true CheatCore.IsFitness = true CheatCore.IsSleep = true CheatCore.ToggleAllStats = true else getPlayer():Say("Infinite stats disabled.") CheatCore.IsHunger = false CheatCore.IsThirst = false CheatCore.IsPanic = false CheatCore.IsSanity = false CheatCore.IsStress = false CheatCore.IsBoredom = false CheatCore.IsAnger = false CheatCore.IsPain = false CheatCore.IsSick = false CheatCore.IsEndurance = false CheatCore.IsFitness = false CheatCore.IsSleep = false CheatCore.ToggleAllStats = false endendCheatCore.DoCheats = function() if CheatCore.IsGod == true then getPlayer():getBodyDamage():RestoreToFullHealth(); end if CheatCore.IsAmmo == true then local primaryHandItemData = getPlayer():getPrimaryHandItem():getModData(); if primaryHandItemData.currentCapacity >= 0 then primaryHandItemData.currentCapacity = primaryHandItemData.maxCapacity end end if CheatCore.IsHunger == true then getPlayer():getStats():setHunger(0); end if CheatCore.IsThirst == true then getPlayer():getStats():setThirst(0); end if CheatCore.IsPanic == true then getPlayer():getStats():setPanic(0); end if CheatCore.IsSanity == true then getPlayer():getStats():setSanity(1); end if CheatCore.IsStress == true then getPlayer():getStats():setStress(0); end if CheatCore.IsBoredom == true then getPlayer():getStats():setBoredom(0); end if CheatCore.IsAnger == true then getPlayer():getStats():setAnger(0); end if CheatCore.IsPain == true then getPlayer():getStats():setPain(0); end if CheatCore.IsSick == true then getPlayer():getStats():setSickness(0) end if CheatCore.IsEndurance == true then getPlayer():getStats():setEndurance(1); end if CheatCore.IsFitness == true then getPlayer():getStats():setFitness(1); end if CheatCore.IsSleep == true then getPlayer():getStats():setFatigue(0); end if CheatCore.IsWeightThing == true then getPlayer():setMaxWeightBase( 999999 ) end if CheatCore.IsWeightThing == false then getPlayer():setMaxWeightBase( 8 ); end if getPlayer():getBodyDamage():getHealth() <= 5 and CheatCore.DoPreventDeath == true then getPlayer():getBodyDamage():RestoreToFullHealth(); end if IsRepair == true and getPlayer():getPrimaryHandItem():getCondition() < getPlayer():getPrimaryHandItem():getConditionMax() then local ToolToRepair = getPlayer():getPrimaryHandItem() -- basically does the same thing as DoRepair ToolToRepair:setCondition( getPlayer():getPrimaryHandItem():getConditionMax() ) endendCheatCore.DoTraitCheats = function() -- also does some other things if getPlayer():HasTrait("permagod") then getPlayer():getBodyDamage():RestoreToFullHealth(); end if getPlayer():HasTrait("permacreative") then ISBuildMenu.cheat = true end if getPlayer():HasTrait("permaweight") then getPlayer():setMaxWeightBase( 999999 ); end if CheatCore.IsMelee == true and CheatCore.HasSwitchedWeapon ~= getPlayer():getPrimaryHandItem():getName() and not getPlayer():getPrimaryHandItem():isRanged() then getPlayer():Say("Re-initializing melee insta-kill cheat") CheatCore.DoWeaponDamage() else if CheatCore.IsMelee == true and CheatCore.HasSwitchedWeapon ~= getPlayer():getPrimaryHandItem():getName() and getPlayer():getPrimaryHandItem():isRanged() then getPlayer():Say("Non-melee weapon detected! Please switch back and disable the cheat.") end endendCheatCore.DoWeaponDamage = function() local weapon = getPlayer():getPrimaryHandItem() if CheatCore.IsMelee == true and not getPlayer():getPrimaryHandItem():isRanged() then CheatCore.HasSwitchedWeapon = getPlayer():getPrimaryHandItem():getName() -- stores name in variable, so if the player switches weapons DoCheats will detect it and disable the cheat, otherwise things get a bit messy originalMinDamage = weapon:getMinDamage() -- gets the original value, to make it toggleable originalMaxDamage = weapon:getMaxDamage() originalDoorDamage = weapon:getDoorDamage() originalTreeDamage = weapon:getTreeDamage() weapon:setMinDamage( 999 ); weapon:setMaxDamage( 999 ); weapon:setDoorDamage( 999 ); weapon:setTreeDamage( 999 ); else if CheatCore.IsMelee == true and getPlayer():getPrimaryHandItem():isRanged() then getPlayer():Say("Non-melee weapon detected! Melee insta-kill disabled.") CheatCore.IsMelee = false end end if CheatCore.IsMelee == false then weapon:setMinDamage( originalMinDamage ); -- returns the original weapon values weapon:setMaxDamage( originalMaxDamage ); weapon:setDoorDamage( originalDoorDamage ); weapon:setTreeDamage( originalTreeDamage ); end endCheatCore.DoNoReload = function() if CheatCore.IsMelee == true then -- checks to make sure that IsMelee is enabled, and if it is then it disables it. CheatCore.IsMelee = false CheatCore.DoWeaponDamage() end local weapon = getPlayer():getPrimaryHandItem() if CheatCore.NoReload == true then originalRecoilDelay = weapon:getRecoilDelay() -- again, saves the normal values into variables weapon:setRecoilDelay( 0 ) -- due to how the games code works, I can't set it under 0, or the class file that handles this function will just set it back to 0. end if CheatCore.NoReload == false then weapon:setRecoilDelay( originalRecoilDelay ) -- and again, it then restores the old values when disabled endendCheatCore.DoMaxAllSkills = function() getPlayer():Say("All skills maxed!") getPlayer():getXp():AddXP(Perks.Sprinting, 999999); getPlayer():getXp():AddXP(Perks.Lightfoot, 999999); getPlayer():getXp():AddXP(Perks.Nimble, 999999); getPlayer():getXp():AddXP(Perks.Sneak, 999999); getPlayer():getXp():AddXP(Perks.Cooking, 999999); getPlayer():getXp():AddXP(Perks.Woodwork, 999999); getPlayer():getXp():AddXP(Perks.Farming, 999999); getPlayer():getXp():AddXP(Perks.Axe, 999999); getPlayer():getXp():AddXP(Perks.Blunt, 999999); getPlayer():getXp():AddXP(Perks.Aiming, 999999); getPlayer():getXp():AddXP(Perks.Reloading, 999999); getPlayer():getXp():AddXP(Perks.Fishing, 999999); getPlayer():getXp():AddXP(Perks.Trapping, 999999); getPlayer():getXp():AddXP(Perks.BluntGuard, 999999); getPlayer():getXp():AddXP(Perks.BluntMaintenance, 999999); getPlayer():getXp():AddXP(Perks.BladeGuard, 999999); getPlayer():getXp():AddXP(Perks.BladeMaintenance, 999999); getPlayer():getXp():AddXP(Perks.PlantScavenging, 999999); getPlayer():getXp():AddXP(Perks.Doctor, 999999); end Events.OnPlayerUpdate.Add(CheatCore.DoCheats); Events.OnTick.Add(CheatCore.DoTraitCheats); Events.OnMouseDown.Add(CheatCore.DoFireNow); Events.OnMouseDown.Add(CheatCore.SpawnZombieNow); Events.OnKeyPressed.Add(CheatCore.DoDelete); JimPanzee 1 Link to comment Share on other sites More sharing options...
JimPanzee Posted June 26, 2015 Author Share Posted June 26, 2015 @Suomiboi: Oh, ok I did read the post about the debugger but may be to blind to see the part about loading a file. Thank you for the information. @ethanwdp: Wow. Nice. That is exactly what I had in mind to mod myself. I will try to expand it with some kind of auto completion. I thought about reading all the lua files with "luadoc" and indexing the functions in a file. Than using tooltips to show available functions. Are custom tooltips at an edit-field possible? Link to comment Share on other sites More sharing options...
ethanwdp Posted June 26, 2015 Share Posted June 26, 2015 @Suomiboi: Oh, ok I did read the post about the debugger but may be to blind to see the part about loading a file. Thank you for the information. @ethanwdp: Wow. Nice. That is exactly what I had in mind to mod myself. I will try to expand it with some kind of auto completion. I thought about reading all the lua files with "luadoc" and indexing the functions in a file. Than using tooltips to show available functions. Are custom tooltips at an edit-field possible?Some of the code there was from an early version, so the lua interpreter might be buggy (fixed version below)And for your question, I have no clue. I don't have much experience with lua interpreters. That was my first time making one Not too sure how autocompletion would work. The ISTextEntryBox doesn't support tooltips AFAIK. Btw, here's an updated lua interpreter, because the last one couldn't even accept spaces: letmespeakcommandsfunction ISTextEntryBox:onCommandEntered() local LMSText = LMSWindow.LMSChatBar:getText() local LMSTable = {} local LMSKey = 0 if LMSWindow:getIsVisible() then if not string.find(LMSText, "/", 1) then getPlayer():Say(LMSText); elseif string.match(LMSText, "/") and not string.match(LMSText, "/lua ") then for i in string.gmatch(LMSText, "%S+") do LMSTable[LMSKey] = i LMSKey = LMSKey + 1 end if string.match(LMSText, "/godmode") then CheatCore.HandleToggle("God Mode", "CheatCore.IsGod", nil) end if string.match(LMSText, "/creative") then CheatCore.HandleToggle("Creative Mode", "ISBuildMenu.cheat") end if string.match(LMSText, "/deletemode") then CheatCore.HandleToggle("Delete Mode (X to Delete)", "CheatCore.IsDelete") end if string.match(LMSText, "/toggleneed") then local LMSTextToToggleNeed = "CheatCore.Is"..LMSTable[1] print(LMSTextToToggleNeed) CheatCore.HandleToggle(LMSTable[1], string.gsub(LMSTextToToggleNeed, "%a", string.upper, 1)) end for i = 1,3 do print(LMSTable) print("Table key is"..tostring(i)) end elseif string.match(LMSText, "/lua ") then local LMSTextToLua = string.gsub(LMSText, "/lua ", "") loadstring(LMSTextToLua)() end LMSWindow.LMSChatBar:clear(); LMSWindow.LMSChatBar:unfocus(); LMSWindow:setVisible(false); endend Updated CheatCore:-------------------------------------------------------------- ---- ________ __ ______ ---- / ____/ /_ ___ ____ _/ /_ / ____/___ ________ ---- / / / __ \/ _ \/ __ `/ __/ / / / __ \/ ___/ _ \ ----/ /___/ / / / __/ /_/ / /_ / /___/ /_/ / / / __/ ----\____/_/ /_/\___/\__,_/\__/ \____/\____/_/ \___/ ---- ---- --------------------------------------------------------------CheatCore = {}------------------------------------------------Needs/stats/whatever they're called toggle------------------------------------------------CheatCore.ToggleAllStats = false----------------------------------------------CheatCore.HandleToggle = function(DisplayName, VariableToToggle, Optional) -- CheatType is the string to add to the getPlayer():Say() function, VariableToToggle is the variable to toggle (woah, right?) in string form, and Optional is the optional function to call. if VariableToToggle ~= nil then if loadstring("return "..VariableToToggle)() == nil then loadstring(VariableToToggle.." = false")() end if loadstring("return "..VariableToToggle)() == false then loadstring(VariableToToggle.." = true")() -- concatenates the VariableToToggle string into the " = true" statement, so that I no longer need dedicated toggle functions for every cheat. getPlayer():Say(DisplayName.." cheat enabled.") else loadstring(VariableToToggle.." = false")() getPlayer():Say(DisplayName.." cheat disabled.") end end if Optional ~= nil then -- checks if the OptionalCall argument was passed loadstring(Optional)() endendCheatCore.SetTime = function(TimeToSet, DayOrMonth) local time = getGameTime() -- gets game time if DayOrMonth == "Time" then time:setTimeOfDay( TimeToSet ) -- sets game time to whatever was passed to it. getPlayer():Say("Time successfully changed to "..TimeToSet..":00.") end if DayOrMonth == "Day" then time:setDay( time:getDay() + TimeToSet ) if time:getDay() == TimeToSet and TimeToSet <= 30 then getPlayer():Say("Day successfully changed to "..TimeToSet) else if time:getDay() >= time:daysInMonth(time:getYear(), time:getMonth()) then time:setMonth( time:getMonth() + 1 ) time:setDay( 0 ) end end end if DayOrMonth == "Month" then local roundToProperMonth = time:getMonth() + TimeToSet time:setMonth( time:getMonth() + TimeToSet ) if time:getMonth() > 12 then time:setYear( time:getYear() + 1 ) time:setMonth( roundToProperMonth - 12 ) end end if DayOrMonth == "Year" then time:setYear( time:getYear() + TimeToSet ) endendCheatCore.DoRefillAmmo = function() local primaryHandItemData = getPlayer():getPrimaryHandItem():getModData(); primaryHandItemData.currentCapacity = primaryHandItemData.maxCapacityendCheatCore.DoMaxSkill = function(worldobjects, SkillToSet, ToLevel) getPlayer():getXp():setXPToLevel(SkillToSet, ToLevel); getPlayer():setNumberOfPerksToPick(ToLevel);endCheatCore.DoGhostMode = function() if not getPlayer():isGhostMode() then -- checks if player is already ghostmode getPlayer():Say("Ghost Mode cheat enabled.") getPlayer():setGhostMode(true) else getPlayer():Say("Ghost Mode cheat disabled.") getPlayer():setGhostMode(false) endendCheatCore.DoRepair = function() getPlayer():Say("Weapon repaired!") local ToolToRepair = getPlayer():getPrimaryHandItem() -- gets the item in the players hand ToolToRepair:setCondition( getPlayer():getPrimaryHandItem():getConditionMax() ) -- gets the maximum condition and sets it to itendCheatCore.SpawnZombieNow = function() if CheatCore.ZombieBrushEnabled == true then local mx = getMouseXScaled(); local my = getMouseYScaled(); local player = getPlayer(); local wz = player:getZ(); local wx, wy = ISCoordConversion.ToWorld(mx, my, wz); local versionNumber = tonumber(string.match(getCore():getVersionNumber(), "%d+")) -- saves version number to variable, for checking versions if versionNumber <= 31 then -- checks for build 31 and below for i = 1,CheatCore.ZombiesToSpawn do getVirtualZombieManager():createRealZombieNow(wx,wy,wz); end else if versionNumber >= 32 then -- handles this differently if it is build 32 or above spawnHorde(wx,wy,wx,wy,wz,CheatCore.ZombiesToSpawn) end end endendCheatCore.DoHeal = function(_player) getPlayer():Say("Player healed.") getPlayer():getBodyDamage():RestoreToFullHealth();endCheatCore.DoDelete = function(_keyPressed) if CheatCore.IsDelete == true and _keyPressed == 45 then local mx = getMouseXScaled(); local my = getMouseYScaled(); local player = getPlayer(); local wz = getPlayer():getZ(); local wx, wy = ISCoordConversion.ToWorld(mx, my, wz); wx = math.floor(wx); wy = math.floor(wy); local cell = getWorld():getCell(); local sq = cell:getGridSquare(wx, wy, wz); local sqObjs = sq:getObjects(); local sqSize = sqObjs:size(); for i = sqSize-1, 0, -1 do local obj = sqObjs:get(i); if i > 0 then -- checks for floor, otherwise it'd leave a gaping hole sq:getSpecialObjects():remove(obj); sq:getObjects():remove(obj); end end endendCheatCore.DoFireNow = function() if CheatCore.FireBrushEnabled == true then local mx = getMouseXScaled(); local my = getMouseYScaled(); local player = getPlayer(); local wz = math.floor(player:getZ()); local wx, wy = ISCoordConversion.ToWorld(mx, my, wz); wx = math.floor(wx); wy = math.floor(wy); local cell = getWorld():getCell(); local GridToBurn = cell:getGridSquare(wx, wy, wz) GridToBurn:StartFire(); endendCheatCore.AllStatsToggle = function(_player) if CheatCore.ToggleAllStats == false then getPlayer():Say("Infinite stats enabled.") CheatCore.IsHunger = true CheatCore.IsThirst = true CheatCore.IsPanic = true CheatCore.IsSanity = true CheatCore.IsStress = true CheatCore.IsBoredom = true CheatCore.IsAnger = true CheatCore.IsPain = true CheatCore.IsSick = true CheatCore.IsEndurance = true CheatCore.IsFitness = true CheatCore.IsSleep = true CheatCore.ToggleAllStats = true else getPlayer():Say("Infinite stats disabled.") CheatCore.IsHunger = false CheatCore.IsThirst = false CheatCore.IsPanic = false CheatCore.IsSanity = false CheatCore.IsStress = false CheatCore.IsBoredom = false CheatCore.IsAnger = false CheatCore.IsPain = false CheatCore.IsSick = false CheatCore.IsEndurance = false CheatCore.IsFitness = false CheatCore.IsSleep = false CheatCore.ToggleAllStats = false endendCheatCore.DoCheats = function() if CheatCore.IsGod == true then getPlayer():getBodyDamage():RestoreToFullHealth(); end if CheatCore.IsAmmo == true then local primaryHandItemData = getPlayer():getPrimaryHandItem():getModData(); if primaryHandItemData.currentCapacity >= 0 then primaryHandItemData.currentCapacity = primaryHandItemData.maxCapacity end end if CheatCore.IsHunger == true then getPlayer():getStats():setHunger(0); end if CheatCore.IsThirst == true then getPlayer():getStats():setThirst(0); end if CheatCore.IsPanic == true then getPlayer():getStats():setPanic(0); end if CheatCore.IsSanity == true then getPlayer():getStats():setSanity(1); end if CheatCore.IsStress == true then getPlayer():getStats():setStress(0); end if CheatCore.IsBoredom == true then getPlayer():getStats():setBoredom(0); end if CheatCore.IsAnger == true then getPlayer():getStats():setAnger(0); end if CheatCore.IsPain == true then getPlayer():getStats():setPain(0); end if CheatCore.IsSick == true then getPlayer():getStats():setSickness(0) end if CheatCore.IsEndurance == true then getPlayer():getStats():setEndurance(1); end if CheatCore.IsFitness == true then getPlayer():getStats():setFitness(1); end if CheatCore.IsSleep == true then getPlayer():getStats():setFatigue(0); end if CheatCore.IsWeightThing == true then getPlayer():setMaxWeightBase( 999999 ) end if CheatCore.IsWeightThing == false then getPlayer():setMaxWeightBase( 8 ); end if getPlayer():getBodyDamage():getHealth() <= 5 and CheatCore.DoPreventDeath == true then getPlayer():getBodyDamage():RestoreToFullHealth(); end if CheatCore.IsRepair == true and getPlayer():getPrimaryHandItem():getCondition() < getPlayer():getPrimaryHandItem():getConditionMax() then local ToolToRepair = getPlayer():getPrimaryHandItem() -- basically does the same thing as DoRepair ToolToRepair:setCondition( getPlayer():getPrimaryHandItem():getConditionMax() ) endendCheatCore.DoTraitCheats = function() -- also does some other things if getPlayer():HasTrait("permagod") then getPlayer():getBodyDamage():RestoreToFullHealth(); end if getPlayer():HasTrait("permacreative") then ISBuildMenu.cheat = true end if getPlayer():HasTrait("permaweight") then getPlayer():setMaxWeightBase( 999999 ); end if CheatCore.IsMelee == true and CheatCore.HasSwitchedWeapon ~= getPlayer():getPrimaryHandItem():getName() and not getPlayer():getPrimaryHandItem():isRanged() then getPlayer():Say("Re-initializing melee insta-kill cheat") CheatCore.DoWeaponDamage() else if CheatCore.IsMelee == true and CheatCore.HasSwitchedWeapon ~= getPlayer():getPrimaryHandItem():getName() and getPlayer():getPrimaryHandItem():isRanged() then getPlayer():Say("Non-melee weapon detected! Please switch back and disable the cheat.") end endendCheatCore.DoWeaponDamage = function() local weapon = getPlayer():getPrimaryHandItem() if CheatCore.IsMelee == true and not getPlayer():getPrimaryHandItem():isRanged() then CheatCore.HasSwitchedWeapon = getPlayer():getPrimaryHandItem():getName() -- stores name in variable, so if the player switches weapons DoCheats will detect it and disable the cheat, otherwise things get a bit messy originalMinDamage = weapon:getMinDamage() -- gets the original value, to make it toggleable originalMaxDamage = weapon:getMaxDamage() originalDoorDamage = weapon:getDoorDamage() originalTreeDamage = weapon:getTreeDamage() weapon:setMinDamage( 999 ); weapon:setMaxDamage( 999 ); weapon:setDoorDamage( 999 ); weapon:setTreeDamage( 999 ); else if CheatCore.IsMelee == true and getPlayer():getPrimaryHandItem():isRanged() then getPlayer():Say("Non-melee weapon detected! Melee insta-kill disabled.") CheatCore.IsMelee = false end end if CheatCore.IsMelee == false then weapon:setMinDamage( originalMinDamage ); -- returns the original weapon values weapon:setMaxDamage( originalMaxDamage ); weapon:setDoorDamage( originalDoorDamage ); weapon:setTreeDamage( originalTreeDamage ); end endCheatCore.DoNoReload = function() if CheatCore.IsMelee == true then -- checks to make sure that IsMelee is enabled, and if it is then it disables it. CheatCore.IsMelee = false CheatCore.DoWeaponDamage() end local weapon = getPlayer():getPrimaryHandItem() if CheatCore.NoReload == true then originalRecoilDelay = weapon:getRecoilDelay() -- again, saves the normal values into variables weapon:setRecoilDelay( 0 ) -- due to how the games code works, I can't set it under 0, or the class file that handles this function will just set it back to 0. end if CheatCore.NoReload == false then weapon:setRecoilDelay( originalRecoilDelay ) -- and again, it then restores the old values when disabled endendCheatCore.DoMaxAllSkills = function() getPlayer():Say("All skills maxed!") getPlayer():getXp():AddXP(Perks.Sprinting, 999999); getPlayer():getXp():AddXP(Perks.Lightfoot, 999999); getPlayer():getXp():AddXP(Perks.Nimble, 999999); getPlayer():getXp():AddXP(Perks.Sneak, 999999); getPlayer():getXp():AddXP(Perks.Cooking, 999999); getPlayer():getXp():AddXP(Perks.Woodwork, 999999); getPlayer():getXp():AddXP(Perks.Farming, 999999); getPlayer():getXp():AddXP(Perks.Axe, 999999); getPlayer():getXp():AddXP(Perks.Blunt, 999999); getPlayer():getXp():AddXP(Perks.Aiming, 999999); getPlayer():getXp():AddXP(Perks.Reloading, 999999); getPlayer():getXp():AddXP(Perks.Fishing, 999999); getPlayer():getXp():AddXP(Perks.Trapping, 999999); getPlayer():getXp():AddXP(Perks.BluntGuard, 999999); getPlayer():getXp():AddXP(Perks.BluntMaintenance, 999999); getPlayer():getXp():AddXP(Perks.BladeGuard, 999999); getPlayer():getXp():AddXP(Perks.BladeMaintenance, 999999); getPlayer():getXp():AddXP(Perks.PlantScavenging, 999999); getPlayer():getXp():AddXP(Perks.Doctor, 999999); end Events.OnPlayerUpdate.Add(CheatCore.DoCheats); Events.OnTick.Add(CheatCore.DoTraitCheats); Events.OnMouseDown.Add(CheatCore.DoFireNow); Events.OnMouseDown.Add(CheatCore.SpawnZombieNow); Events.OnKeyPressed.Add(CheatCore.DoDelete);I would throw up a download, but the rest of this mod still needs a lot of work. Hope that works in the meantime. JimPanzee 1 Link to comment Share on other sites More sharing options...
JimPanzee Posted June 26, 2015 Author Share Posted June 26, 2015 Thanks again. Will try it this weekend. 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