muddykat Posted May 4, 2015 Share Posted May 4, 2015 i'm currently working on a character mod (Bellatrix) I have an item which when equipped triggers a state graph and a transformation animation now all i have to do is change a variable to finish it off but it keeps crashing i already tried using owner./inst./self.inst.even though i kinda new it wouldn't work i still tried and failed so if anyone knows can give me a hand thanks here is the variables i needed to change and how i structured them if(damage=true) then damage=falseend if(daytime=true) then damage=trueend Link to comment Share on other sites More sharing options...
Mobbstar Posted May 4, 2015 Share Posted May 4, 2015 Please show the entire code. A stategraph instance can be referenced to by inst.sg EDIT: Wait hang on, isn't Bellatrix the really complicated bee queen character that entirely modifies bees without actually overriding anything in that relation? Link to comment Share on other sites More sharing options...
muddykat Posted May 5, 2015 Author Share Posted May 5, 2015 nopenot that mod all i want to do is change a variable in reference to the character when an item is eqiuped Link to comment Share on other sites More sharing options...
Blueberrys Posted May 5, 2015 Share Posted May 5, 2015 @muddykat Like this?-- In player scriptplayer_inst.val = 1-- In modmainprint(GLOBAL.GetPlayer().val) -- prints 1-- Elsewhereprint(GetPlayer().val) -- prints 1 Link to comment Share on other sites More sharing options...
muddykat Posted May 5, 2015 Author Share Posted May 5, 2015 ill test it out thanks ill give you feed back strait away Link to comment Share on other sites More sharing options...
muddykat Posted May 5, 2015 Author Share Posted May 5, 2015 @muddykat Like this?-- In player scriptplayer_inst.val = 1-- In modmainprint(GLOBAL.GetPlayer().val) -- prints 1-- Elsewhereprint(GetPlayer().val) -- prints 1Kind of like that execpt i need that value to change from 1 to 0 and back and fourthhere is the exact code that im using for my item local assets={ Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "ANIM", "anim/beard.zip" ),Asset( "ANIM", "anim/shadow_hands.zip" ), Asset("ANIM", "anim/cloak.zip"), Asset("ATLAS", "images/inventoryimages/cloak.xml")} local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_body", "cloak", "swap_body") owner.components.talker:Say(GetString(owner.prefab, "ANNOUNCE_NIGHTMAREFORM")) SpawnPrefab("statue_transition").Transform:SetPosition(inst:GetPosition():Get()) SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) owner.SoundEmitter:PlaySound("dontstarve/charlie/warn") owner.SoundEmitter:PlaySound("dontstarve/common/throne/thronemagic", "nightmaresound")owner.components.combat.damagemultiplier = 2.1owner.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 2)owner.components.health.maxhealth = 95owner.components.hunger.max = 100owner.components.locomotor.walkspeed = 4owner.components.locomotor.runspeed = 5owner.components.builder.magic_bonus = 2owner.components.builder.science_bonus = 0 owner.sg:GoToState("nightmareform")owner:AddTag("nonclonable")if(damage=true) then damage=falseendend local function onunequip(inst, owner) owner.AnimState:ClearOverrideSymbol("swap_body") SpawnPrefab("statue_transition").Transform:SetPosition(inst:GetPosition():Get()) SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) owner.SoundEmitter:PlaySound("dontstarve/charlie/warn") owner.SoundEmitter:PlaySound("dontstarve/creatures/knight_nightmare/voice")owner.talksoundoverride = "dontstarve/characters/bellatrix/talk_LP"owner.components.combat.damagemultiplier = .9owner.components.builder.magic_bonus = 1owner.components.builder.science_bonus = 0owner.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.05) owner.sg:GoToState("normalform")owner.SoundEmitter:KillSound("nightmaresound")owner:RemoveTag("nonclonable")if(daytime=true) then damage=trueendend local function fn(Sim)local inst = CreateEntity() inst.entity:AddTransform()inst.entity:AddAnimState() MakeInventoryPhysics(inst) inst.AnimState:SetBank("armor_grass") inst.AnimState:SetBuild("cloak") inst.AnimState:PlayAnimation("anim") inst:AddComponent("inspectable") inst:AddTag("irreplaceable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/cloak.xml" inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.BODY inst.components.equippable:SetOnEquip( onequip ) inst.components.equippable:SetOnUnequip( onunequip ) inst:AddComponent("insulator") inst.components.insulator.insulation = math.huge return instend return Prefab( "common/inventory/cloak", fn, assets ) Link to comment Share on other sites More sharing options...
Blueberrys Posted May 5, 2015 Share Posted May 5, 2015 @muddykat Ah.. well, I was just demonstrating how you can access variables associated with your character. The rest depends on your design, think of how you can use that to do what you want to do. eg.player_inst.damage = trueplayer_inst.damage = false-- ...if (GetPlayer().damage) then -- ...end Link to comment Share on other sites More sharing options...
muddykat Posted May 5, 2015 Author Share Posted May 5, 2015 cool thanks ill try it out Link to comment Share on other sites More sharing options...
RBD Posted May 6, 2015 Share Posted May 6, 2015 Your lack of brackets is awful... Link to comment Share on other sites More sharing options...
Mobbstar Posted May 6, 2015 Share Posted May 6, 2015 Your lack of brackets is awful... Pardon stranger? I would say there's even an excess of brackets in the if statements found on this thread. If your statement was meant to be sarcastic, then I'm afraid that the sarcasm wasn't clear enough. Generally speaking, it's a good idea to give reason for your statements. Link to comment Share on other sites More sharing options...
Blueberrys Posted May 6, 2015 Share Posted May 6, 2015 @RBD Perhaps you meant indents? Link to comment Share on other sites More sharing options...
muddykat Posted May 8, 2015 Author Share Posted May 8, 2015 Your lack of brackets is awful...lol its my first mod to ya know no one really has taught me how to adequately use brackets or indents or what ever you meant so if you know what your calling me on id be glad to take a lesson if not then would you kindly back off Link to comment Share on other sites More sharing options...
Blueberrys Posted May 8, 2015 Share Posted May 8, 2015 @muddykat My previous link defines what indents are. Here's quite a long article on indentation. I don't think you need to read all of it, just skim through and check out the examples. It's not using Lua either, so keep that in mind. For Lua, indentation will look something like this:local function something() -- Indented lines -- Indented linesendif some_bool then -- Indented lines -- Indented linesendfor k, v in pairs(some_table) do -- Indented lines -- Indented linesendAnd nested statements:local function something() -- Indented lines if some_bool then -- Indented if-statement -- Double indented lines -- Double indented lines end -- Indented end, same spacing as the corresponding if-statement above -- Indented linesend Link to comment Share on other sites More sharing options...
muddykat Posted May 8, 2015 Author Share Posted May 8, 2015 thanks man ill try and keep my code easy to read and nicely indented if you want you can have a look at the mod this was all for you can find it here http://forums.kleientertainment.com/files/file/1188-bellatrix-the-realistic-vampire/ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.