KlezmerGryphon Posted October 21, 2017 Share Posted October 21, 2017 Right, so in a player home that I'm working on, I have a unique shotgun you can repair and use (basically a rehash of the SMG in Doc Mitchell's place), but I'm having issues getting the script to work. Since I'm basing this off of the repairable weapon in Goodsprings, I figured I'd go ahead and copy the script and edit it for the specifics of the application, but this is not working so far. I can hit the activate button on the static gun all I want and nothing happens. Here's my current code, which is based off of the one found in Goodsprings; scn MechShopBrokenSGScript short Button begin OnActivate if IsActionRef player ShowMessage MechShopBrokenText endif end BEGIN GameMode set Button to GetButtonPressed if [ Button == 1 ] player.AddItemHealthPercent WeapHansShotgun 1 0.35 RewardXP 25 Disable endif endif END If anyone would happen to have a better way of going about this, I would greatly appreciate it! :) Link to comment Share on other sites More sharing options...
uhmattbravo Posted October 21, 2017 Share Posted October 21, 2017 Start by switching the game mode block to MenuMode. Does the script you copied use a GameMode block for that? I've used menuMode for all my message boxes. Also, it'd be wise to add a cancel or 'do nothing' button if there's a skill check to fix it. Otherwise, the player could be stuck in the menu if they don't meet the requirement. Link to comment Share on other sites More sharing options...
KlezmerGryphon Posted October 24, 2017 Author Share Posted October 24, 2017 Start by switching the game mode block to MenuMode. Does the script you copied use a GameMode block for that? I've used menuMode for all my message boxes. Also, it'd be wise to add a cancel or 'do nothing' button if there's a skill check to fix it. Otherwise, the player could be stuck in the menu if they don't meet the requirement. The original script I'm working from does use a GameMode block for that, but I went ahead and switched it out to MenuMode just to see if it would work with that; still no dice. I've gone through and double checked the message that's supposed to pop up, and the name's right. As someone rather new to scripting, I'm at a loss as to what might be wrong with it. Link to comment Share on other sites More sharing options...
dubiousintent Posted October 24, 2017 Share Posted October 24, 2017 Your conditional appears to not be complete for returning a "True/False" result. According to the example in the GECK wiki that function only works in a "OnActivate" block, and it should be: if IsActionRef Player == [0|1:int]Attempts at "shorthand" forms of expressions are always suspect when things don't seem to work correctly. -Dubious- Link to comment Share on other sites More sharing options...
Radioactivelad Posted October 26, 2017 Share Posted October 26, 2017 (edited) The Button portion needs to begin on "Menumode 1001". I have no idea what the 1001 means, but that's the Seddon tutorial says and It's worked for all my Button scripts. Odd that the smg in Doc's house uses Gamemode though. Also, you don't the need the "Isactionref Player" if you just set the Reference of the Object your attaching the script to be ignored by sandbox.And like Dubious says, you've forgotten to add a 1, declaring that the following event is supposed to happen when the ref is the Player. Edited October 26, 2017 by Radioactivelad Link to comment Share on other sites More sharing options...
KlezmerGryphon Posted November 2, 2017 Author Share Posted November 2, 2017 Well, I managed to get it working, at least somewhat; got rid of "IsActionRef" and added 1001 after MenuMode. The message box now appears like it should, but as soon as I exit, I can't get it to pop up again without exiting the game entirely and loading the save prior to activating it, which is odd and frustrating. Once again, here's the latest version of the script; scn MechShopBrokenSGScript short Button begin OnActivate ShowMessage MechShopBrokenText end BEGIN MenuMode 1001 set Button to GetButtonPressed if [Button == 1] player.AddItemHealthPercent WeapHansShotgun 1 0.35 RewardXP 25 Disable endif ENDWhile I have a suspicion it might be because I don't have an if statement for the other button, which just says "Leave it alone.", I'm not entirely sure. It could be something else entirely. Link to comment Share on other sites More sharing options...
dubiousintent Posted November 2, 2017 Share Posted November 2, 2017 My suspicion falls on the "disable" command. Just what are you intending to "disable" (try adding an explicit reference), and why? -Dubious- Link to comment Share on other sites More sharing options...
KlezmerGryphon Posted November 2, 2017 Author Share Posted November 2, 2017 My suspicion falls on the "disable" command. Just what are you intending to "disable" (try adding an explicit reference), and why? -Dubious- The disable command there is supposed to disable the activator if the player passes the skill check to repair the weapon. While I could easily use a work around to keep the script from being run more than once if the skill check is successful, I'd rather have not that model sticking around after a successful skill check. Link to comment Share on other sites More sharing options...
Radioactivelad Posted November 4, 2017 Share Posted November 4, 2017 (edited) The Disable command should be WeapHansShotgun.Disable, marking the shotgun as the object to be disabled. (If WeapHansShotgun is the objects Base Id rather than its Ref ID that would also be a problem.) Also my scripts wouldn't work unless Button ==1 is surrounded by Round Brackets, rather than square ones. Seem arbitrary, and if it was a problem for you, you wouldn't have gotten this far, but give it a shot. Edited November 4, 2017 by Radioactivelad Link to comment Share on other sites More sharing options...
DoctaSax Posted November 4, 2017 Share Posted November 4, 2017 if [ Button == 1 ] endif endif You had two endifs there, and only one if. Obsidian has lots of little things like that, you wonder how they got them to compile at all. In addition, Radioactivelad quite rightly pointed out you need parentheses ( ) instead of square brackets. Or you can just not use anythingif button == 1Square brackets in NV scripting are exclusively used for handling NVSE array and string vars. Your conditional appears to not be complete for returning a "True/False" result. According to the example in the GECK wiki that function only works in a "OnActivate" block, and it should be: if IsActionRef Player == [0|1:int]Attempts at "shorthand" forms of expressions are always suspect when things don't seem to work correctly. -Dubious- If an if condition only contains a boolean function, then the expected value doesn't need to be made explicit if you want to check if it's true. The if-line only cares about what follows being true or false, so if the return of a function is either 1 or 0, it has enough to go on. Usually. It would be interesting to see if there are different results withif 1 == IsActionRef playerrefThere doesn't seem to be a reason why the IsActionRef line would block the message from being shown though. I remember the vanilla script this is based on working fine (despite its extra endif in the gamemode block too). I wonder if there wasn't something wrong with the message's editorID the first go around, and failure to properly compile was ignored. I can't imagine the script being able to be compiled anyway if PU was used, due to the brackets and the extra endif. Well, I managed to get it working, at least somewhat; got rid of "IsActionRef" and added 1001 after MenuMode. The message box now appears like it should, but as soon as I exit, I can't get it to pop up again without exiting the game entirely and loading the save prior to activating it, which is odd and frustrating.What happened here is probably that the square brackets caused the script to silently crash, preventing it from being run again. You usually let the button-detection part of a messagebox script run in the block type you expect the player to be in after the messagebox is closed. In most cases, that'll be gamemode. The Disable command should be WeapHansShotgun.Disable, marking the shotgun as the object to be disabled. (If WeapHansShotgun is the objects Base Id rather than its Ref ID that would also be a problem.)WeapHansShotgun is most likely a base form, so you can't call the "disable" function on it. Leaving just "disable" as in the original script is fine, because it will apply to the implied ref, ie the ref that the object script is running on. Link to comment Share on other sites More sharing options...
Recommended Posts