RngrHawk Posted August 14, 2016 Share Posted August 14, 2016 Hello community! I have a problem with a script. I'm trying the make a quick workaround for the ModScrapScalar crap that doesn't work properly, because Bethesda... Scriptname SSS_s_AddItem_BasketballHoop02 extends Quest MiscObject Property BaskeballHoopParts auto const Event OnWorkshopObjectDestroyed(ObjectReference BaskeballHoop01NoPole) Game.GetPlayer().AddItem(BaskeballHoopParts, 1, false) EndEvent I am new to modding on the CK, and especially the scripting part. What I am trying to achieve is:Every time I scrap a specific object, the player receives an item into his/her inventory. From my very short term memory and some experience, I guess I need to do it through a Quest so that it keeps running? By the way, if anyone knows how the ModScrapScalar works in detail, please also give some hints. The problem is, if I want the scalar to return back 100% of the components, it will do that, but not if the amount is 1... then it just returns nothing. Thanks for any help in advance! Link to comment Share on other sites More sharing options...
FatsackTony1 Posted August 14, 2016 Share Posted August 14, 2016 (edited) in the lineEvent OnWorkshopObjectDestroyed(ObjectReference BaskeballHoop01NoPole) That is an output variable name, not the place for an input. It's telling you what parameters the function is passing to you and what data type they are. take out baskeballhoop01nopole and replace it with what it should be from the ck wiki. it should be something like akTarget or something than add a property at the top of the script like: ObjectReference Property basketballhoop Auto and then within the event doif (basketballhoop == akTarget) ***or whatever the handle is from the ck*** do code stuff hereendif then in the ck or fo4 make the property the form id of the baskeballhoop01 thing you want to add. You need to use properties to communicate forms to papyrus. Edited August 14, 2016 by FatsackTony1 Link to comment Share on other sites More sharing options...
RngrHawk Posted August 14, 2016 Author Share Posted August 14, 2016 Ah, this is somewhat familiar! Ok, thanks for the response, I'll give it a try in a bit :P Unfortunately, I'm having a bit of trouble with CK right at this second, so might take a while! Link to comment Share on other sites More sharing options...
FatsackTony1 Posted August 14, 2016 Share Posted August 14, 2016 you should be able to find whatever the correct handle for the event is on the ck wiki. heres a link http://www.creationkit.com/index.php?title=Category:Events Link to comment Share on other sites More sharing options...
RngrHawk Posted August 14, 2016 Author Share Posted August 14, 2016 I think I saw it before, I was going through the wiki before I made this script :P I think it was akActionRef? Link to comment Share on other sites More sharing options...
RngrHawk Posted August 14, 2016 Author Share Posted August 14, 2016 Also do I need to activate this somehow through Stages inside the quest or not rly? Link to comment Share on other sites More sharing options...
RngrHawk Posted August 15, 2016 Author Share Posted August 15, 2016 (edited) OK I have this now: Scriptname SSS_s_AddItem_BasketballHoop02 extends Quest MiscObject Property BasketballHoopParts auto Event OnWorkshopObjectDestroyed(ObjectReference akActionRef) If (BasketballHoopParts == akActionRef) Game.GetPlayer().AddItem(BasketballHoopParts, 1, false) Endif EndEvent I get two errors: (5,25): cannot compare a miscobject to a objectreference (cast missing or types unrelated)(4,0): new event onworkshopobjectdestroyed cannot be defined because the script is not flagged as native The first one is pretty obvious, but how would I fix it? Also the second some keeps popping up, and I am not sure at all what it could mean D: Edited August 15, 2016 by marekto98 Link to comment Share on other sites More sharing options...
FatsackTony1 Posted August 15, 2016 Share Posted August 15, 2016 (edited) You may need to register your script for an the workshop destroy event, within an OnLoad event, and than put it in a quest that loads on game start. the error on line 5 is a data type mismatch, you can change the data type because one is a MiscObject and the other is a ObjectReference, you can "cast" it (think like casting molten metal in a forge to a new form) using the 'as' operator like this: victim = akTarget as actor or akActionRef as MiscObject But what you might be confusing is the Misc item, which is an entry in the inventory and a droppable object, like a weapon mod, or stimpack etc. With a placeable workshop object, which would be the object reference. I think they are 2 different form types. so you may have to add 2 properties, where the one in the IF statement would be the placeable workshop object cast as object reference, and then the misc inventory item, that gets added when the if statement is true. http://www.creationkit.com/fallout4/index.php?title=Quest_Script Error # 2 on line 4 is a problem because it does not recognize OnWorkshopItemDestroyed as a native event. Native in this case meaning part of the vanilla game. You can create custom events of your own, but this is not something I've played around with much. But there is some information on how to on the ck wiki. It might be that your script extends Quest, which mean it extends the Quest script and so you only have available the functions and events to use that are within the quest script. If you extend ActiveMagicEffect, it would change the functions and events you can use, such as OnEffectStart, etc etc. check here. http://www.creationkit.com/fallout4/index.php?title=ObjectReference_Script soooo.... I think you may need to make your script extend ObjectReference, since you're calling an event from it, and than attach it to the placeable workshop item form. Edited August 15, 2016 by FatsackTony1 Link to comment Share on other sites More sharing options...
RngrHawk Posted August 15, 2016 Author Share Posted August 15, 2016 (edited) Oh yes, I just realized I was doing this a bit off. So 'BasketballHoopParts' would actually be a misc item that I can use in-game. On this note, akActionRef should equate to something else. Ah ok, I think I get it now. So I need to create a property similar to this I guess: ObjectReference Property BasketballHoopParts02 auto and then change the 'BasketballHoopParts' inside the if statement to 'BasketballHoopParts02'.Is this right? Also, the other problem. I do not fully understand the 'extends' business xD Before, I guessed it informed the script to what type it is for some sorting/accessing reason. Like I used something else instead of 'Quest' before, since I used the script inside a MiscItem instead of Quest, which was completely wrong. But I guess now that it doesn't do what I just said? xP Edited August 15, 2016 by marekto98 Link to comment Share on other sites More sharing options...
RngrHawk Posted August 15, 2016 Author Share Posted August 15, 2016 (edited) There we go, I've done what you just posted and it seemed to remove the first error, so it works. Didn't test it yet but I'm sure with a few Quest tweaks it's gonna work as intended. Also, I have extended it to ObjectReference and that also fixed the second problem :D Thank you so much for the help. I may need some more in a few minutes, i'm sure i'm gonna mess something up :tongue: For now, I will test the script to see if it works properly. Although! There is another problem already. ObjectReference only references to an existing object in a specific cell. How do I make it, or something else reference to an object I place with the workshop? Edited August 15, 2016 by marekto98 Link to comment Share on other sites More sharing options...
Recommended Posts