YolkfolkThe Dizzy Fansite 1 logged in0 playing
Community discussion

Scripting problem

Started by gavlaa on 7 May 2009 • 16,207 views

43 posts
#71089

The "itemid" command is new to me so could I just clarify what it's doing? (and forgive my very basic understanding!)

The "itemid=ObjGet" is instructing the program that if the object you are giving to the bird is either 1000, 1001, 1002 or 1003 then run the message, "here's some twigs". Then the next part checks the bird to see how many it has been given and if the objects are less than 4 then run the message, "i need more twigs" and if they are equal to 4 then run the message, "i don't need more".

I hope I've understood that correctly as it actually made sense as I was writing it!

sorry, 'itemid' is just a variable. I could have called it 'idx', or 'jelly', or 'custardcreambiscuit'. It doesn't matter what it's called, it's simply something for the game to use to store information. In this case, it's storing the Object ID of variable 'idx' (which itself is the item that the player is trying to use)

so 'itemid=ObjGet(idx,O_ID);' basically tells the game to get the ID property of whatever object is stored in variable 'idx', then store the ID number in variable 'itemid'

the 'if' command is the part which checks if the ID of the object you are giving to the bird is either 1000, 1001, 1002 or 1003. If it is, then it runs the code contained in the { and }.

the next part adds 1 to the status of the bird object, then another 'if' statement checks if it's less than 4, and runs the code in the { and } brackets if it is. If not, the game jumps to the next 'if' statement, to check if the status is equal to or more than 4, and runs the code in those { and } brackets if it is.

I hope that makes sense :smile:

👍 0
#71090

ok, maybe it's better explained like this:

this code:

itemid=ObjGet(idx,O_ID);
	if(itemid==1000||itemid==1001||itemid==1002||itemid==1003)

is the same as this code:

if(ObjGet(idx,O_ID)==1000||ObjGet(idx,O_ID)==1001||ObjGet(idx,O_ID)==1002||ObjGet(idx,O_ID)==1003)

you can see above that because in the first example we defined variable 'itemid' as the command 'ObjGet(idx,O_ID)', it means that there is a lot less coding to write on the second line, so it's easier to both read and write, and it's also less likely that mistakes will creep in, due to the simplified code.

👍 0
#71103
I wouldn't worry about it. We all have to start somewhere! As long as it works, that's the main thing. The player doesn't see how it's coded :smile:

if you compare the coding for the mine ride in RRD with the coding for the mine ride in IID, you'll see that they're about the same length, despite the ride in IID being much longer and more complicated. I've almost always thought of better, simpler ways to code stuff once I've finished a particular game.

The bobbing up and down in the middle of the water in MSD is such a botch-job it's unreal. I'm actually pretty embarrassed by how I coded it, which needless to say is most certainly not how I'd code it these days! :tongue:
👍 0