Picking stuff up in a script

Post » Sun Mar 06, 2011 6:19 am

can someone please tell me what the scripting command is to have someone pick up an item that is being interacted with as part of the script?

this is what i'm working on

If OnActivate == 1  If OnGround == 1    ShowMessage STL_AssemSetting    SetButton2 to GetButtonPressed    If Button2 == 0      {Missinglines here!!!! Need scriptline to have player pickup item into inventory.}      Set OnGround to 0    endif      ElseIf Button2 == 1          If CraftItem == 0          ShowMessage STLAssemblerMenu          Set Craftitem to 1        Endif      Endif    Endif  EndifEndif


basically, i want to pick up the item if the option is selected within the script
User avatar
Rude_Bitch_420
 
Posts: 3429
Joined: Wed Aug 08, 2007 2:26 pm

Post » Sun Mar 06, 2011 9:12 am

The player "activating" a misc item that is sitting on the ground will cause it to be snatched. You can actually script this, its along these lines -

itemREF.activate player

http://geck.gamesas.com/index.php/Activate
User avatar
Flash
 
Posts: 3541
Joined: Fri Oct 13, 2006 3:24 pm

Post » Sat Mar 05, 2011 8:29 pm

Basically you want to add the item to the player, remove the one the script is being run from, and make it go away for good..
player.additem ThisItemsName 1
disable
MarkForDelete

The 'if onactivate == 1' part should be an OnActivate block instead ( http://http://geck.gamesas.com/index.php/Category:Blocktypes ), or if that's one of your variable names it's still going to cause issues.. very hard to tell from a script clip what's going on.
Should also have an 'if IsActionRef Player == 1' check just under the OnActivate block, otherwise the player will be getting the showmessage if an NPC in the players area decides to activate that item.
User avatar
Sanctum
 
Posts: 3524
Joined: Sun Aug 20, 2006 8:29 am

Post » Sat Mar 05, 2011 6:52 pm

Basically you want to add the item to the player, remove the one the script is being run from, and make it go away for good..
player.additem ThisItemsName 1
disable
MarkForDelete

The 'if onactivate == 1' part should be an OnActivate block instead ( http://http://geck.gamesas.com/index.php/Category:Blocktypes ), or if that's one of your variable names it's still going to cause issues.. very hard to tell from a script clip what's going on.
Should also have an 'if IsActionRef Player == 1' check just under the OnActivate block, otherwise the player will be getting the showmessage if an NPC in the players area decides to activate that item.


Well what i'm working on is an item that brings up a menu when initialy activated - one option is for it to be picked up, the other will bring up a different menu - this menu will always appear, whenever the item is selected in gameworld (dropped as normal from the inventory.) Does this change the initial command from OnActivate to something else, if Activating the item automatically picks it up? and if so, is it still OnActivate Block?
User avatar
I’m my own
 
Posts: 3344
Joined: Tue Oct 10, 2006 2:55 am

Post » Sun Mar 06, 2011 5:50 am

Well what i'm working on is an item that brings up a menu when initialy activated - one option is for it to be picked up, the other will bring up a different menu - this menu will always appear, whenever the item is selected in gameworld (dropped as normal from the inventory.) Does this change the initial command from OnActivate to something else, if Activating the item automatically picks it up? and if so, is it still OnActivate Block?

Well like Tarrant says, if the item is an object type that you normally can pick up from the ground or a table, then the object itself will handle the 'jumping into your inventory' when it's activated. However, you'll have to intercept it's normal behavior to be immediately taken into your inventory if you want to have it do a showmessage menu. An example might be..
ScriptName WhateverThisScriptShouldBeCalledShort bumperShort Button2Short CraftItemBegin OnActivate  if (IsActionRef Player == 1)    ShowMessage STL_AssemSetting    set bumper to 1    set CraftItem to 0  else    Activate  endifEndBegin GameMode  If (bumper == 1)    Set Button2 to GetButtonPressed    if (Button2 == 0)      Activate Player  ;**method 1**      ;player.additem ThisItemsName 1  ;**method 2**      ;disable      ;MarkForDelete    endif    if (Button2 == 1)      set CraftItem to 1    endif    Set bumper to 0  Endif  If (CraftItem == 1)    ShowMessage STLAssemblerMenu    set Button2 to GetButtonPressed    if (Button2 == 0)      ;Do some stuff    endif    if (Button2 == 1)      ;Do other stuff    endif  Set CraftItem to 0  EndifEND

User avatar
^~LIL B0NE5~^
 
Posts: 3449
Joined: Wed Oct 31, 2007 12:38 pm

Post » Sun Mar 06, 2011 5:57 am

Well like Tarrant says, if the item is an object type that you normally can pick up from the ground or a table, then the object itself will handle the 'jumping into your inventory' when it's activated. However, you'll have to intercept it's normal behavior to be immediately taken into your inventory if you want to have it do a showmessage menu.


Is there a way to attach a script so that the item could be carried as a misc item, and the menu accessed from there without putting it down?
User avatar
matt oneil
 
Posts: 3383
Joined: Tue Oct 09, 2007 12:54 am

Post » Sat Mar 05, 2011 8:51 pm

Is there a way to attach a script so that the item could be carried as a misc item, and the menu accessed from there without putting it down?

Actually there might be.. by putting all of the script inside the OnActivate block. The script is linear enough that you could probably just remove the 'Begin GameMode' line, and the 'End' right above it.
The OnActivate block, according to the wiki, will run one time when the item containing it is selected (as in left clicked) in the inventory menu. If that's true (I haven't tried it), then adding the script to the custom item via its script dropdown box would be enough.
Be aware though, that there's a fair chance selecting the first "pick up item from ground" menu choice might cause your game to crash hard... the items already in your inventory at that point, so I have no idea what that would do.
User avatar
Minako
 
Posts: 3379
Joined: Sun Mar 18, 2007 9:50 pm

Post » Sun Mar 06, 2011 5:00 am

Is there a way to attach a script so that the item could be carried as a misc item, and the menu accessed from there without putting it down?


I know the problems you're about to run into with this.

Once a misc item is in your inventory, you cannot make its onactivate block run again while it is still in there. Or, its onequip block. Its a pain in the ass.

To use the item again, you could do - -

- require the item to be put on the ground before use.

- hijack the ONDROP block. hehe!!!! I did this recently, and its nice. What you have to do is, at the end of the ondrop block, when you're done menuing and farting around with the player, you delete the original item and add a new one.

Here's a segment of known-good code I'm using to hijack an ondrop block on a misc. item for my own purposes. There is no provision to allow the player to actually drop the item to the ground, but you could add it via a messagebox menu.

scn PhalanxPassCardRedSCRIPT; This script runs 3 different-named items. Globals used: PhalanxWeapIdent PhalanxWeapIdent2 PhalanxWeapIdent3ref containerbegin ondrop playerset container to GetContainerif container	returnendif ;player put the item into a container/teammate/vendorif PhalanxWeapIdent == 0	set PhalanxWeapIdent to 1	if PhalanxWeapIdent2 == 0		showmessage PhalanxIdentONMSG		set PhalanxWeapIdent2 to 1	endif	Playerref.additem PhalanxPassCardRedON 1 1else	set PhalanxWeapIdent to 0	if PhalanxWeapIdent3 == 0		showmessage PhalanxIdentOFFMSG		set PhalanxWeapIdent3 to 1	endif	Playerref.additem PhalanxPassCardRedOFF 1 1endifplayerref.additem Pencil01 1 1playerref.removeitem Pencil01 1 1disablemarkfordeleteend

User avatar
sam smith
 
Posts: 3386
Joined: Sun Aug 05, 2007 3:55 am

Post » Sat Mar 05, 2011 10:40 pm

I likda got the idea for what i want from the 'chalk' mod for morrowind, and that sounds similer to how it works. However, there might be another way - would it be possible to script it so that it could be hotkeyed, and when the hotkey is activated, it brings up the menu if the player is carrying the item?
User avatar
Javier Borjas
 
Posts: 3392
Joined: Tue Nov 13, 2007 6:34 pm

Post » Sun Mar 06, 2011 4:28 am

would it be possible to script it so that it could be hotkeyed, and when the hotkey is activated, it brings up the menu if the player is carrying the item?

I do this to bring up a master list of summonable followers, however it uses an invisible headwear piece that the player can see in their inventory, but not on their character.
Just make a brand new armor, leave it blank except for Equip type: Headwear, and select MouthObject under Biped Object.
Here's a rough idea of the script that goes in it..
ScriptName NameSCRshort handlershort chosenBegin OnEquip Player  if (Player.GetItemCount MiscItemName == 1)    ShowMessage MiscItemMenu    set handler to 1  endifEndBegin OnUnequip Player  set handler to 0  set chosen to -1EndBegin GameMode  if (handler == 1)    set chosen to GetButtonPressed    if (chosen == 0)      ;Do stuff    else      ;Do Other stuff    endif      set handler to 0      set chosen to -1      Player.UnequipItem MiscItemMenuObject 1 ;invisible item that this script is going in    endif  endifEnd

When the invisible item is hotkeyed and pressed, IF they have MiscItemName in their inventory.. they'll get the menu. After a choice is made the invisible item unequips itself.
User avatar
Mark Churchman
 
Posts: 3363
Joined: Sun Aug 05, 2007 5:58 am


Return to Fallout 3

cron