YolkfolkThe Dizzy Fansite 1 logged in0 playing
Community discussion

Costumes

Started by AndyG on 4 September 2014 • 3,624 views

5 posts
#55397
Just as I was boasting in another thread about how smart I was at working costumes out, I've hit a problem! Basically, I'd set animations from tile ID 400 onwards, and added code to the handler script so it looks like this:
// Player set costume costume = 0; if(ID_SCUBA!=-1) costume = InventoryHasItem(ID_SCUBA) ? 30 : 0; PlayerSet(P_COSTUME,costume); costume = 0; if(ID_FANCY!=-1) costume = InventoryHasItem(ID_FANCY) ? 390 : 0; PlayerSet(P_COSTUME,costume); // Check Player Wind Now, the scuba costume doesn't work! Whether you've collected this costume yet or not. Nor will it even function as a scuba. To be honest, I don't fully understand the coding and I was just fiddling around. Can someone please help me with this?

http://i1360.photobucket.com/albums/r650/andygoulding85/tycoon_zps1b0957a9.png
(This is my costume, btw. He's Tycoon Dizzy :D )
👍 0
#81568
Hey Andy,

Prepare to kick yourself! It's a very simple problem, you've set the costume to zero after setting it to scuba:
costume = 0; if(ID_SCUBA!=-1) costume = InventoryHasItem(ID_SCUBA) ? 30 : 0; PlayerSet(P_COSTUME,costume); costume = 0; ////REMOVE THIS LINE!!! if(ID_FANCY!=-1) costume = InventoryHasItem(ID_FANCY) ? 390 : 0; PlayerSet(P_COSTUME,costume); BTW, I don't understand the code here either. All the logic operators like ?, &, and so on are beyond me. :dizzy_confused:

Actually, come to think of it, you can remove the first PlayerSet(P_COSTUME... line too. The bottom one will set it for both costumes. :)
👍 0
#81571
Thanks a lot Noggin! That's exactly what I wanted to hear: that it's both possible and simple! Unfortunately, I can't seem to get it working with what you said. I suspect the answer lies in a different script, or maybe I just didn't define it correctly. I just added it in the gamedef file underneath the scuba as follows: #def ID_SCUBA 1026 #def ID_FANCY 1043 If I remove the code I put in to the handlers file, it goes back the way it was so it's good that I haven't messed anything up! But as it is, the new costume I made replaces the scuba and the scuba does nothing. Thanks for being patient :)
👍 0
#81572
Hmm. It does sound like the FANCY code is changing the costume to zero somehow. Have you tried swapping them over so the FANCY bit is above the SCUBA bit? I imagine that'll just make the SCUBA work and the FANCY not.

Here's another thing you might try, but make sure you put it right at the end of whichever handler function it's in.
costume = 0; if(ID_SCUBA!=-1) costume = InventoryHasItem(ID_SCUBA) ? 30 : 0; PlayerSet(P_COSTUME,costume); if(costume!=0) return; if(ID_FANCY!=-1) costume = InventoryHasItem(ID_FANCY) ? 390 : 0; PlayerSet(P_COSTUME,costume); The 'return' command stops the function there, so if you've got the scuba, the engine won't go on to the next line. That's why you've got to make sure there's no other code below it in the function - if you've got the scuba, that code won't get read.

Let me know if it works anyway.
👍 0
#81573
Brilliant, thanks! That worked great. I'd already changed the order and yes, as you say, the scuba worked and the fancy clothes didn't. Then I did try putting a return command at the end, but didn't consider moving the whole section to the end of the function. You've saved me :) .
👍 0