Sorry another newbie question!

Need help with using DizzyAGE then look here
Post Reply
Captain Jonesy
Your Backpack is Empty
Posts: 29
Joined: Mon Feb 15, 2010 12:27 pm

Sorry another newbie question!

Post by Captain Jonesy » Tue Oct 05, 2010 4:12 pm

Hi guys,

I'm currently having issue with my code, when I give an item to daisy, I want to change her tile/animation and colour but for some reason, her tile won't change when I access the func UseObject command. Could anyone explain why this is and where I am going wrong please? Here is code below;

Code: Select all

///////////// Daisy 
func UseObject_1000( idx )
{
    if(ObjGet(idx,O_ID)==100)//Giving potion item
    {
    InventorySub(idx); // remove item from the inventory
    idx = ObjFind(1000);///Selecting Daisy tile
    ObjSet(idx,O_TILE,310);//Changing tile
    ObjSet(idx,O_COLOR,COLOR_DEFAULT);///change back to default colour
    Message2(3,8,"Thank you\nI feel so much better"); MessagePop();
    Message2(3,8,"What were you about to say? \n before I"); MessagePop(); 
    Message2(3,8,"Noooooo!"); MessagePop();
    Message2(3,8,"its happening again!"); MessagePop();
    ObjSet(idx,O_TILE,183); // Goat 
    rand = gs_rand(1);
    if(rand==0)
    ObjSet(idx,O_COLOR,COLOR_BLUE);    
Thanks in advance and sorry for fitting up the forum with newbie questions.

Jonesy

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Tue Oct 05, 2010 4:57 pm

hmmm well I have no idea why you have the rand = gs_rand(1); and if(rand==0) code in there. That will probably be interfering with it a bit, but otherwise, I can't see any reason why it shouldn't work. Are you getting an error message, or is it just not changing the tile? What exactly happens?

one other small point, the Goat tile is a different size to the Daisy tile, so you'll have to change the O_MAP properties as well as the O_W and O_H properties, to change the sizes of the object.
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Tue Oct 05, 2010 5:05 pm

additional: as I just pointed out in the other thread, there is no colour defined as COLOR_DEFAULT in the normal game files. Therefore if you haven't defined it then chances are that the game will not run that line of code.
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

Captain Jonesy
Your Backpack is Empty
Posts: 29
Joined: Mon Feb 15, 2010 12:27 pm

Post by Captain Jonesy » Tue Oct 05, 2010 6:00 pm

Sorry I should contained more detail in my last post, after daisy character becomes the goat I get a two error messages saying;

Message 1:

BADARGCOUNT,3,2 ""
Code:-1
Object:-1 <ActionObject_1000:216 < ActionObject:253 < Action: 24 <.

Message 2:

ERROREXIT: GS9 ERROR
_gserrorexit< GSErrHandler < gsVM::Error <gsObjSet <
gsVM::Run < cDizScript::Update < cDizGame:Update <
cDizApp::Update < AppOnRun < e9App:Run < main

This occurs with my updated code from Delta's suggestions on this thread (By the way, thank you Delta for the tips) although it did come up with a similar error message before these changes were made:

Code: Select all

{
    if(ObjGet(idx,O_ID)==100)
    {
    InventorySub(idx); // remove item from the inventory
    idx = ObjFind(1000);
    ObjSet(idx,O_TILE,310);
    ObjSet(idx,O_COLOR,COLOR_WHITE);
    Message2(3,8,"Thank you\nI feel so much better"); MessagePop();
    Message2(3,8,"What were you about to say? \n before I"); MessagePop(); 
    Message2(3,9,"Noooooo!"); 
    Message2(3,8,"its happening again!");
    ObjSet(idx,O_TILE,183); // Goat 
    rand = gs_rand(1);
    ObjSet(idx,O_COLOR,COLOR_BLUE);    
    ObjSet(idx,O_W,26);     
    ObjSet(idx,O_H,26);
    ObjSet(idx,O_MAP+2,26);  
    ObjSet(idx,O_MAP+3,26);
    Message2(2,6,"Baa-ram-ewe. Baa-ram-ewe"); 
    Message1(4,5,"That didn't work.\nI better look\nfor another potion"); MessagePop();
    ObjSet(ObjFind(1000),O_STATUS,1);
    }
I hope that's more clear and thanks again :v2_dizzy_thumbsup:

Colin
Hard Boiled Egg
Posts: 594
Joined: Mon May 28, 2007 8:34 am
Location: Worthing, West Sussex, UK

Post by Colin » Tue Oct 05, 2010 6:28 pm

here is a version that should work for you. i'm not sure of the need to have a gs_rand in there though, but i left it in. i tested it and it worked ok

Code: Select all

//////////// Daisy 
func ActionObject_1000()
{
	if(ObjGet(ObjFind(1000),O_STATUS)==0)//first time talk 
	{
	Message1(4,5,"I be back soon \n with some meds I promise");
	Message2(5,6,"Please be quick \n Ouch!"); MessagePop();
	ObjSet(ObjFind(1000),O_STATUS,1); // advance the talk status  
	return;
	}
	if(ObjGet(ObjFind(1000),O_STATUS)==1) 
	{
	idx = OpenDialogInventory();
	if(idx!=-1) UseObject(idx);
	return;
	}
}


///////////// Daisy 
func UseObject_1000( idx )
{
	if(ObjGet(idx,O_ID)==100)
	{
	InventorySub(idx); // remove item from the inventory
	idx = ObjFind(1000);
	ObjSet(idx,O_TILE,310);
	ObjSet(idx,O_COLOR,COLOR_WHITE);
	Message2(3,8,"Thank you\nI feel so much better"); MessagePop();
	Message2(3,8,"What were you\nabout to say? \n before I"); MessagePop(); 
	Message2(3,9,"Noooooo!"); 
	Message2(3,8,"its happening again!");
	ObjSet(idx,O_TILE,183); // Goat 
	rand = gs_rand(1);
	ObjSet(idx,O_COLOR,COLOR_BLUE);    
	ObjSet(idx,O_W,26);     
	ObjSet(idx,O_H,26);
	ObjSet(idx,O_MAP+2,26);  
	ObjSet(idx,O_MAP+3,26);
	Message2(2,6,"Baa-ram-ewe. Baa-ram-ewe"); 
	Message1(4,5,"That didn't work.\nI better look\nfor another potion"); MessagePop();
	ObjSet(ObjFind(1000),O_STATUS,1);
	}
}
ImageImageImage

delta
Hard Boiled Egg
Posts: 3965
Joined: Fri Feb 09, 2007 7:08 pm
Location: North West
Contact:

Post by delta » Tue Oct 05, 2010 6:35 pm

I just realised, rand = gs_rand(1); gets the game to select a random number from a selection of 1 number, so it will always return the number 0. (having a choice of 8 numbers would randomise the selection from 0 - 7).
Image

Image

"Quotes from the internet may not be genuine" - Abraham Lincoln

Captain Jonesy
Your Backpack is Empty
Posts: 29
Joined: Mon Feb 15, 2010 12:27 pm

Post by Captain Jonesy » Thu Oct 07, 2010 11:37 am

Thank you very much guys, you're been very helpful, saved my bacon again! :v2_dizzy_tongue:

Captain Jonesy
Your Backpack is Empty
Posts: 29
Joined: Mon Feb 15, 2010 12:27 pm

Post by Captain Jonesy » Thu Oct 07, 2010 11:51 am

Thank you very much guys, you're been very helpful, saved my bacon again! :v2_dizzy_tongue:

Post Reply