View Single Post
  #1  
Old 01-04-2006, 02:01 AM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
what am i doing wrong?

Hello, i'm creating a card game in gscript but i've hit a problem.

This worked when i converted it to gscript1 and tried it offline (diddnt work with gscript1 online though).

At the moment all this should do is put a card on the screen then change it to a random one when you touch the npc.

NPC Code:
if (created) {
*snip*...visual stuff....*snip*
showimg 15,cards.gif, x-5,y-4;
changeimgpart 15,80,232,40,58;

this.cardx = {0,40,80,120,160,200,240,280,320,360,400,440,480,0 ,40,80,120,160,200,240,280,320,360,400,440,480,0,4 0,80,120,160,200,240,280,320,360,400,440,480,0,40, 80,120,160,200,240,280,320,360,400,440,480}
this.cardy = {0,0,0,0,0,0,0,0,0,0,0,0,0,58,58,58,58,58,58,58,58 ,58,58,58,58,58,116,116,116,116,116,116,116,116,11 6,116,116,116,116,174,174,174,174,174,174,174,174, 174,174,174,174,174}
}


function onActionPlay() {
setcharprop #c,touched;
randomcard();
}


function randomcard() {
this.num = int(random(1,53));
changeimgpart 15,this.cardx[this.num],this.cardy[this.num],40,58;
}
//#CLIENTSIDE
function onPlayerTouchsMe() {
triggeraction x+2,y+2,play,;
}



The this.cardx and this.cardy variables store the co-ordinates of each card on card.gif. It's not very pretty but it's the easiest way i could get it to work.. and 2d arrays don't seem possible. (please show me how if i'm wrong).

The problem is this.cardx[anything] is always 0. Same with this.cardy[] I can't understand it! I thought it might be a scope issue so i moved the this.cardx = and this.cardy = lines into randomcard() {} but it diddn't fix it. this.cardx[any number] is always 0.

What am i doing wrong? This has really baffled me
Reply With Quote