diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs | 73 |
2 files changed, 65 insertions, 10 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs index 9e8ea54..2dc8547 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
52 | // Only the types we need to convert | 52 | // Only the types we need to convert |
53 | dataTypes.Add("void", "void"); | 53 | dataTypes.Add("void", "void"); |
54 | dataTypes.Add("integer", "LSL_Types.LSLInteger"); | 54 | dataTypes.Add("integer", "LSL_Types.LSLInteger"); |
55 | dataTypes.Add("float", "double"); | 55 | dataTypes.Add("float", "LSL_Types.LSLFloat"); |
56 | dataTypes.Add("string", "LSL_Types.LSLString"); | 56 | dataTypes.Add("string", "LSL_Types.LSLString"); |
57 | dataTypes.Add("key", "LSL_Types.LSLString"); | 57 | dataTypes.Add("key", "LSL_Types.LSLString"); |
58 | dataTypes.Add("vector", "LSL_Types.Vector3"); | 58 | dataTypes.Add("vector", "LSL_Types.Vector3"); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs index a3dcfaf..107d493 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs | |||
@@ -1093,6 +1093,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1093 | m_string=s; | 1093 | m_string=s; |
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | public LSLString(LSLFloat f) | ||
1097 | { | ||
1098 | string s=String.Format("{0:0.000000}", f.value); | ||
1099 | m_string=s; | ||
1100 | } | ||
1101 | |||
1096 | #endregion | 1102 | #endregion |
1097 | 1103 | ||
1098 | #region Operators | 1104 | #region Operators |
@@ -1160,6 +1166,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1160 | return new LSLString(d); | 1166 | return new LSLString(d); |
1161 | } | 1167 | } |
1162 | 1168 | ||
1169 | public static explicit operator LSLString(LSLFloat f) | ||
1170 | { | ||
1171 | return new LSLString(f); | ||
1172 | } | ||
1173 | |||
1163 | public static implicit operator Vector3(LSLString s) | 1174 | public static implicit operator Vector3(LSLString s) |
1164 | { | 1175 | { |
1165 | return new Vector3(s.m_string); | 1176 | return new Vector3(s.m_string); |
@@ -1225,6 +1236,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1225 | 1236 | ||
1226 | #endregion | 1237 | #endregion |
1227 | 1238 | ||
1239 | #region Operators | ||
1240 | |||
1228 | static public implicit operator int(LSLInteger i) | 1241 | static public implicit operator int(LSLInteger i) |
1229 | { | 1242 | { |
1230 | return i.value; | 1243 | return i.value; |
@@ -1318,6 +1331,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1318 | return i.value == 0; | 1331 | return i.value == 0; |
1319 | } | 1332 | } |
1320 | 1333 | ||
1334 | #endregion | ||
1335 | |||
1321 | #region Overriders | 1336 | #region Overriders |
1322 | 1337 | ||
1323 | public override string ToString() | 1338 | public override string ToString() |
@@ -1352,6 +1367,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1352 | public double value; | 1367 | public double value; |
1353 | 1368 | ||
1354 | #region Constructors | 1369 | #region Constructors |
1370 | |||
1355 | public LSLFloat(int i) | 1371 | public LSLFloat(int i) |
1356 | { | 1372 | { |
1357 | this.value = (double)i; | 1373 | this.value = (double)i; |
@@ -1366,20 +1382,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1366 | 1382 | ||
1367 | #region Operators | 1383 | #region Operators |
1368 | 1384 | ||
1369 | static public implicit operator Double(LSLFloat f) | 1385 | static public implicit operator int(LSLFloat f) |
1370 | { | 1386 | { |
1371 | return f.value; | 1387 | return (int)f.value; |
1372 | } | 1388 | } |
1373 | 1389 | ||
1374 | //static public implicit operator System.Int32(LSLFloat f) | 1390 | static public implicit operator uint(LSLFloat f) |
1375 | //{ | 1391 | { |
1376 | // return (int)f.value; | 1392 | return (uint) Math.Abs(f.value); |
1377 | //} | 1393 | } |
1378 | |||
1379 | 1394 | ||
1380 | static public implicit operator Boolean(LSLFloat f) | 1395 | static public implicit operator Boolean(LSLFloat f) |
1381 | { | 1396 | { |
1382 | if (f.value == 0) | 1397 | if (f.value == 0.0) |
1383 | { | 1398 | { |
1384 | return false; | 1399 | return false; |
1385 | } | 1400 | } |
@@ -1394,17 +1409,57 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script | |||
1394 | return new LSLFloat(i); | 1409 | return new LSLFloat(i); |
1395 | } | 1410 | } |
1396 | 1411 | ||
1412 | static public implicit operator LSLFloat(string s) | ||
1413 | { | ||
1414 | return new LSLFloat(double.Parse(s)); | ||
1415 | } | ||
1416 | |||
1397 | static public implicit operator LSLFloat(double d) | 1417 | static public implicit operator LSLFloat(double d) |
1398 | { | 1418 | { |
1399 | return new LSLFloat(d); | 1419 | return new LSLFloat(d); |
1400 | } | 1420 | } |
1421 | |||
1422 | static public bool operator ==(LSLFloat f1, LSLFloat f2) | ||
1423 | { | ||
1424 | return f1.value == f2.value; | ||
1425 | } | ||
1426 | |||
1427 | static public bool operator !=(LSLFloat f1, LSLFloat f2) | ||
1428 | { | ||
1429 | return f1.value != f2.value; | ||
1430 | } | ||
1431 | |||
1432 | static public LSLFloat operator ++(LSLFloat f) | ||
1433 | { | ||
1434 | f.value++; | ||
1435 | return f; | ||
1436 | } | ||
1437 | |||
1438 | static public LSLFloat operator --(LSLFloat f) | ||
1439 | { | ||
1440 | f.value--; | ||
1441 | return f; | ||
1442 | } | ||
1443 | |||
1444 | static public implicit operator System.Double(LSLFloat f) | ||
1445 | { | ||
1446 | return f.value; | ||
1447 | } | ||
1448 | |||
1449 | //static public implicit operator System.Int32(LSLFloat f) | ||
1450 | //{ | ||
1451 | // return (int)f.value; | ||
1452 | //} | ||
1453 | |||
1401 | #endregion | 1454 | #endregion |
1402 | 1455 | ||
1403 | #region Overriders | 1456 | #region Overriders |
1457 | |||
1404 | public override string ToString() | 1458 | public override string ToString() |
1405 | { | 1459 | { |
1406 | return this.value.ToString(); | 1460 | return String.Format("{0:0.000000}", this.value); |
1407 | } | 1461 | } |
1462 | |||
1408 | #endregion | 1463 | #endregion |
1409 | } | 1464 | } |
1410 | } | 1465 | } |