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 09-24-2011, 05:52 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Changing text in timeout.

I am working on a staff boots script for Lexia, and I don't want it to be just an old boring staff boots script, so I have added a little display to tell you your speed and to also show a little staff boots image too. Here is what the display says.
NPC Code:
Speed: 1

It is reading the speed. However, when I press the = key (increase speed), it doesn't recognise that the speed has changed at all and still shows 1;
Here is the code.
PHP Code:
//#CLIENTSIDE
function onKeyPressed(codeKey) {
  if (
Key == "z") {
    
setTimer(0.05);
    if (
this.mode == 0) {
      
this.mode 1;
      
player.chat "On";
      
this.speed 1;
    } else {
      
this.mode 0;
      
player.chat "Off";
    }
  }
  if (
Key == "=") {
    
this.speed this.speed 1;
  }
}

function 
onTimeout() {
  if (
this.mode == 1) {
    
showingimage();
    for (
temp.key 0key 4key++) {
      if (
keydown(key)) {
        
player.+= (vecx(key) * this.speed);
        
player.+= (vecy(key) * this.speed);
      }
    }
  }
  if (
this.mode == 0) {
    
hidingimage();
  }
  
setTimer(0.05);
}

function 
ShowingImage() {
  
with(findimg(200)) {
    
image "wboots.png";
    
layer 4;
    
screenwidth 675;
    
screenheight 610;
  }
  
with(findimg(201)) {
    
text "Speed: " this.speed;
    
screenwidth 638;
    
screenheight 601;
    
zoom 0.7;
    
layer 4;
  }
}

function 
HidingImage() {
  
hideimg(200);
  
hideimg(201);

The code isn't finished yet, as you can see there is no way to decrease speed and the display is still very simple. The display is attached below.
Attached Images
 
__________________
Reply With Quote
  #2  
Old 09-24-2011, 05:54 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
You need to use thiso.speed in your with container.
Reply With Quote
  #3  
Old 09-24-2011, 05:55 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by Crow View Post
You need to use thiso.speed in your with container.
Thanks for that crow. Can you explain why I needed to use thiso.speed? I won't learn otherwise
__________________
Reply With Quote
  #4  
Old 09-24-2011, 05:58 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Emera View Post
Thanks for that crow. Can you explain why I needed to use thiso.speed? I won't learn otherwise
Inside a with container, this refers to that specific object (in this case, the image/text). To access the object the with container resides in you need to use thiso. The "o" is for "original", I guess.
Reply With Quote
  #5  
Old 09-24-2011, 06:00 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by Crow View Post
Inside a with container, this refers to that specific object (in this case, the image/text). To access the object the with container resides in you need to use thiso. The "o" is for "original", I guess.
Thank you. Green pepper coming your way when I can :O
Need to spread some rep first.
__________________

Last edited by Emera; 09-25-2011 at 02:57 PM..
Reply With Quote
  #6  
Old 09-24-2011, 06:16 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Pardon the double post!
I am having some other problems with the Ganis I am using. I want to use a gani to enhance the boots script a bit, and it works fine when you go into the gani mode, but coming out makes an idle character over my real character. Here is the script and both ganis.

Script
PHP Code:
function onKeyPressed(codeKey) {
  if (
Key == "z") {
    
setTimer(0.05);
    if (
this.mode == 0) {
      
this.mode 1;
      
this.speed 1;
      
player.attr[23] = "lexia_boots.gani";
    } else {
    
this.mode 0;
    
player.attr[23] = "lexia_unboots.gani";
    }
  }
  if (
Key == "=") {
    
this.speed this.speed 1;
  }
  if (
Key == "-") {
    
this.speed this.speed 1;
  }

Attached Files
File Type: gani lexia_boots.gani (8.0 KB, 129 views)
File Type: gani lexia_unboots.gani (7.9 KB, 134 views)
__________________
Reply With Quote
  #7  
Old 09-24-2011, 06:35 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Try setting the 23rd attribute to an empty string when "unequipping" it. Should do the trick.
Reply With Quote
  #8  
Old 09-24-2011, 06:36 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
done that, character just remains invisible.
__________________
Reply With Quote
  #9  
Old 09-24-2011, 09:35 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Try getting rid of all the sprites in the ganis.
__________________
Quote:
Reply With Quote
  #10  
Old 09-25-2011, 05:38 PM
cbk1996 cbk1996 is offline
Banned
Join Date: Sep 2011
Location: Kentucky
Posts: 5
cbk1996 has a little shameless behaviour in the past
Send a message via AIM to cbk1996
Try grabbing the MD5 hash of the string and make sure it doesn't return a NULL entity! If it does; you're in trouble.
Reply With Quote
  #11  
Old 09-25-2011, 05:49 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Why are you posting on all the threads MD5 hash?
__________________
Reply With Quote
  #12  
Old 09-25-2011, 06:40 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Emera View Post
Why are you posting on all the threads MD5 hash?
Because that's cbk1996, not cbk1994
Reply With Quote
  #13  
Old 09-25-2011, 06:43 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by Crow View Post
Because that's cbk1996, not cbk1994
Yeah. It that really allowed? He is impersonating him. Other members have been banned for doing that.
__________________
Reply With Quote
  #14  
Old 09-26-2011, 02:56 AM
Unkownsoldier Unkownsoldier is offline
Ignorance has no future
Join Date: Sep 2008
Posts: 1,287
Unkownsoldier is on a distinguished road
It just seems to me that you ask a scripting question almost every day, if not more. I understand that it is not easy nor is it a quick learn. But I would suggest you find someone to teach you, someone good. I don't mind the questions, but its kind of annoying when you hit "new posts" and half of them are scripting questions. This isn't just you, but a lot of other people. Granted you want to finish your scripts and you want a quick answer so you go to the forums, but it just seems old after a while. I have never remembered when the coding forum was this active, let alone by a 2-3 individuals Nothing personal of course.
__________________
Look beyond the monitor.
Reply With Quote
  #15  
Old 09-26-2011, 03:00 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by Unkownsoldier View Post
It just seems to me that you ask a scripting question almost every day, if not more. I understand that it is not easy nor is it a quick learn. But I would suggest you find someone to teach you, someone good. I don't mind the questions, but its kind of annoying when you hit "new posts" and half of them are scripting questions. This isn't just you, but a lot of other people. Granted you want to finish your scripts and you want a quick answer so you go to the forums, but it just seems old after a while. I have never remembered when the coding forum was this active, let alone by a 2-3 individuals Nothing personal of course.
Ok, first off, stop the trolling. Secondly, this is the place in the forums to post scripting questions. The people who answer my questions (mainly fp4, crow and cbk1994), don't have to answer my questions. It is none of your concern what and when I post in the forums. End of story.

Quote:
I don't mind the questions,
I don't give a crap. You aren't answering them.

Quote:
Granted you want to finish your scripts and you want a quick answer
Almost 75% of the codes I post here are for my learning benefit.

Quote:
kind of annoying when you hit "new posts" and half of them are scripting questions
I think you have some kind of issue. It pains me to see your name in the online members bar at the bottom of the index, bu I don't make a fuss. Get over yourself for christ sake.


so that means...
__________________

Last edited by Emera; 09-26-2011 at 03:27 AM..
Reply With Quote
  #16  
Old 09-26-2011, 03:24 AM
Unkownsoldier Unkownsoldier is offline
Ignorance has no future
Join Date: Sep 2008
Posts: 1,287
Unkownsoldier is on a distinguished road
I was just trying to help you but okay. I suggested you find someone to help you because it would probably be easier for YOU and the forums. So as you can see I don't really understand why you are mad .
__________________
Look beyond the monitor.
Reply With Quote
  #17  
Old 09-26-2011, 03:26 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Unkownsoldier View Post
It just seems to me that you ask a scripting question almost every day, if not more. I understand that it is not easy nor is it a quick learn. But I would suggest you find someone to teach you, someone good. I don't mind the questions, but its kind of annoying when you hit "new posts" and half of them are scripting questions. This isn't just you, but a lot of other people. Granted you want to finish your scripts and you want a quick answer so you go to the forums, but it just seems old after a while. I have never remembered when the coding forum was this active, let alone by a 2-3 individuals Nothing personal of course.
The forums are the best place for scripting questions because it allows us to reuse responses (scripters can search the forums, or we can post a link to a relevant thread from the past). If everyone learned directly from a veteran scripter, Graal's scripting documentation would be even worse than it is now.
__________________
Reply With Quote
  #18  
Old 09-26-2011, 03:37 AM
Unkownsoldier Unkownsoldier is offline
Ignorance has no future
Join Date: Sep 2008
Posts: 1,287
Unkownsoldier is on a distinguished road
Quote:
Originally Posted by cbk1994 View Post
The forums are the best place for scripting questions because it allows us to reuse responses (scripters can search the forums, or we can post a link to a relevant thread from the past). If everyone learned directly from a veteran scripter, Graal's scripting documentation would be even worse than it is now.
I understand that Graals documentation for anything isn't very good, especially scripting. Are there other languages similar to gscript that have more documentation? So maybe people could start there and work their way towards gscript. Just an idea. -- Now granted I don't know anything about scripting nor will I assume anything but is the only way to learn how to script is (once all tutorials are read and understood) that you ask a question and have a more experienced scripter give you the answer to your problem? Or should they point you in the right direction and let you figure it out with hints because I always thought someone would learn better if they did it/found it out themselves. I am not trying to put down anyone including emera, I was just thinking you should persevere through your problems and use the forums as a last resort. Could possibly be more beneficial no? And instead of resorting to the forums everyday for a new question, maybe try to perfect a script before moving onto the next. I'm being serious, not sarcastic at all.
__________________
Look beyond the monitor.
Reply With Quote
  #19  
Old 09-26-2011, 03:55 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Unkownsoldier View Post
I understand that Graals documentation for anything isn't very good, especially scripting. Are there other languages similar to gscript that have more documentation?
Syntactically, JavaScript is almost identical—but few questions are related to syntax. Most are Graal-specific.

Quote:
Now granted I don't know anything about scripting nor will I assume anything but is the only way to learn how to script is (once all tutorials are read and understood) that you ask a question and have a more experienced scripter give you the answer to your problem? Or should they point you in the right direction and let you figure it out with hints because I always thought someone would learn better if they did it/found it out themselves.
Most of the time people are given hints or pointed to relevant documentation if they ask an overly general question. Sometimes questions are so specific that the only way to explain is with an example. This is good because it shows that the poster has a good understanding of GScript but needs advice on one thing.

Quote:
you should persevere through your problems and use the forums as a last resort. Could possibly be more beneficial no?
This isn't always possible. Some things can't be done without appropriate documentation or prior understanding. Many of these posts, for example, deal with specific features.

Quote:
And instead of resorting to the forums everyday for a new question, maybe try to perfect a script before moving onto the next.
I agree, and in the past we've pointed this out to people who were abusing the scripting forum. Just recently:

Quote:
Originally Posted by cbk1994 View Post
For some reason I feel like you've been told to do checks on serverside (for allowed players) at least three or four times now.
Quote:
Originally Posted by fowlplay4 View Post
These "concept" threads you've been posting are just becoming spam, especially when they contain bad-practices/errors we've already tried to tell you to fix and because of that it really negates their helpfulness.

1. Don't constantly re-create GUI objects. Create them once, and update their variables.
2. Move the 'allowed' validation to the server-side.
3. You don't need to use a 0.05 loop, for a weather system you can easily get away with 0.5-1. If only staff can change the weather then you don't really need it at all.
4. When you "change the weather" send a trigger to everyone on to update the weather on the client-side.
__________________
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 01:25 AM.


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