Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   what am i doing wrong? (https://forums.graalonline.com/forums/showthread.php?t=63190)

JkWhoSaysNi 01-04-2006 02:01 AM

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 :(

Maniaman 01-04-2006 04:55 AM

this.cardx={NUMBERS} and this.cardy={MORENUMBERS} are missing the ; at the end.

JkWhoSaysNi 01-04-2006 04:17 PM

thanks :)


All times are GMT +2. The time now is 06:01 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.