Quote:
Originally Posted by cbk1994
You renamed "input" to "Calculator_input", but forgot to rename it in the functions
PHP Code:
function Calculator_one.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 1;
}
else
{
Calculator_input.text @= 1;
}
}
Also, make sure you use "==" when comparing variables instead of "="; a single equality sign is used for assigning values to variables, and two signs are used for comparisons.
edit: damn you Chompy
|
ah silly me, completely forgot about that,
and yeah, i know about the == for comparing and = for assigning, i somehow randomly keep forgetting to add the == for comparing.
edit:
awesome, now it's working as planned for this far.
editedit:
i finished it!
PHP Code:
//#CLIENTSIDE
function onWeaponFired()
{
this.number1 = 0;
this.divide = 0;
this.add = 0;
this.subtract = 0;
this.multiply = 0;
new GuiWindowCtrl("Calculator_window")
{
profile = GuiBlueWindowProfile;
clientrelative = true;
clientextent = "165, 200";
canmove = true;
canresize = false;
closequery = false;
destroyonhide = true;
text = "Calculator";
x = 300;
y = 200;
new GuiTextEditCtrl("Calculator_input")
{
profile = GuiBlueTextEditProfile;
x = 5;
y = 5;
width = 155;
height = 30;
text="0";
}
new GuiButtonCtrl("Calculator_clear")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "Clear";
width = 35;
x = 5;
y = 45;
}
new GuiButtonCtrl("Calculator_plusmin")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "+/-";
width = 35;
x = 45;
y = 45;
}
new GuiButtonCtrl("Calculator_divide")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "%";
width = 35;
x = 85;
y = 45;
}
new GuiButtonCtrl("Calculator_multiply")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "X";
width = 35;
x = 125;
y = 45;
}
new GuiButtonCtrl("Calculator_seven")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "7";
width = 35;
x = 5;
y = 75;
}
new GuiButtonCtrl("Calculator_eight")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "8";
width = 35;
x = 45;
y = 75;
}
new GuiButtonCtrl("Calculator_nine")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "9";
width = 35;
x = 85;
y = 75;
}
new GuiButtonCtrl("Calculator_subtract")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "-";
width = 35;
x = 125;
y = 75;
}
new GuiButtonCtrl("Calculator_four")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "4";
width = 35;
x = 5;
y = 105;
}
new GuiButtonCtrl("Calculator_five")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "5";
width = 35;
x = 45;
y = 105;
}
new GuiButtonCtrl("Calculator_six")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "6";
width = 35;
x = 85;
y = 105;
}
new GuiButtonCtrl("Calculator_add")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "+";
width = 35;
x = 125;
y = 105;
}
new GuiButtonCtrl("Calculator_one")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "1";
width = 35;
x = 5;
y = 135;
}
new GuiButtonCtrl("Calculator_two")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "2";
width = 35;
x = 45;
y = 135;
}
new GuiButtonCtrl("Calculator_three")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "3";
width = 35;
x = 85;
y = 135;
}
new GuiButtonCtrl("Calculator_equals")
{
profile = GuiBlueButtonProfile;
height = 55;
text = "=";
width = 35;
x = 125;
y = 135;
}
new GuiButtonCtrl("Calculator_zero")
{
profile = GuiBlueButtonProfile;
height = 25;
text = "0";
width = 75;
x = 5;
y = 165;
}
new GuiButtonCtrl("Calculator_dot")
{
profile = GuiBlueButtonProfile;
height = 25;
text = ",";
width = 35;
x = 85;
y = 165;
}
}
}
function Calculator_one.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 1;
}
else
{
Calculator_input.text @= 1;
}
}
function Calculator_two.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 2;
}
else
{
Calculator_input.text @= 2;
}
}
function Calculator_three.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 3;
}
else
{
Calculator_input.text @= 3;
}
}
function Calculator_four.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 4;
}
else
{
Calculator_input.text @= 4;
}
}
function Calculator_five.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 5;
}
else
{
Calculator_input.text @= 5;
}
}
function Calculator_six.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 6;
}
else
{
Calculator_input.text @= 6;
}
}
function Calculator_seven.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 7;
}
else
{
Calculator_input.text @= 7;
}
}
function Calculator_eight.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 8;
}
else
{
Calculator_input.text @= 8;
}
}
function Calculator_nine.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 9;
}
else
{
Calculator_input.text @= 9;
}
}
function Calculator_zero.onAction()
{
if(Calculator_input.text == 0)
{
Calculator_input.text = 0;
}
else
{
Calculator_input.text @= 0;
}
}
function Calculator_clear.onAction()
{
Calculator_input.text = 0;
}
function Calculator_dot.onAction()
{
Calculator_input.text @= ".";
}
function Calculator_plusmin.onAction()
{
Calculator_input.text -= 2 * Calculator_input.text;
}
function Calculator_divide.onAction()
{
this.number1 = Calculator_input.text;
this.divide = 1;
Calculator_input.text = "0";
}
function Calculator_add.onAction()
{
this.number1 = Calculator_input.text;
this.add = 1;
Calculator_input.text = "0";
}
function Calculator_subtract.onAction()
{
this.number1 = Calculator_input.text;
this.subtract = 1;
Calculator_input.text = "0";
}
function Calculator_multiply.onAction()
{
this.number1 = Calculator_input.text;
this.multiply = 1;
Calculator_input.text = "0";
}
function Calculator_equals.onAction()
{
if(this.divide == 1)
{
this.divide = 0;
Calculator_input.text = (this.number1 / Calculator_input.text);
this.number1 = 0;
}
else if(this.add == 1)
{
this.add = 0;
Calculator_input.text += this.number1;
}
else if(this.subtract == 1)
{
Calculator_input.text = this.number1 - Calculator_input.text;
this.subtract = 0;
this.number1 = 0;
}
else if(this.multiply == 1)
{
Calculator_input.text = this.number1 * Calculator_input.text;
this.number1 = 0;
this.multiply = 0;
}
}
1 thing i plan on fixing in the future,
right now you cannot do for example: 8*8*8*8=
but you have to do 8*8=64*8=somehugenumber
so you have to press the = after each equation, im still quite happy with it,