Skip to content

Commit

Permalink
fixed wrong implementation of the new static variables
Browse files Browse the repository at this point in the history
  • Loading branch information
M4GNV5 committed Aug 11, 2015
1 parent 95f9e94 commit 96f4c28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/api/cbjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ cplApi.MinecraftCommand = MinecraftCommand;
cplApi.construct = function()
{
var other = arguments[0];
if(other instanceof StaticVariable)
other = other.value;

var args = [];
for(var i = 1; i < arguments.length; i++)
Expand Down
20 changes: 10 additions & 10 deletions src/api/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ cplApi.math.pow = function(base, exponent)
var staticBase;
if(typeof base == 'number')
staticBase = base;
else if(base instanceof StaticVariable)
staticBase = base.value;
else if(base.type == 'number')
staticBase = base + 0;

var staticExponent;
if(typeof exponent == 'number')
staticExponent = exponent;
else if(exponent instanceof StaticVariable)
staticExponent = exponent.value;
else if(exponent.type == 'number')
staticExponent = exponent + 0;

if(typeof staticBase == 'number' && typeof staticExponent == 'number')
return Math.pow(staticBase, staticExponent);
Expand All @@ -77,8 +77,8 @@ cplApi.math.sin = function(value)
{
if(typeof value == 'number')
return Math.sin(value);
else if(value instanceof StaticVariable)
return Math.sin(value.value);
else if(value.type == 'number')
return Math.sin(value + 0);

var next = startNewFunction();
var result = new Runtime.Decimal();
Expand All @@ -93,8 +93,8 @@ cplApi.math.sqrt = function(value)
{
if(typeof value == 'number')
return Math.sqrt(value);
else if(value instanceof StaticVariable)
return Math.sqrt(value.value);
else if(value.type == 'number')
return Math.sqrt(value + 0);

var next = startNewFunction();
var result = new Runtime.Decimal();
Expand All @@ -109,8 +109,8 @@ cplApi.math.factorial = function(value)
{
if(typeof value == 'number')
return staticFactorial(value);
else if(value instanceof StaticVariable)
return staticFactorial(value.value);
else if(value.type == 'number')
return staticFactorial(value + 0);

var next = startNewFunction();
var result = new Runtime.Decimal();
Expand Down
9 changes: 6 additions & 3 deletions src/api/staticVar.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
function createStaticVar(value, name)
{
var type = typeof value;
value = new Object(value);
value.type = type;
if(typeof value.type == 'undefined') //is already a static var
{
var type = typeof value;
value = new Object(value);
value.type = type;
}

function _set(val)
{
Expand Down

0 comments on commit 96f4c28

Please sign in to comment.