2DWorlds Forums
"+" and "-" - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: Suggestions (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=19)
+--- Thread: "+" and "-" (/showthread.php?tid=6703)



"+" and "-" - Nyht - 07-09-2011

"+" is not defined, currently (I believe). It can be used to add with ease, Instead of typing Vec2D:add or <variable>:add, they can use "+". It can also be used in math to make adding easier... AKA, save some time typing.
e.g.

[lua]while true do
eg = game.Environment
eg.Time = eg.Time + 1
wait(0.3)
end[/lua]


[lua]eg = game.World.TelePad2
function onTouched(hit)
if hit == "Body" then
hit.Position = eg.Position + 0.25
end[/lua]

Same thing for "-", will make subtraction easier.


RE: "+" and "-" - AK-47 - 07-09-2011

hit.Position = Vec2D(eg.Position.x, eg.Position.y + 0.25)

Do this instead.


RE: "+" and "-" - Nyht - 07-09-2011

(07-09-2011, 11:35 AM)AK-47 Wrote: hit.Position = Vec2D(eg.Position.x, eg.Position.y + 0.25)

Do this instead.

I didn't realize I made a mistake, lol. This was at like 2:00 AM, though. xD


RE: "+" and "-" - noob007 - 07-09-2011

Operator overloading would be useful...