Stikyhooves Posted April 26, 2016 Share Posted April 26, 2016 Hey folks. I think this may be my first post. I am having an issue with a stategraph for my character mod. Here is the scenario: (the working parts first for background) Custom character has a rifle. The rifle is re loadable with a crafted clip. - this part works great. (thank you to Ecu and his Blowgun-revamped for a lot of the coding I borrowed for this. ) The loading the rifle currently uses a local function, AddAction, Actionhandler, and AddStategraphActionHandler to cause doing the reload in game to que the "dolongaction" bit. - This works great and I like it. (additionally much borrowed from Ecu I think... but it has been a while and this code was revamped quite a bit) I have this working for both client and server. Here is where my trouble comes in: There are also AddActions, Actionhandlers, and AddStategraphActionHandlers for the act of shooting the gun. (Thanks to ZupaleX for the excellent Archery mod - I did borrow considerably from this) Right now the mod works great when I am hosting, but if anyone else is hosting the mod crashes when I fire the gun. Other than that there are no issues. The crash log. [00:02:20]: [string "scripts/actions.lua"]:573: attempt to index field 'combat' (a nil value) LUA ERROR stack traceback: scripts/actions.lua:573 in (field) fn (Lua) <572-575> scripts/bufferedaction.lua:24 in (method) Do (Lua) <20-34> scripts/entityscript.lua:1234 in (method) PerformBufferedAction (Lua) <1226-1244> ../mods/Wren 0.10 - 754/modmain.lua:494 in (field) fn (Lua) <491-496> scripts/stategraph.lua:568 in (method) UpdateState (Lua) <536-580> scripts/stategraph.lua:607 in (method) Update (Lua) <599-627> scripts/stategraph.lua:125 in (method) Update (Lua) <109-148> scripts/update.lua:209 in () ? (Lua) <150-223> My understanding here is that I am not correctly setting up my initial references. to the combat action. I don't think that the issue is in the 'bulk' of the stategraph. All of the below code is in my modmain Here is my action code: (also, I am aware right now that this code results in the blowdart being swung like a melee weapon. I can fix that, but it is not a priority right now) local newshootaction_client local function newshootaction_client(inst) if not (inst.replica.health:IsDead() or inst.sg:HasStateTag("attack")) then local weapon = inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) or nil if weapon and weapon:HasTag("sniper_rifle") and not inst.sg:HasStateTag("attack") and inst.replica.combat then if inst.replica.combat then return (weapon:HasTag("sniper_rifle") and "snipershot") end else return "attack" end end end AddStategraphActionHandler("wilson_client", ActionHandler(ACTIONS.ATTACK, newshootaction_client)) Here is the heading of my stategraph. (I am happy to post the whole thing if that is helpful, but it is very long): local snipershot_client = State({ name = "snipershot", tags = { "attack", "notalking", "abouttoattack", "autopredict" }, onenter = function(inst) local buffaction = inst:GetBufferedAction() local target = buffaction ~= nil and buffaction.target or nil local equip = inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) local wornhat = inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) global_weapname = equip.prefab inst.components.locomotor:Stop() Here are my initial declarations that are in the modmain separate from a function: (I will confess that this is messy as I have multiple things going on) local resolvefilepath = GLOBAL.resolvefilepath -- What is this for? local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS local Text = require "widgets/text" local Image = require "widgets/image" local Recipe = GLOBAL.Recipe local RECIPETABS = GLOBAL.RECIPETABS local TECH = GLOBAL.TECH ---------------------------FROM GUN-------- local FRAMES = GLOBAL.FRAMES local ACTIONS = GLOBAL.ACTIONS local State = GLOBAL.State local EventHandler = GLOBAL.EventHandler local ActionHandler = GLOBAL.ActionHandler local TimeEvent = GLOBAL.TimeEvent local EQUIPSLOTS = GLOBAL.EQUIPSLOTS local require = GLOBAL.require GLOBAL.INVINFO = {} ----------------------------- local global_facing local global_targetisok local global_gunisloaded local global_conditions_fulfilled local global_weapname I feel like I know just enough to get in deep but still make rookie mistakes. Hopefully what I am missing will be obvious to someone here. I've been stabbing at this for a week now and just can't get it quite right. Any help would be appreciated. Otherwise I will just keep using my rifle like a blowgun in my non-hosted games. (in my alternate 'client friendly' version) Bonus question: On an unrelated note, in case someone feels they know. I also can't use my gun in melee range. I don't mind this because it seems like a bad idea, but I am not sure why this is taking place. I assume this has to do with tags in the weapon's prefab. Link to comment https://forums.kleientertainment.com/forums/topic/66719-client-stategraph-issue-question/ Share on other sites More sharing options...
Ecu Posted April 27, 2016 Share Posted April 27, 2016 Just popping in to give ya a lil bump and to let you know that I'm glad someone got use out of my code. I couldn't figure out how to do the animation for it, so never managed to get it working perfectly. It is good to hear that you got use out of it none the less. Link to comment https://forums.kleientertainment.com/forums/topic/66719-client-stategraph-issue-question/#findComment-758619 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