View Full Version : Sorry another newbie question!
Captain Jonesy
05-10-10, 04: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;
///////////// 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
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.
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.
Captain Jonesy
05-10-10, 06: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:
{
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:
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
//////////// 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);
}
}
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).
Captain Jonesy
07-10-10, 11:37 AM
Thank you very much guys, you're been very helpful, saved my bacon again! :v2_dizzy_tongue:
Captain Jonesy
07-10-10, 11:51 AM
Thank you very much guys, you're been very helpful, saved my bacon again! :v2_dizzy_tongue:
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.