Forums » Community Projects


Nov 14, 2007 blacknet link
I wrote this calculator tonight in lua, basic 4 function, %, -/+, memory.

syntax is /calc
Nov 14, 2007 liddy link
wow quite possibley the most usefull plugin, perhaps the devs shoudl consider this as part of the next update.
Nov 14, 2007 raybondo link
You should make a scientific mode. and have hex support. so you can hex someone.
Nov 14, 2007 blacknet link
that's up next :)

I have been looking at a way to do a on/off bind with this and not able to figure that one out. say you bind "F6" to /calc, press once it shows, press again it hides.

Nov 15, 2007 mr_spuck link

I'm pretty sure firsm did something like that in vokb.
Grep for keycmd. looks like he used the k_any attribute on the dialog. That probably only works if the dialog still has focus though.

Another feature request: a command mode, something like this
/calc 1 + 1
You could probably abuse loadstring for this if you don't want to write your own evaluator.
loadstring("return "..table.concat(args)) or something like that.
Although it'd allow calling any game function and so kill the client and stuff with a formula...
Nov 15, 2007 Lord~spidey link
thats just kickass :)

now make it have a nice Ui that goes with the skin your using like notepad
Nov 15, 2007 slime73 link
Yeah I've been using loadstring for my own calculator recently.
Nov 15, 2007 raybondo link
You'd have to look at some bind/alias examples that toggle.
Basically, it consists of 3 alias/binds that bind the key back and forth between two commands
/alias blahon calcon; bind key blahoff
/alias blahoff calcoff; bind key blahon
/bind key blahon

I think that may work. I haven't used alias/binds in a long while.
You could do a bunch of it in lua, instead.
make your /calc function see if calc dialog is open and then close it and vice versa checking whether dialog.visible=="YES" or not.
Nov 16, 2007 blacknet link
The problem is when the lua apps are displayed all of the keyboard shortcuts are disabled because the lua app has control. I figured there were 2 possible ways to handle this. 1) read the binds and check for the app toggle, 2) some how give partial control to the app which would be a very bad idea as the app may need some/many/all of the hot keys for other things.

I am also not aware of any way to read the binds inside lua.

Nov 16, 2007 raybondo link
Oh yeah, duh.

You can do this:
function dialog:k_any(char)
local command = gkinterface.GetCommandForKeyboardBind(char)
if command == 'calc' then
-- close window here
return iup.IGNORE
return iup.CONTINUE

That will make your dialog close when it sees the key bound to the calc command being pressed.
Nov 16, 2007 blacknet link
oh yes, that works superb thanks!

We need a kb for stuff like this.

Nov 18, 2007 blacknet link
This is version 1.1 I have added several things.

USAGE: /calc

Keyboard input,
Sci functions,
function color codes,
extra error checking,

Hot keys:
# = number 0-9
* = multiply
+ = plus/equal
enter = equal
. = period
/ = divide
% = percent
- = minus
= - equal

Backspace = delete last digit on display
a = clear all
e = clear entry
m = memory add
r = memory recall
c = memory clear
ESC = closes program
'bind key' = closes program


Nov 18, 2007 Shadoen link
Now make a graphing one! :D
Nov 18, 2007 speeker02 link
Who's gonna make a Massively Multiplayer Online Roleplaying Game in Lua that we can load into vendetta?
Nov 20, 2007 greengeek link
If Divide by Zero errors don't cause your ship to explode, then I think it's just not worth it.
Nov 23, 2007 Eonis Jannar link
On Tuesday at 11:13 PM, greengeek wrote:
If Divide by Zero errors don't cause your ship to explode, then I think it's just not worth it.

Apr 03, 2008 rhapsody link
Apr 03, 2008 FatStrat85 link
Apr 08, 2008 zendada link
A Traders dream app. Thanks. :)
Apr 10, 2008 zamzx zik link
"On Tuesday at 11:13 PM, greengeek wrote:
If Divide by Zero errors don't cause your ship to explode, then I think it's just not worth it.