Requesting simple script

Post » Wed May 11, 2016 2:02 pm

I am creating a "debug mod" to help me play through some mods I used to use years ago because I am feeling nostalgic but don't have time to actually pick up the game again for a long term basis at this time. Basically I want to put an item in the first town, which when I pick it up gives me a certain other item, then deletes itself. How would I script this?

User avatar
Tyler F
 
Posts: 3420
Joined: Mon Aug 27, 2007 8:07 pm

Post » Wed May 11, 2016 11:30 am


begin debug_scri

short OnPCAdd

if ( OnPCAdd )
Player->AddItem "OtherItem" 1
Player->RemoveItem "DebugItem" 1
endif

end

Sometimes removing an item from within its own script can cause a crash, but for something this simple I doubt you'll have any problems.

User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm

Post » Wed May 11, 2016 10:37 am

It crashed :(

User avatar
Rhiannon Jones
 
Posts: 3423
Joined: Thu Sep 21, 2006 3:18 pm

Post » Wed May 11, 2016 3:59 pm

I prefer onActivate. Add the desired item to the player-> and then disable the activated item, wait for a couple of frames and the delete it, like



short s1
;
if ( getDisabled == 1 )
set s1 to s1 + 1
if ( s1 > 3 )
setDelete 1
endif
return
endif
;
if ( onActivate == 1 )
player->addItem "Whatever" 1
disable
set s1 to 0 ; # just to be sure, in case you use this var for other purposes elsewhere in the script
return
endif
;
; # Whatever else the item that you pick up may do like float and rotate or shrink and expand ...
;

I do it all the time, and it always worx nicely.

User avatar
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm

Post » Wed May 11, 2016 7:37 pm

Yeah, activate could do it. Or drop then delete.


I gotta ask though, why not just do a simple console command?



Player->AddItem "item name" 1
User avatar
Alister Scott
 
Posts: 3441
Joined: Sun Jul 29, 2007 2:56 am


Return to III - Morrowind