markyrocks Posted August 24, 2018 Share Posted August 24, 2018 (edited) its driving me nuts. everything seems to be fine until it gets to the registerlessthandistance event. It compiles when i hit the compile button but wont save. Ive stared at it ive changed these couple lines at least 50 times... losing it honestly Scriptname RobotRemix:aRemix extends ObjectReference Const {activate furniture} Message Property jMessage Auto Const Furniture Property iBench Auto Const {RobotWorkbench} MiscObject Property stim Auto Const FormList Property menu Auto Const FormList Property topList Auto Const {topList} Keyword Property aKeyword Auto Const ObjectReference iBenchRef Event OnInit() ObjectReference[] LinkedRefs = GetLinkedRefChildren(aKeyword) int i = 0 while (i < LinkedRefs.length) ;this should give an arrary of refs of robot benches.... if (!LinkedRefs[i].IsNearPlayer()) else iBenchRef = LinkedRefs[i] endif i += 1 function(iBenchRef) endwhile EndEvent function iBench1(iBenchRef) RegisterForDistanceLessThanEvent(Game.GetPlayer(), iBenchRef) endfunction Event OnDistanceLessThan(Game.GetPlayer(), iBenchRef, 5.0) Debug.Trace("Player is now " + afDistance + " units away from the bird - fly away!") endEvent UnregisterForDistanceEvents(Game.GetPlayer(), iBenchRef) this is a last resort, no matter what i do it won't work. anyhelp is much appreciated thanks Edited August 24, 2018 by markyrocks Link to comment Share on other sites More sharing options...
Reneer Posted August 24, 2018 Share Posted August 24, 2018 (edited) UnregisterForDistanceEvents needs to be inside an event or function. Also there are other problems like your "function(iBenchRef)" call which isn't how you call functions. I'd explain in more detail but I'm on mobile. And your OnDistanceLessThan event parameters are wrong - they are variables, not values. And your RegisterForDistanceLessThanEvent call is missing a third parameter. Edited August 24, 2018 by Reneer Link to comment Share on other sites More sharing options...
SKKmods Posted August 24, 2018 Share Posted August 24, 2018 (edited) To expand on Monsieur Fox's valuable insights: You probably want to use OnLoad() which will refresh at every visit rather than OnInit() which is less frequent at cell reset. If you want this responsive to real time events you may end up with an event registration to WorkshopParent.WorkshopObjectBuilt() The while loop could find multiple ibenchRefs but you don't store each persistent, or bail out at the first so the last one will win. Call to function(iBenchRef) should be iBench1(iBenchRef) Declaration of function iBench1(iBenchRef) should be Function iBench1(ObjectReference AnyNameYouWant) RegisterForDistanceLessThanEvent(Game.GetPlayer(), AnyNameYouWant, 64.0) needs a distance 5.0 is far too small may never make that collision, player height is 128 units. You don't put values into event headers, use the vanilla declaration then test for values: Event OnDistanceLessThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance) If (akObj1 == Game.getPlayer()) && (akObj2 == iBenchREF) && (afDistance <= 64.0) ; dont really need the distance here just filling in for example UnregisterForDistanceEvents(Game.GetPlayer(), iBenchRef) ;do stuff EndifEndEvent Edited August 24, 2018 by SKK50 Link to comment Share on other sites More sharing options...
markyrocks Posted August 24, 2018 Author Share Posted August 24, 2018 Also there are other problems like your "function(iBenchRef)" call which isn't how you call functions. I'd explain in more detail but I'm on mobile. And your OnDistanceLessThan event parameters are wrong - they are variables, not values. And your RegisterForDistanceLessThanEvent call is missing a third parameter.Lol, that function call, ya that's called being tired and a symptom of the built in editor being utter trash. As far as the 3rd parameter, that's exactly how it shows it on the reference page.... I thought the exact same thing. Idk thanks for the input. Link to comment Share on other sites More sharing options...
markyrocks Posted August 24, 2018 Author Share Posted August 24, 2018 @skk50 I definitely appreciate the response. I was a little confused as to what onload() meant exactly. Does unload basically mean that the 3d object is in the players LOS? Or newly built. As far as the iBenchRef only finding one instance, I was aware of that flaw but I was trying to get something working and then add stuff later to handle all scenarios. This language is really a pain. I'm just going to start putting everything into functions bc these rules where certain things have to be in events or functions is pretty annoying. I realize that the example shows it that way but the description doesn't say so and when I see that I dont automatically assume its required (but I guess I better start) I would just assume they're doing the example that way just for kicks or w/e. The other thing on the topic of the example is that the distance wasn't even meantioned as far as what the unit of measure was, that definitely crossed my mind. Also the distance variable in the registration example is missing. You put all those things together and it kinda points to the wikis being incomplete and having errors of there own. Literally if it said "must be in a function" I would have done so and a problem that I messed with for hours would have been fixed in minutes. That was what started the whole thing off. After that I out it in a function anyways bc I thought maybe iBenchRefs wasn't able to be passed for some reason. Idk, I e said it b4 but this language is crazy formal. I've studied some c++ and autoit and I've never come across rules like this. Link to comment Share on other sites More sharing options...
SKKmods Posted August 24, 2018 Share Posted August 24, 2018 (edited) I was where U are 18 months ago ... the object and function declaration model is singular and the documentation quality and language is shocking even if your working with jewels and dragons. The best thing to do is to find an object or process in the game that is doing roughly what you want and look its forms and scripts. Which is why I was asking what outcome you want to point you at working models. I tried to AVOID doing this for months and learn from fundamental principles as I have an aversion to monkey-see monkey-do push button youtube copy learning. Didn't work out well, so ended up unpacking and unpicking the base game scripts like the many thousands before me. Another thing to look out for. The Skyrim narrative is generally far better, but the functions have sometimes changed (or been withdrawn) from that to Fallout4 so if you find yourself looking at https://www.creationkit.com/index.php page always check if there is a fallout 4 update at https://www.creationkit.com/fallout4 many fun hours wasted trying to get non existent functions working there. Example: google "creationkit onload" read the skyrim page that will be first in the list then insert /fallout4/ in the url and check for changes. EDIT: Just a thought - learning the papyrus scripting part of CK can be like a bereavement, so copy a Kubler-Ross Change Curve and plot your journey on it. You are probably in the SHOCK stage right now. Edited August 24, 2018 by SKK50 Link to comment Share on other sites More sharing options...
markyrocks Posted August 24, 2018 Author Share Posted August 24, 2018 Ya I watched some videos but as I'm going I'm even finding things that the video authors even don't understand or just overlook. I like to use that information as a base but I actually want comprehension of what I'm doing, I don't want to to a specific thing and just do it that way bc it works. I want to understand why it works. I've definitely spent time looking at the base scripts really just back tracking where information comes from. I realize I can't see everything bc some of it is hidden. It would be nice if we had access to the Source code just to see how certain things function. An example of that is I'm trying to determine where the initial menu for the robot workbench originates from and I find everything up (working backwards) up to the main menu or toplist, but b4 that a message pops up with the name of robot companions and an option for a new automatron. I can't find where that comes from. I've found the function that figures out which robot companions you have but that's as far as I've been able to trace it. I'd assume the rest is hidden. I'm probably wrong but I've spent hours looking for it Link to comment Share on other sites More sharing options...
Reneer Posted August 24, 2018 Share Posted August 24, 2018 (edited) The vast majority of menu related things are stored away in Flash / Scaleform menus (which are themselves in a BA2 file) and they interact with game objects in less than clear ways because the AS3 code can do things that Papyrus literally can't. Also, I think SKK has some excellent advice, especially regarding the Wiki. Edited August 24, 2018 by Reneer Link to comment Share on other sites More sharing options...
markyrocks Posted August 24, 2018 Author Share Posted August 24, 2018 Also, I think SKK has some excellent advice, especially regarding the Wiki.You are absolutely correct, the man knows his stuff. Ok so let's talk about the while loop. If I remove the ! In front of the array linkedrefs will it reverse the logic? Like as it stands that line. If (!linkedrefs.isnearplayer()) returns true if the reference is not near the player. If I remove the ! Will it return true if the ref is near the player? Link to comment Share on other sites More sharing options...
Evangela Posted August 24, 2018 Share Posted August 24, 2018 (edited) if bool (if it's true) ; things happenelse ; nothing or something else happensendif if !bool (if it's false) ; things happenelse ; nothing or something else happensendif ========================= if bool == true if bool == false and also.. if bool != true if bool != false I prefer the bool == true/false thing because it's less confusing. Edited August 24, 2018 by Rasikko Link to comment Share on other sites More sharing options...
Recommended Posts