Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 01-04-2006, 04:55 AM
Maniaman Maniaman is offline
Registered User
Join Date: Aug 2005
Posts: 326
Maniaman is on a distinguished road
this.cardx={NUMBERS} and this.cardy={MORENUMBERS} are missing the ; at the end.
__________________

Current Maloria Event: (click to go to it)
Reply With Quote
  #3  
Old 01-04-2006, 04:17 PM
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
thanks
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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