lfnetwork.com mark read register faq members calendar

Thread: [HELP] My Script works.... But not how i expected
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 05-14-2010, 05:43 PM   #1
Holty1-5
Junior Member
 
Holty1-5's Avatar
 
Join Date: Feb 2010
Location: Reading UK
Posts: 254
Current Game: Final Fantasy 13
Helpful! 
[HELP] My Script works.... But not how i expected

void main() {
object oDestroy = GetFirstItemInInventory( GetFirstPC() );
while( GetIsObjectValid( oDestroy ) ) {
if( GetTag( oDestroy ) == "rancorblood" )
DestroyObject( oDestroy, 0.00, FALSE, 0.00 );
oDestroy = GetNextItemInInventory( GetFirstPC() );
object oItem=CreateItemOnObject( "rancorstim", GetFirstPC());
}
}

See the above script
heres what its ment to do
Take away the Item RancorBlood and give you 1 rancor stim

But for some Unknown reason i Was Given 11 Stims not 1


What going on? Is it a Scripting Error? Help?

~Holty

Holty1-5 is offline   you may: quote & reply,
Old 05-14-2010, 06:29 PM   #2
newbiemodder
Gentleman Modder
 
newbiemodder's Avatar
 
Join Date: Feb 2009
Location: Chicago
Posts: 701
Veteran Modder 
I'm not a scripting guru, but I think this line

Code:
object oItem=CreateItemOnObject( "rancorstim", GetFirstPC());
should read

Code:
object oItem=CreateItemOnObject( "rancorstim", GetFirstPC(),1,0);


Who's more foolish, the fool or the fool that follows?

Just exactly what is a head-piece to the Staff of Ra?

http://www.lucasforums.com/showthread.php?t=206819

http://www.lucasforums.com/showthread.php?t=206541

http://www.lucasforums.com/showthrea...t=newbiemodder
newbiemodder is offline   you may: quote & reply,
Old 05-15-2010, 02:30 AM   #3
Istorian
Junior Member
 
Istorian's Avatar
 
Join Date: May 2008
Location: Back at LF
Posts: 378
Helpful! 
Well, I'm not a scripting guru, either, but, I think there is a certain logic problem here..This script checks the PC's inventory for every item that has the tag "rancorblood", and for each one it finds, it gives you 1 rancor stim. Thus, if you have 11 rancor blood in the inventory, the script destroys all of them, and you get 11 rancor stims in the inventory...

Try this one, instead, where the command to create the "rancorstim" is out of the while loop:

Code:
void main() {

object oDestroy = GetFirstItemInInventory( GetFirstPC() );

while( GetIsObjectValid( oDestroy ) ) {

if( GetTag( oDestroy ) == "rancorblood" )

DestroyObject( oDestroy, 0.00, FALSE, 0.00 );

oDestroy = GetNextItemInInventory( GetFirstPC() );

}

object oItem=CreateItemOnObject( "rancorstim", GetFirstPC());

}
Hope this helps!

Istorian is offline   you may: quote & reply,
Old 05-15-2010, 03:48 PM   #4
Holty1-5
Junior Member
 
Holty1-5's Avatar
 
Join Date: Feb 2010
Location: Reading UK
Posts: 254
Current Game: Final Fantasy 13
Helpful! 
Well Guys thanks for the Help, I'll try Newbiemodders,

@Istorian
I understand that Loop thing but the Odd bit was i only Had 1 of the Blood item and it gave me 11 stims :P talk about Bonus

Holty1-5 is offline   you may: quote & reply,
Old 05-15-2010, 03:55 PM   #5
Darth333
Administraterror
 
Darth333's Avatar
 
Status: Administrator
Join Date: Feb 2004
Location: In my secret dungeon...
Posts: 8,292
Quote:
Originally Posted by Holty1-5 View Post
Well Guys thanks for the Help, I'll try Newbiemodders,

@Istorian
I understand that Loop thing but the Odd bit was i only Had 1 of the Blood item and it gave me 11 stims :P talk about Bonus
It depends on how the script is fired...the same happened to me when I first started modding kotor back in 2004 I don't recall this happening when running a script from a dlg file but it happens when opening containers and entering new areas. Add a variable to make sure the item is not already in the inventory or does not already exist (but I could be wrong as it's been a while since I've done any kotor modding).
Darth333 is offline   you may: quote & reply,
Old 05-15-2010, 04:16 PM   #6
Holty1-5
Junior Member
 
Holty1-5's Avatar
 
Join Date: Feb 2010
Location: Reading UK
Posts: 254
Current Game: Final Fantasy 13
Helpful! 
Lol at The Pic xD

When i did the Exchange Newbiemodder suggest i didnt get 11 stims

I got 9 lol

I'll keep playin around with it and see what happens

Holty1-5 is offline   you may: quote & reply,
Old 05-17-2010, 12:33 AM   #7
logan23
Veteran
 
logan23's Avatar
 
Join Date: Aug 2007
Location: East Coast
Posts: 909
Current Game: Revenge of Revan
Veteran Modder Forum Veteran Contest winner - Modding Hot Topic Starter 
Quote:
Code:

void main() {

object oDestroy = GetFirstItemInInventory( GetFirstPC() );

while( GetIsObjectValid( oDestroy ) ) {

if( GetTag( oDestroy ) == "rancorblood" )

DestroyObject( oDestroy, 0.00, FALSE, 0.00 );

oDestroy = GetNextItemInInventory( GetFirstPC() );

}

object oItem=CreateItemOnObject( "rancorstim", GetFirstPC());

}

Hope this helps!
This helps with limiting the stim creation to 1.
The only issue is if I have 2 boma blood items and then go through this script it only gives me one Stim. Is there a way to make it give the number of stim based on the number of bomablood items?

Thanks

Logan

logan23 is offline   you may: quote & reply,
Old 05-17-2010, 07:01 AM   #8
Istorian
Junior Member
 
Istorian's Avatar
 
Join Date: May 2008
Location: Back at LF
Posts: 378
Helpful! 
You mean you want to get as many stims as the number of boma blood items you have in the inventory? or in a different rate? (e.g. 1 stim for every 2 boma blood items)

Istorian is offline   you may: quote & reply,
Old 05-17-2010, 07:06 AM   #9
logan23
Veteran
 
logan23's Avatar
 
Join Date: Aug 2007
Location: East Coast
Posts: 909
Current Game: Revenge of Revan
Veteran Modder Forum Veteran Contest winner - Modding Hot Topic Starter 
Trying to get 2 bomablood = 2 boma stims, ....and so on... basically the number of bomablood will equal the number of boma stims...

Thanks

logan23 is offline   you may: quote & reply,
Old 05-17-2010, 07:33 AM   #10
Istorian
Junior Member
 
Istorian's Avatar
 
Join Date: May 2008
Location: Back at LF
Posts: 378
Helpful! 
Well, I think that this will give you the result you'd like!

Code:
void main() {

object oDestroy = GetFirstItemInInventory( GetFirstPC() );

while( GetIsObjectValid( oDestroy ) ) {

if( GetTag( oDestroy ) == "YOUR_BOMABLOOD_TAG_HERE" )

DestroyObject( oDestroy, 0.00, FALSE, 0.00 );

oDestroy = GetNextItemInInventory( GetFirstPC() );

object oItem=CreateItemOnObject( "YOUR_STIM_TAG_HERE", GetFirstPC());

}

}
Hope this helps!

Istorian is offline   you may: quote & reply,
Old 05-17-2010, 09:27 AM   #11
logan23
Veteran
 
logan23's Avatar
 
Join Date: Aug 2007
Location: East Coast
Posts: 909
Current Game: Revenge of Revan
Veteran Modder Forum Veteran Contest winner - Modding Hot Topic Starter 
I believe thats the same script that was originally shown in first post. If so it ends up cashing kotor2 ,as if its trying to give you unlimited items,
Correct if im wrong about the two scripts. Im look at this on my cell so cant see whole page at once. Thanks

logan23 is offline   you may: quote & reply,
Old 05-18-2010, 06:02 AM   #12
Istorian
Junior Member
 
Istorian's Avatar
 
Join Date: May 2008
Location: Back at LF
Posts: 378
Helpful! 
Actually it is, but even though I'm not a scripting guru or something like that, as far as I'm concerned, it works. I also made a quick module and tested it, and it works fine in my game...If it crashes in yours let me know, and I'll see what I can do!

Istorian is offline   you may: quote & reply,
Old 05-19-2010, 07:46 AM   #13
logan23
Veteran
 
logan23's Avatar
 
Join Date: Aug 2007
Location: East Coast
Posts: 909
Current Game: Revenge of Revan
Veteran Modder Forum Veteran Contest winner - Modding Hot Topic Starter 
I will do some testing with he script you have and place it in a new dlg file, and also try different .uti's to see the core of the freeze.

Thanks

logan23 is offline   you may: quote & reply,
Old 05-21-2010, 09:28 PM   #14
logan23
Veteran
 
logan23's Avatar
 
Join Date: Aug 2007
Location: East Coast
Posts: 909
Current Game: Revenge of Revan
Veteran Modder Forum Veteran Contest winner - Modding Hot Topic Starter 
Nope it crashes.

I tested if it is the item , but it did not matter

Now this is for kotor2. I do not know if this matters.

Let me know if you have any other ideas.


Edit: Never mind I found a way using a script that i found on the forums:

Quote:
int DestroyOneItem(object oItem) {
if (GetIsObjectValid(oItem)) {
int nStack = GetItemStackSize(oItem);

if (nStack > 1)
SetItemStackSize(oItem, nStack - 1);
else
DestroyObject(oItem);

return TRUE;
}
return FALSE;
}

void main () {
object oPC = GetFirstPC();

object oSaber = GetItemPossessedBy(oPC, "bomablood");
if (DestroyOneItem(oSaber))
return;

//oSaber = GetItemPossessedBy(oPC, "g_w_lghtsbr01");
//if (DestroyOneItem(oSaber))
//return;
}
I then will just place a create a boma stim on the next dlg line to keep it clean.

I just have to send the PC back to the beginning dlg line so that you can keep going over an over.

Will later look at shrinking the script so you don't have to do one at a time but this will solve it and make if work.

Thanks everyone!!


Last edited by logan23; 05-21-2010 at 10:03 PM.
logan23 is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > [HELP] My Script works.... But not how i expected

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:16 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.