Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Calculator GUI Help (https://forums.graalonline.com/forums/showthread.php?t=134263758)

Twilikari 07-05-2011 08:32 AM

Calculator GUI Help
 
I was practicing my scriting, and I somewhat succesfully FIXED a calculator script. Too some of you, it may look veryyyy familiar. But I wanted to take it one step further. i wanted to make into a fully operational calculator GUI. I've never even attempted to make a GUI however, and I am completely lost. Any help is greatly appreciated!

I'm not looking for someone to do it for me, more of guide me. I want buttons for numbers in the GUI, and some kind of output for the answer.

PHP Code:

function onCreated() {
  
temp.a = 2;
  
temp.b = 1;
  
temp.c = 3;
  
temp.a = onAdd(temp.a, temp.b);
  
onResult(temp.a);  
  
temp.a = onSubtract(temp.a, temp.c);
  
onResult(temp.a);  
  
temp.a = onDivide(temp.b, temp.a);
  
onResult(temp.a);  
  
temp.a = onMultiply(temp.b + 1, temp.c);
  
onResult(temp.a);  
}

function 
onResult(temp.result) {
  echo(
"Result: " @ temp.result);
}

function 
onAdd(a, b) {
  
a = a+b;
  return 
a;
}

function 
onSubtract(a, b) {
  
a = a - b;
  return 
a;
}

function 
onDivide(a, b) {  
  if (
b == 0) {
    
a = "Error: Can't divide by 0!";
  } 
  if (
b != 0) {
    
a = a / b ;
  }  
  return 
a;
}

function 
onMultiply(a, b) {
  
a = a * b;
  return 
a;
} 

Thank's for the help, in advance! ^~^

fowlplay4 07-05-2011 03:33 PM

You can use the GUI Editor in the Client-RC to get a rough idea of how GUIs are made and then afterwards hand-make your own.

cbk1994 07-05-2011 03:42 PM

This thread might help. If you don't understand how to use onAction events I'll be happy to explain them. I'd try to avoid catchEvent (which that script uses) until you're a bit more experienced with GUIs. If you'd like a more conventional example, try this (but whatever you do, do NOT style your code like that).

Twilikari 07-05-2011 07:49 PM

Thank's for all that :D
That calculator is exactly what I was aiming for. I just gotta figure out an easier way.


All times are GMT +2. The time now is 11:41 PM.

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