ozziefire Posted July 16, 2016 Share Posted July 16, 2016 (edited) I've done a fair bit of scripting ok in GECK but never done Papyrus before so this is my first script attempt: I've basically made a copy of the Wedding ring, I have the following script attached to it, the idea being that the wearer slowly regenerates health if they have no Rads, and that they will also regenerate rads slowly too. But I'm having some really basic problems with the structure and some basic problems, I can't get it to compile.I'm under the impression OnEquip and OnUnequip are one shot edge triggers, but I could be wrong. So I'm trying to set a bool then use that to check if the Main part should be running. Scriptname SuperPowerScript extends ObjectReference native bool bItemWorn ; it doesn't seem to like this, how am I to tell my main part to keep running or am I wrong in assuming OnEquip is an edge trigger? Event OnEquip() bItemWorn = 1 EndEvent Function MainPart () if (bItemWorn) float fPowerLevel actor akActor = GetActorOwner() ; I'm trying to set the wearing actor here, I'm doing it wrong float fActorRads = akActor.GetActorValue ("Rads") float fActorHealth = akActor.GetActorValue ("Health") int iCurrRads = fActorRads int iPrevRads iRadDamage = iPrevRads - iCurrRads if (fActorRads <= 0) if (fActorHealth < 100) ; Assuming 100% = 100) fActorHealth = fActorHealth + 1 akActor.SetValue ("Health", fActorHealth) DefaultScriptFunctions.DefaultScriptTrace(self + ":Healing") endif else if (iRadDamage < 1) fActorRads = fActorRads - 1 akActor.SetValue ("Rads", fActorRads) endif endif iPrevRads = iCurrRads endif EndFunction Event OnUnequip() bItemWorn = 0 EndEventCompiler Output:Papyrus Compiler Version 2.8.0.4 for Fallout 4Copyright © ZeniMax Media. All rights reserved.Starting 1 compile threads for 1 files...Compiling "SuperPowerScript"...C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(3,1): native scripts may not contain data, script variable bItemWorn cannot be definedNo output generated for SuperPowerScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on SuperPowerScriptI tries removing native and it says it has to be native, I tried const and get similar issues.I'm a little confused on whether the main should be a function and if it how to call it every 10 seconds RealTime or 30seconds Gametime Edited July 16, 2016 by ozziefire Link to comment Share on other sites More sharing options...
Reneer Posted July 16, 2016 Share Posted July 16, 2016 The first thing you will want to do is remove the "native" bit from your Scriptname line. Link to comment Share on other sites More sharing options...
ozziefire Posted July 16, 2016 Author Share Posted July 16, 2016 (edited) Ok did that and now get this: Papyrus Compiler Version 2.8.0.4 for Fallout 4 Copyright © ZeniMax Media. All rights reserved. Starting 1 compile threads for 1 files... Compiling "SuperPowerScript"... C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(5,0): new event onequip cannot be defined because the script is not flagged as native C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(12, :cool:: type mismatch while assigning to a actor (cast missing or types unrelated) C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(13,29): GetActorValue is not a function or does not exist C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(13, :cool:: type mismatch while assigning to a float (cast missing or types unrelated) C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(14,31): GetActorValue is not a function or does not exist C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(14, :cool:: type mismatch while assigning to a float (cast missing or types unrelated) C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(15,6): type mismatch while assigning to a int (cast missing or types unrelated) C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(17,2): variable iRadDamage is undefined C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(17,2): type mismatch while assigning to a none (cast missing or types unrelated) C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(22,22): type mismatch on parameter 1 - cannot pass a string to a actorvalue C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(23,27): argument showtrace is not specified and has no default value C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(26,7): variable iRadDamage is undefined C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(26,18): cannot compare a none to a int (cast missing or types unrelated) C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(26,18): cannot relatively compare variables to None C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(28,22): type mismatch on parameter 1 - cannot pass a string to a actorvalue C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(35,0): new event onunequip cannot be defined because the script is not flagged as native No output generated for SuperPowerScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on SuperPowerScriptAny idea what the 2nd, 3rd, 4th etc things I ned to do now? :smile: Edited July 16, 2016 by ozziefire Link to comment Share on other sites More sharing options...
PoliteRaider Posted July 16, 2016 Share Posted July 16, 2016 I know this doesn't necessarily help as Papyrus advice, but if the important part is getting the ring to do what you want then I think you could get the same result with a Magic Effect placed on the ring using the conditions tab in the Creation Kit to change how it functions when the player character isn't irradiated. However if you're doing this to practice Papyrus scripting then I get why you'd want to do it this way though. I'm a total novice at scripting so take my advice with a pinch of salt but here's some suggestions. 1. According to the payprus information on the OnEquipped event "When an object is equipped it is inside a container, which means that you cannot call native functions on it. (Unless it is a persistent reference)" 2. Shouldn't it be akActor.getvalue rather than akActor.getactorvalue. 3. GetActorOwner is used for getting the base owner, i.e. it's owned by a person belonging to the gunner template rather than this particular individual gunner. You should be using GetActorRefOwner. 4. You're just pulling GetActorOwner out of thin air, it needs to be TheObjectYou'reReferringTo.GetActorOwner. Otherwise the compiler will be wondering "owner of what?". I'm not sure that's everything, but there's some problems I can spot. Link to comment Share on other sites More sharing options...
ozziefire Posted July 16, 2016 Author Share Posted July 16, 2016 I know this doesn't necessarily help as Papyrus advice, but if the important part is getting the ring to do what you want then I think you could get the same result with a Magic Effect placed on the ring using the conditions tab in the Creation Kit to change how it functions when the player character isn't irradiated. However if you're doing this to practice Papyrus scripting then I get why you'd want to do it this way though. I'm a total novice at scripting so take my advice with a pinch of salt but here's some suggestions. 1. According to the payprus information on the OnEquipped event "When an object is equipped it is inside a container, which means that you cannot call native functions on it. (Unless it is a persistent reference)" 2. Shouldn't it be akActor.getvalue rather than akActor.getactorvalue. 3. GetActorOwner is used for getting the base owner, i.e. it's owned by a person belonging to the gunner template rather than this particular individual gunner. You should be using GetActorRefOwner. 4. You're just pulling GetActorOwner out of thin air, it needs to be TheObjectYou'reReferringTo.GetActorOwner. Otherwise the compiler will be wondering "owner of what?". I'm not sure that's everything, but there's some problems I can spot.Cool, thanks for the advice, yes its a learning experience I have much grander plans later of course and other mods planned, so I thought I'd start with something simple and build on it when it works rather than drop 200 lines of "Why won't this work?" on others :smile: I'll poke around with it more tomorrow and do some more wiki reading on the functions and see if I can get it compiled and firing. Link to comment Share on other sites More sharing options...
PoliteRaider Posted July 16, 2016 Share Posted July 16, 2016 Good luck. I pretty much need the papyrus reference constantly open while I script and work line by line. Even then I spend just as much time bug-fixing.It's a slow and painstaking process but it works and I'm learning as I go. It's a good idea to start with something a bit smaller. I'm trying to make a much more complicated script at the moment, so I've been going a bit cross-eyed from staring at the code and references and figuring it all out. I don't usually have the sense to start small I'm afraid. Link to comment Share on other sites More sharing options...
ozziefire Posted July 17, 2016 Author Share Posted July 17, 2016 (edited) Ok now I have this, SuperRing is the name of the object the script is attached to, its just a copy of the WeddingRingScriptname SuperPowerScript extends ObjectReference Event OnLoad() float fPowerLevel actor akActor = SuperRing.GetActorRefOwner() float fActorRads = akActor.GetValue ("Rads") float fActorHealth = akActor.GetValue ("Health") if (akActor.GetEquipped(SuperRing)) int iCurrRads = fActorRads int iPrevRads int iRadDamage = iPrevRads - iCurrRads if (fActorRads <= 0) if (fActorHealth < 100) ; Assuming 100% = 100) fActorHealth = fActorHealth + 1 akActor.SetValue ("Health", fActorHealth) DefaultScriptFunctions.DefaultScriptTrace(self + ":Healing") endif else if (iRadDamage < 1) fActorRads = fActorRads - 1 akActor.SetValue ("Rads", fActorRads) endif endif iPrevRads = iCurrRads endif EndEventCompiling "SuperPowerScript"...C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(5,17): variable SuperRing is undefinedC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(5,27): none is not a known user-defined script typeC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(5,7): type mismatch while assigning to a actor (cast missing or types unrelated)C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(6,38): type mismatch on parameter 1 - cannot pass a string to a actorvalueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(6,7): type mismatch while assigning to a float (cast missing or types unrelated)C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(7,40): type mismatch on parameter 1 - cannot pass a string to a actorvalueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(7,7): type mismatch while assigning to a float (cast missing or types unrelated)C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(8,25): variable SuperRing is undefinedC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(8,13): GetEquipped is not a function or does not existC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(9,6): type mismatch while assigning to a int (cast missing or types unrelated)C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(16,22): type mismatch on parameter 1 - cannot pass a string to a actorvalueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(17,27): argument showtrace is not specified and has no default valueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(22,22): type mismatch on parameter 1 - cannot pass a string to a actorvalueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(8,1): cannot cast a void to a bool to perform a condition checkNo output generated for SuperPowerScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on SuperPowerScript Edited July 17, 2016 by ozziefire Link to comment Share on other sites More sharing options...
ozziefire Posted July 17, 2016 Author Share Posted July 17, 2016 (edited) Tried this too and failing because I realised OnLoad is also a one shot edge trigger by the looksScriptname SuperPowerScript extends ObjectReference auto state MainBit float fPowerLevel actor akActor = SuperRing.GetActorRefOwner() float fActorRads = akActor.GetValue ("Rads") float fActorHealth = akActor.GetValue ("Health") if (akActor.GetEquipped(SuperRing)) int iCurrRads = fActorRads int iPrevRads int iRadDamage = iPrevRads - iCurrRads if (fActorRads <= 0) if (fActorHealth < 100) ; Assuming 100% = 100) fActorHealth = fActorHealth + 1 akActor.SetValue ("Health", fActorHealth) DefaultScriptFunctions.DefaultScriptTrace(self + ":Healing") endif else if (iRadDamage < 1) fActorRads = fActorRads - 1 akActor.SetValue ("Rads", fActorRads) endif endif iPrevRads = iCurrRads endif EndStatePapyrus Compiler Version 2.8.0.4 for Fallout 4Copyright © ZeniMax Media. All rights reserved.Starting 1 compile threads for 1 files...Compiling "SuperPowerScript"...C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(3,7): missing FUNCTION at 'fPowerLevel'C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(3,18): mismatched input '\\r\\n' expecting LPARENC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperPowerScript.psc(0,0): error while attempting to read script SuperPowerScript: Object reference not set to an instance of an object.No output generated for SuperPowerScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on SuperPowerScript Edited July 17, 2016 by ozziefire Link to comment Share on other sites More sharing options...
lndn95 Posted July 17, 2016 Share Posted July 17, 2016 Hi, everyone. I have a question regarding modding and the creation kit and I'm wondering if anyone on here can help me. I've recently created a simple companion mod. He is a synth who is 99% complete. However, there are two issues. One, whenever he is damaged, electricity appears and won't go away. Two, he attacks almost everybody. I've attempted to tweak things here and there to resolve these issues but I haven't been able to yet. Is there anyone here who would have any suggestions? Thanks! Link to comment Share on other sites More sharing options...
ozziefire Posted July 17, 2016 Author Share Posted July 17, 2016 Ok looking through the CK I worked out that only 2 Armor items use scripts directly attached for whatever reason so changed direction to s script in a Magic Effect but still having similar issues :/Scriptname SuperEffects extends activemagiceffect Int Property NewProperty Auto Const Function SomeFunction() RegisterForUpdate(1.0) ; Before we can use OnUpdate() we must register. EndFunction Event OnUpdate() float fPowerLevel actor akActor = SuperRing.GetActorRefOwner() float fActorRads = akActor.GetValue ("Rads") float fActorHealth = akActor.GetValue ("Health") int iCurrRads = fActorRads int iPrevRads int iRadDamage = iPrevRads - iCurrRads if (fActorRads <= 0) if (fActorHealth < 100) ; Assuming 100% = 100) fActorHealth = fActorHealth + 1 akActor.SetValue ("Health", fActorHealth) DefaultScriptFunctions.DefaultScriptTrace(self + ":Healing") endif else if (iRadDamage < 1) fActorRads = fActorRads - 1 akActor.SetValue ("Rads", fActorRads) endif endif iPrevRads = iCurrRads EndEventPapyrus Compiler Version 2.8.0.4 for Fallout 4Copyright © ZeniMax Media. All rights reserved.Starting 1 compile threads for 1 files...Compiling "SuperEffects"...C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(6,1): RegisterForUpdate is not a function or does not existC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(12,17): variable SuperRing is undefinedC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(12,27): none is not a known user-defined script typeC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(12,7): type mismatch while assigning to a actor (cast missing or types unrelated)C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(13,38): type mismatch on parameter 1 - cannot pass a string to a actorvalueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(13,7): type mismatch while assigning to a float (cast missing or types unrelated)C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(14,40): type mismatch on parameter 1 - cannot pass a string to a actorvalueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(14,7): type mismatch while assigning to a float (cast missing or types unrelated)C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(15,5): type mismatch while assigning to a int (cast missing or types unrelated)C:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(22,21): type mismatch on parameter 1 - cannot pass a string to a actorvalueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(23,26): argument showtrace is not specified and has no default valueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(28,21): type mismatch on parameter 1 - cannot pass a string to a actorvalueC:\Users\Owner\AppData\Local\Temp\PapyrusTemp\SuperEffects.psc(9,0): new event onupdate cannot be defined because the script is not flagged as nativeNo output generated for SuperEffects, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on SuperEffects Link to comment Share on other sites More sharing options...
Recommended Posts