Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Graphical Interface (https://forums.graalonline.com/forums/showthread.php?t=74272)

xAndrewx 05-29-2007 06:45 PM

Graphical Interface
 
4 Attachment(s)
Here's a simple gui effect

HTML Code:

//#CLIENTSIDE
function onCreated()
{
  playergui = this;
  this.startGui();
}

function startGui()
{
  this.guiPosition = {2, 2};
 
  this.updateData();
 
  for (temp.currentImage: this.imageData)
  {
    this.drawImage(temp.currentImage);
  }
}
function updateData()
{
  this.imageData = {
    {200, "c_gui-base.png", this.guiPosition, 4},
    {201, player.headimg, {(this.guiPosition[0] + 4), (this.guiPosition[1] + 6)}, 5, {0, 64, 32, 32}},
    {202, "c_gui-hpbar.png", {(this.guiPosition[0] + 42), (this.guiPosition[1] + 11)}, 5, {0, 0, this.findBar("hp"), 7}},
    {203, "c_gui-mpbar.png", {(this.guiPosition[0] + 42), (this.guiPosition[1] + 22)}, 5, {0, 0, 59, 7}}
  };
}
function drawImage(imageData)
{
  showimg(temp.imageData[0], temp.imageData[1], temp.imageData[2][0], temp.imageData[2][1]);
  changeimgvis(temp.imageData[0], temp.imageData[3]);
  if (temp.imageData[4].size() == 4)
  {
    changeimgpart(temp.imageData[0], temp.imageData[4][0], temp.imageData[4][1], temp.imageData[4][2],temp.imageData[4][3]);
  }
}

function findBar(barType)
{
  if (temp.barType == "hp")
    return ((player.hearts / player.fullhearts) * 59 <= 1? 1: (player.hearts / player.fullhearts) * 59);
}

public function updateHP()
{
  this.updateData();
  this.drawImage(this.imageData[2]);
}

public function updateMP()
{
  //place holder, make your own!
}
public function hideGui()
{
  hideimgs(200, 210);
}

Here are the images! It's the top left gui thing.

cbk1994 05-31-2007 01:39 AM

Looks nice. Script is a bit long for this, but that's not a problem. Long scripts don't usually mean anything.

xXziroXx 05-31-2007 01:40 AM

Quote:

Originally Posted by cbkbud (Post 1313561)
Looks nice. Script is a bit long for this, but that's not a problem. Long scripts don't usually mean anything.

bytes ++

cbk1994 05-31-2007 01:42 AM

Quote:

Originally Posted by xXziroXx (Post 1313562)
postcount ++

Fixed it for you.
bytes mean nothing, really. NPC-Server reads through it the same (though it's on the client in this script), so no harm, no foul.

xXziroXx 05-31-2007 01:46 AM

Quote:

Originally Posted by cbkbud (Post 1313564)
bytes mean nothing, really. NPC-Server reads through it the same (though it's on the client in this script), so no harm, no foul.

I know it doesn't. But I still think that the smaller a script can be in lines/words/whatever, and still be able to perform the same way another script that has more lines/words/whatever is the better script.

But hey, that's just my point of view.

cbk1994 05-31-2007 01:48 AM

Quote:

Originally Posted by xXziroXx (Post 1313568)
I know it doesn't. But I still think that the smaller a script can be in lines/words/whatever, and still be able to perform the same way another script that has more lines/words/whatever is the better script.

But hey, that's just my point of view.

In that case

PHP Code:

function onCreated() { if (true){ dosomething(); dosomethingelse(); } if ( nottruelol ) { dothis(); killplayer(); } } function onPlayerEnters() { player.chat "foo"; if (player.30 ) { player.31player.chat "HAXOR!" } } 

(My ingenius haxor protection system)

DustyPorViva 05-31-2007 02:19 AM

With coding/scripting, it should be a practice to make codes/scripts as efficiently short as possible.

Novo 05-31-2007 02:28 AM

Quote:

Originally Posted by cbkbud (Post 1313569)
In that case

PHP Code:

function onCreated() { if (true){ dosomething(); dosomethingelse(); } if ( nottruelol ) { dothis(); killplayer(); } } function onPlayerEnters() { player.chat "foo"; if (player.30 ) { player.31player.chat "HAXOR!" } } 

(My ingenius haxor protection system)


PHP Code:

function onCreated(){if (1){s();o();} if (0){t();k();}} function onPlayerEnters(){player.chat="foo";if(player.x<30){player.x=31;player.chat="HAXOR!"}} 

By Ziro's interpretation, I optimized your code. :)

cbk1994 05-31-2007 04:08 AM

Quote:

Originally Posted by DustyPorViva (Post 1313586)
With coding/scripting, it should be a practice to make codes/scripts as efficiently short as possible.

Why?

DustyPorViva 05-31-2007 04:23 AM

It's good practice. IE, it might not be completely useful in Graal, but it is in practice. Small changes in scripts and making it shorter and more efficient for Graal might not make a difference on its own, but do so to a bunch of scripts and it will.
Also, for coding, it's very important to code efficiently for various reasons.

cbk1994 05-31-2007 04:25 AM

Quote:

Originally Posted by DustyPorViva (Post 1313642)
It's good practice. IE, it might not be completely useful in Graal, but it is in practice. Small changes in scripts and making it shorter and more efficient for Graal might not make a difference on its own, but do so to a bunch of scripts and it will.
Also, for coding, it's very important to code efficiently for various reasons.

Length of script and effective code have absolutly no corrolation at all.

DustyPorViva 05-31-2007 04:53 AM

Why do
PHP Code:

function onWeaponfired() {
  if (
player.dir==0shoot(blahblah crap for direction 0);
  if (
player.dir==1shoot(blahblah crap for direction 1);
  if (
player.dir==2shoot(blahblah crap for direction 2);
  if (
player.dir==3shoot(blahblah crap for direction 3);


when you can do
PHP Code:

function onWeaponfired() {
  
shoot(formulate the angle depending on the direction);


?
Sure, the first way works, but it's silly to not try to improve your scripting by finding shorter alternatives. Like I said, it's better practice. There may not be any hard evidence as to why, in terms of efficiency, but you can learn a lot of things by trying to think outside the box and find ways to shorten your code.

Inverness 05-31-2007 05:04 AM

Quote:

Originally Posted by cbkbud (Post 1313632)
Why?

To me, it seems as if you're arguing against shorter code just for the sake of arguing.

xAndrewx 05-31-2007 10:41 AM

Quote:

Originally Posted by cbkbud (Post 1313561)
Looks nice. Script is a bit long for this, but that's not a problem. Long scripts don't usually mean anything.

Show me how you'd make this gui, with the capability to add more features easily.

cbk1994 05-31-2007 12:40 PM

Quote:

Originally Posted by DustyPorViva (Post 1313662)
Why do
PHP Code:

function onWeaponfired() {
  if (
player.dir==0shoot(blahblah crap for direction 0);
  if (
player.dir==1shoot(blahblah crap for direction 1);
  if (
player.dir==2shoot(blahblah crap for direction 2);
  if (
player.dir==3shoot(blahblah crap for direction 3);


when you can do
PHP Code:

function onWeaponfired() {
  
shoot(formulate the angle depending on the direction);


?
Sure, the first way works, but it's silly to not try to improve your scripting by finding shorter alternatives. Like I said, it's better practice. There may not be any hard evidence as to why, in terms of efficiency, but you can learn a lot of things by trying to think outside the box and find ways to shorten your code.

????????

I never said anything about something like that. If there is a way to make it shorter, fine. I'm saying long doesn't mean bad, which is true. Short doesn't even mean more effiecent, though it can be most of the time.

DustyPorViva 05-31-2007 02:27 PM

Well you quoted my post and asked why, and I answered. I never said anything like long means bad either, but you still asked me why I posted what I did. So why did you ask if you weren't looking for an answer?

killerogue 05-31-2007 05:43 PM

I'm with Inverness on this one, seems like you're just arguing to be arguing.

cbk1994 06-01-2007 03:14 AM

Okay, first, argueing is good for you--it's proven. I am a rebellious person. I don't think people should be making blanket statements like shorter=better.

So, whatever. Let's stop this arguement. Basicly, we now know the following:

-Shorter != More Effective
-Shorter USUALLY = More Effective
-Shorter NOT ALWAYS = better
-Longer USUALLY != better

Well, let's just stop this. We aren't accomplishing much of anything.

Peace out people ^^

DustyPorViva 06-01-2007 03:18 AM

How is me showing an example of shortening a script NOT relevant to a discussion about shorter vs longer??? That makes absolutely no sense.

cbk1994 06-01-2007 03:22 AM

Quote:

Originally Posted by DustyPorViva (Post 1313967)
How is me showing an example of shortening a script NOT relevant to a discussion about shorter vs longer??? That makes absolutely no sense.

Quote:

Originally Posted by cbk1994
Let's stop this arguement.

^^

DustyPorViva 06-01-2007 03:23 AM

Why? Because you said what you wanted to say?

cbk1994 06-01-2007 03:26 AM

Quote:

Originally Posted by DustyPorViva (Post 1313971)
Why? Because you said what you wanted to say?

Quote:

Originally Posted by cbk1994
Let's stop this arguement.

:\

DustyPorViva 06-01-2007 03:27 AM

Ah. Arguing is healthy as long as it's you. If anyone else wants to defend their statement, it's no longer healthy and you don't want to hear it anymore.

cbk1994 06-01-2007 03:28 AM

Quote:

Originally Posted by DustyPorViva (Post 1313973)
Ah. Arguing is healthy as long as it's you. If anyone else wants to defend their statement, it's no longer healthy and you don't want to hear it anymore.

Quote:

Originally Posted by cbk1994
Let's stop this arguement.

Please stop trying to provoke fights!

DustyPorViva 06-01-2007 03:29 AM

I'm not trying to provoke fights, I'm still sticking by what I said, and I see it no different than you sticking by your opinion, except you want your word to be the last.

xXziroXx 06-01-2007 03:37 AM

Quote:

Originally Posted by DustyPorViva (Post 1313975)
I'm not trying to provoke fights, I'm still sticking by what I said, and I see it no different than you sticking by your opinion, except you want your word to be the last.

Why are you never on AIM? :cry:

DustyPorViva 06-01-2007 03:39 AM

Hmm? I'm on right now?

xXziroXx 06-01-2007 03:42 AM

Quote:

Originally Posted by DustyPorViva (Post 1313979)
Hmm? I'm on right now?

Then I suppose you must have it so only people on your buddy list can see you :cry:

Add me! :)

killerogue 06-01-2007 03:49 AM

Quote:

Originally Posted by cbkbud (Post 1313974)
Please stop trying to provoke fights!

This is a totally one sided arguement. You can't just have your opinion heard and try to have it be the last statement.

cbk1994 06-01-2007 04:00 AM

Okay, my post is fixed. I edited it so it does not state my views.

Now, let us end this arguement please :)

Novo 06-01-2007 04:53 AM

Food Fight!

xAndrewx 06-01-2007 08:16 AM

::throws trout at Novo::

Kristi 06-01-2007 04:24 PM

Quote:

Originally Posted by cbkbud (Post 1313645)
Length of script and effective code have absolutly no corrolation at all.

This is true, but in the tone you implied this, you falsely accused Dusty of saying efficient = short, which he did not, all he said, and I quote.

Quote:

Originally Posted by DustyPorViva (Post 1313586)
With coding/scripting, it should be a practice to make codes/scripts as efficiently short as possible.

In which, as read by laws of grammar, he is requesting you shorten the code efficiently, as in, if shortening the code requires you to be inefficient, do not shorten it.

Also, as the others said, you cannot only get your words out and end an argument. If they want to just not respond back, that is okay, but I definately wouldn't demand it end one sided, unless the argument had a clear one side in the first place.

At this point, a big nonsense argument ensued. Lately, it seems every thread is all about an argument, and it is wearing my patience thin. Enough.

Anyway, back on topic, Andrew, this is a fine example ^_^. There are little things you can do to optimize it, like only update the sprite you need to, instead of the whole thing, but since you aren't running a timeout anyway, this would save a negligible amount of processing power, so IMHO it is fine as is.

I personally would not have done the array thing, but my personal preference does not make it wrong ^_^

xAndrewx 06-01-2007 06:25 PM

ok!!
::throws cabage at Hell Raven::


All times are GMT +2. The time now is 12:16 AM.

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