Jupiters Posted August 20, 2015 Share Posted August 20, 2015 How to make deerclops not attack the structure?How to make bearger not attack the structure and when it walk through the structure, it won't collapse.And how to make Goose not attack the wall?@DarkXero Link to comment Share on other sites More sharing options...
Jupiters Posted August 20, 2015 Author Share Posted August 20, 2015 Or how to make the structure invincible?for example: local function Invincible( inst )inst:AddComponent("health")inst.components.health:SetInvincible(true)endAddPrefabPostInit("researchlab2", Invincible) These lines cant make researchlab2 invincible.Any solution please? Link to comment Share on other sites More sharing options...
DarkXero Posted August 21, 2015 Share Posted August 21, 2015 @Jupiters:AddPrefabPostInit("researchlab2", function(inst) inst:RemoveComponent("workable")end)And for everything you want to make invincible. Do you want to be able to hammer them too? Link to comment Share on other sites More sharing options...
Jupiters Posted August 21, 2015 Author Share Posted August 21, 2015 @DarkXeroThanks very much.Yes, I want to hammer them too. Link to comment Share on other sites More sharing options...
DarkXero Posted August 21, 2015 Share Posted August 21, 2015 @Jupiters:if not GLOBAL.TheNet:GetIsServer() then returnendlocal _HammerFn = GLOBAL.ACTIONS.HAMMER.fnGLOBAL.ACTIONS.HAMMER.fn = function(act) act.target.components.workable = act.target.components.hammerworkable local ret = _HammerFn(act) act.target.components.workable = nil return retendlocal function Swap(inst) inst.components.hammerworkable = inst.components.workable inst.components.workable = nilendlocal prefabs = { "researchlab", "researchlab2",}for k, v in pairs(prefabs) do AddPrefabPostInit(v, Swap)end Link to comment Share on other sites More sharing options...
Jupiters Posted August 21, 2015 Author Share Posted August 21, 2015 (edited) @DarkXeroYou are such a genius. Thx. But the hammering action becomes discontinuous. There is a stop during every hammering. Edited August 21, 2015 by Jupiters Link to comment Share on other sites More sharing options...
DarkXero Posted August 21, 2015 Share Posted August 21, 2015 @Jupiters:Yeah, I forgot. Add this to the code:AddStategraphPostInit("wilson", function(sg) local _TimeEvent14 = sg.states["hammer"].timeline[2].fn sg.states["hammer"].timeline[2].fn = function(inst) local sm = inst.sg.statemem.action if sm and sm.target then sm.target.components.workable = sm.target.components.hammerworkable end _TimeEvent14(inst) if sm and sm.target then sm.target.components.workable = nil end endend) Link to comment Share on other sites More sharing options...
Jupiters Posted August 21, 2015 Author Share Posted August 21, 2015 (edited) @DarkXeroNow it works. Thanks. Could I use your codes to make a mod and port it in steam workshop? Edited August 21, 2015 by Jupiters Link to comment Share on other sites More sharing options...
DarkXero Posted August 21, 2015 Share Posted August 21, 2015 @Jupiters, sure, go for it. Link to comment Share on other sites More sharing options...
Jupiters Posted August 21, 2015 Author Share Posted August 21, 2015 @DarkXeroThank you Link to comment Share on other sites More sharing options...
Jupiters Posted August 25, 2015 Author Share Posted August 25, 2015 @DarkXeroa problem occurred. Ice Flingomatic can be destroyed by bearger. I need your help. Link to comment Share on other sites More sharing options...
DarkXero Posted August 25, 2015 Share Posted August 25, 2015 @Jupiters, you are missing,"firesuppressor"from your structure list to protect. Link to comment Share on other sites More sharing options...
Jupiters Posted August 26, 2015 Author Share Posted August 26, 2015 @DarkXeroOoooooooooooh....you are right. I forgot it. Link to comment Share on other sites More sharing options...
Jupiters Posted September 10, 2015 Author Share Posted September 10, 2015 Hello @DarkXero This mod seems to collide with the mod "Advanced World Generation and Cave Content".Need you help. Here is the log: [00:00:41]: [string "scripts/prefabs/altar_prototyper.lua"]:202: attempt to index field 'workable' (a nil value)LUA ERROR stack traceback:scripts/prefabs/altar_prototyper.lua:202 in (upvalue) SetState (Lua) <198-211> inst = 114036 - ancient_altar (valid:true) state = truescripts/prefabs/altar_prototyper.lua:262 in (method) OnLoad (Lua) <257-263> inst = 114036 - ancient_altar (valid:true) data = table: 051E2FD8scripts/entityscript.lua:1455 in (method) SetPersistData (Lua) <1440-1457> self (valid:true) = GUID = 114036 Transform = Transform (2DCFC578) inlimbo = false actionreplica = table: 2DDBB0A8 event_listening = table: 2DDBC138 actioncomponents = table: 2DDBAF18 displaynamefn = function - scripts/prefabs/altar_prototyper.lua:322 lower_components_shadow = table: 2DDBAEC8 _activecount = 0 entity = Entity (2DD75BA0) AnimState = AnimState (2DCFC598) prefab = ancient_altar Light = Light (2DCFC618) OnSave = function - scripts/prefabs/altar_prototyper.lua:265 Network = Network (2DCFC638) persists = true MiniMapEntity = MiniMapEntity (2DCFC5B8) SoundEmitter = SoundEmitter (2DCFC5D8) pendingtasks = table: 2DDDCC88 state = net_bool (2DD82100) event_listeners = table: 2DDBC070 spawntime = 0 OnLoad = function - scripts/prefabs/altar_prototyper.lua:257 replica = table: 2DDBAF40 name = Ancient Pseudoscience Station components = table: 2DDBAEF0 Physics = Physics (2DCFC5F8) data = table: 051E2FD8 newents = table: 132CDF88scripts/mainfunctions.lua:217 in (global) SpawnSaveRecord (Lua) <186-224> saved = table: 051E2FB0 newents = table: 132CDF88 inst = 114036 - ancient_altar (valid:true)scripts/gamelogic.lua:413 in (upvalue) PopulateWorld (Lua) <234-448> savedata = table: 0630D858 profile = table: 079EB028 world = 100022 - forest (valid:true) retune = table: 132CD128 newents = table: 132CDF88 prefab = ancient_altar ents = table: 051E2F88 prefab = ancient_altar k = 1 v = table: 051E2FB0scripts/gamelogic.lua:639 in (upvalue) DoInitGame (Lua) <527-741> savedata = table: 0630D858 profile = table: 079EB028 was_file_load = falsescripts/gamelogic.lua:773 in (upvalue) cb (Lua) <768-774> savedata = table: 0630D858scripts/saveindex.lua:124 in () ? (Lua) <106-125> load_success = true str = return {world_network={persistdata={clock={moonphase="quarter",cycles=83,phase="day",remainingtimeinphase=175.04804992676,totaltimeinphase=240,segs={night=2,day=8,dusk=6}},seasons={elapseddaysinseason=13,premode=false,remainingdaysinseason=7,lengths={summer=15,autumn=20,spring=20,winter=15},totaldaysinseason=20,mode="cycle",season="autumn",segs={summer={night=4,day=11,dusk=1},autumn={night=2,day=8,dusk=6},spring={night=3,day=5,dusk=8},winter={night=6,day=5,dusk=5}}},weather={seasontemperature=22.5,preciptype="rain",daylight=true,moistureceil=8175.3959960938,peakprecipitationrate=0.2890365421772,season="autumn",moisturerateval=0.33174451956625,lightningmode="rain",moistureceilmultiplier=8,moisture=3779.7485351563,wet=true,stopsnowthreshold=0,snowlevel=0,moisturefloormultiplier=1,moisturerateoffset=0,noisetime=40181.7421875,moisturerate=0.33174452185631,wetness=100,nextlightningtime=42.701252688882,startsnowthreshold=-5,precipmode="dynamic",moisturefloor=2408.4946289063,moistureratemultiplier=1,phasetemperature [**truncated**] success = true savedata = table: 0630D858=[C]:-1 in (method) GetPersistentString © <-1--1>scripts/saveindex.lua:106 in (method) GetSaveDataFile (Lua) <105-126> self = data = table: 079EB140 current_slot = 1 file = session/010000A97F0F71AA/0000000086 cb = function - scripts/gamelogic.lua:768scripts/saveindex.lua:132 in (method) GetSaveData (Lua) <128-136> self = data = table: 079EB140 current_slot = 1 slot = 1 cb = function - scripts/gamelogic.lua:768 file = session/010000A97F0F71AA/0000000086scripts/gamelogic.lua:775 in (upvalue) DoLoadWorld [00:00:41]: [string "scripts/prefabs/altar_prototyper.lua"]:202: attempt to index field 'workable' (a nil value)LUA ERROR stack traceback: scripts/prefabs/altar_prototyper.lua:202 in (upvalue) SetState (Lua) <198-211> scripts/prefabs/altar_prototyper.lua:262 in (method) OnLoad (Lua) <257-263> scripts/entityscript.lua:1455 in (method) SetPersistData (Lua) <1440-1457> scripts/mainfunctions.lua:217 in (global) SpawnSaveRecord (Lua) <186-224> scripts/gamelogic.lua:413 in (upvalue) PopulateWorld (Lua) <234-448> scripts/gamelogic.lua:639 in (upvalue) DoInitGame (Lua) <527-741> scripts/gamelogic.lua:773 in (upvalue) cb (Lua) <768-774> scripts/saveindex.lua:124 in () ? (Lua) <106-125> =[C]:-1 in (method) GetPersistentString © <-1--1> scripts/saveindex.lua:106 in (method) GetSaveDataFile (Lua) <105-126> scripts/saveindex.lua:132 in (method) GetSaveData (Lua) <128-136> scripts/gamelogic.lua:775 in (upvalue) DoLoadWorld (Lua) <767-776>Advanced World Generation and Cave Content.zipInvincible Structures.zip Link to comment Share on other sites More sharing options...
DarkXero Posted September 10, 2015 Share Posted September 10, 2015 @Jupiters, uselocal function Swap(inst) inst:DoTaskInTime(1, function() inst.components.hammerworkable = inst.components.workable inst.components.workable = nil end)endso the workable component gets loaded properly before swapping. Link to comment Share on other sites More sharing options...
Jupiters Posted September 10, 2015 Author Share Posted September 10, 2015 @DarkXero, Thank you! Link to comment Share on other sites More sharing options...
Jupiters Posted September 12, 2015 Author Share Posted September 12, 2015 (edited) Hello, @DarkXero In another mod's modmain.lua, I wrote this to make the giant not take the initiative to attack players' structure. local require = GLOBAL.requirelocal combat = require "components/combat" local combat_CanTarget_base = combat.CanTargetfunction combat:CanTarget(target, ...) if target:HasTag("structure") and self.inst:HasTag("monster") or self.inst:HasTag("epic") then return false end return combat_CanTarget_base(self, target, ...)end But it has a crash: [09:09:30]: [string "../mods/workshop-502999570/modmain.lua"]:6: attempt to index local 'target' (a nil value)LUA ERROR stack traceback:../mods/workshop-502999570/modmain.lua:6 in (method) CanTarget (Lua) <5-10>self =hiteffectsymbol = torsoGetGiveUpString = function - scripts/prefabs/player_common.lua:10defaultdamage = 10forcefacing = trueinst = 212111 - wathgrithr (valid:true)hitrange = 2lastwasattackedtime = 32809.868377835playerdamagepercent = 1pvp_damagemod = 0.5GetBattleCryString = function - scripts/prefabs/player_common.lua:14lastattacker = 211119 - mosquito (valid:true)damagemultiplier = 1.25keeptargettimeout = 0battlecryenabled = true_ = table: 270920B0laststartattacktime = 0target = nilarg = nilscripts/components/playercontroller.lua:753 in (method) OnRemoteControllerAttackButton (Lua) <740-771>self =isclientcontrollerattached = truepredictionsent = falsecontroller_target_age = 1.#INFdraggingonground = falsedeploy_mode = trueinst = 212111 - wathgrithr (valid:true)remote_vector = (84.59, 0.00, 563.26)can_use_map = truemap = Map (12663548)classified = 212112 - player_classified (valid:true)is_map_enabled = truedirectwalking = falselocomotor = table: 270900F8time_direct_walking = 0.16666667535901ismastersim = truemousetimeout = 10predictwalking = falseremote_controls = table: 424CD500dragwalking = falsetarget = nilisreleased = nilnoforce = nilscripts/networkclientrpc.lua:97 in () ? (Lua) <94-99>player = 212111 - wathgrithr (valid:true)target = nilisreleased = nilnoforce = nilplayercontroller = table: 424C7768=[C]:-1 in (method) CallRPC © <-1--1>scripts/networkclientrpc.lua:484 in (global) HandleRPCQueue (Lua) <475-492>i = 1fn = function - scripts/networkclientrpc.lua:94sender = 212111 - wathgrithr (valid:true)data = table: 3F38CE28tick = truescripts/update.lua:47 in () ? (Lua) <39-123>dt = 0.016668831929564[09:09:30]: [string "../mods/workshop-502999570/modmain.lua"]:6: attempt to index local 'target' (a nil value)LUA ERROR stack traceback:../mods/workshop-502999570/modmain.lua:6 in (method) CanTarget (Lua) <5-10>scripts/components/playercontroller.lua:753 in (method) OnRemoteControllerAttackButton (Lua) <740-771>scripts/networkclientrpc.lua:97 in () ? (Lua) <94-99>=[C]:-1 in (method) CallRPC © <-1--1>scripts/networkclientrpc.lua:484 in (global) HandleRPCQueue (Lua) <475-492>scripts/update.lua:47 in () ? (Lua) <39-123>[09:09:30]: SCRIPT ERROR! Showing error screen What's wrong with it? Edited September 12, 2015 by Jupiters Link to comment Share on other sites More sharing options...
DarkXero Posted September 12, 2015 Share Posted September 12, 2015 @Jupiters, should belocal require = GLOBAL.requirelocal combat = require "components/combat" local combat_CanTarget_base = combat.CanTargetfunction combat:CanTarget(target, ...) if target and target:HasTag("structure") and (self.inst:HasTag("monster") or self.inst:HasTag("epic")) then return false end return combat_CanTarget_base(self, target, ...)end Link to comment Share on other sites More sharing options...
Jupiters Posted September 14, 2015 Author Share Posted September 14, 2015 @Jupiters, should belocal require = GLOBAL.requirelocal combat = require "components/combat" local combat_CanTarget_base = combat.CanTargetfunction combat:CanTarget(target, ...) if target and target:HasTag("structure") and (self.inst:HasTag("monster") or self.inst:HasTag("epic")) then return false end return combat_CanTarget_base(self, target, ...)end Oh, that's it. Thank you very much! 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