0


What the fuck?

dofile("sys/lua/webnet.lua")

w = webnet.new()
e,msg,s = w:load('sys/lua/IpToCountry.csv')

addhook("join","join_hook")
function join_hook(id)
    iso,name = w:lookup(player(id,"ip"))
    msg("©000255000Player "..player(id,"name").." joined from "..name) 
end

LUA ERROR: sys/lua/server.lua:9: attempt to call global 'msg' (a nil value)

The function msg doesn't work anymore?

flag offensive
asked 2010-10-14 14:06:58.964057
46
add comment
4 Answers:
0


e,msg,s = w:load('sys/lua/IpToCountry.csv')

The global variable msg is redeclared in this statement and overwrites the existing definition. (Note that even if you declare everything as local, the runtime lookup hash will still bump the old msg with the new one, just rename it something else).

permanent link | flag offensive
answered 2010-10-14 14:19:45.315802
41
add comment
0


Oh shit, how could I miss that scratches head.

permanent link | flag offensive
answered 2010-10-14 14:32:02.548693
46
add comment
0


hehe, don't worry, I just took a prelim (midterm) for a CS class and this was our extra credit question:

How do you swap two integer variables X and Y using bitwise operands and no auxiliary variables?

I cannot fucking remember the xor symbol on Java so I wrote in pseudocode:

X = X xor Y; Y = X xor Y; X = X xor Y;

Turns out that you had to write real Java.... T_T FML

permanent link | flag offensive
answered 2010-10-15 02:20:55.048687
41
add comment
0


^ is the xor operator.

X = X + Y;   Y = X - Y;  X = X - Y;

In a way adding is bitwise AND'ing and XOR'ing :P

permanent link | flag offensive
answered 2010-10-15 08:48:31.251284
46
add comment
Your answer:
You are now not logged in but you can answer first and then login
toggle preview



Tags:

× 1
× 1
× 1

Asked: 1 year, 4 months ago

Seen: 881 times

Last updated: 1 year, 4 months ago

Made with Django.