class system lua general understanding [Solved]
Posted: Tue Mar 27, 2018 6:53 am
by Anakin
Hey there,
i'm really confused by the class system from lua. Maybe someone can explain it to me
this is the original function
that i try to wrap this way:
output log:
why does the cp look like that?? In my understanding it should like similar with different name value. But there is no name value.
i'm really confused by the class system from lua. Maybe someone can explain it to me
this is the original function
Hidden/Spoiler:
[code]
function ObjectiveConquest:AddCommandPost(cp)
--make sure we have a table to add the cp to
self.commandPosts = self.commandPosts or {}
--do all the error checking we can on the cp
assert(cp.name, "WARNING: no name supplied for the command post")
cp.name = string.lower(cp.name)
self.commandPosts[cp.name] = cp
--keep a running tally of the bleedValue relative to each team
if not self.totalBleedValue then
self.totalBleedValue = {}
self.totalBleedValue[self.teamATT] = 0
self.totalBleedValue[self.teamDEF] = 0
end
self.totalBleedValue[self.teamATT] = self.totalBleedValue[self.teamATT] + GetCommandPostBleedValue(cp.name, self.teamATT)
self.totalBleedValue[self.teamDEF] = self.totalBleedValue[self.teamDEF] + GetCommandPostBleedValue(cp.name, self.teamDEF)
end
[/code]
function ObjectiveConquest:AddCommandPost(cp)
--make sure we have a table to add the cp to
self.commandPosts = self.commandPosts or {}
--do all the error checking we can on the cp
assert(cp.name, "WARNING: no name supplied for the command post")
cp.name = string.lower(cp.name)
self.commandPosts[cp.name] = cp
--keep a running tally of the bleedValue relative to each team
if not self.totalBleedValue then
self.totalBleedValue = {}
self.totalBleedValue[self.teamATT] = 0
self.totalBleedValue[self.teamDEF] = 0
end
self.totalBleedValue[self.teamATT] = self.totalBleedValue[self.teamATT] + GetCommandPostBleedValue(cp.name, self.teamATT)
self.totalBleedValue[self.teamDEF] = self.totalBleedValue[self.teamDEF] + GetCommandPostBleedValue(cp.name, self.teamDEF)
end
[/code]
Hidden/Spoiler:
[code]
if ObjectiveConquest then
aih_backup = ObjectiveConquest.AddCommandPost
ObjectiveConquest.AddCommandPost = function(cp, ...)
print(">>", cp.name)
uf_print(cp, false, 0)
return aih_backup(cp, unpack(arg))
end
else
print(">> go and find a solution")
end
[/code]
if ObjectiveConquest then
aih_backup = ObjectiveConquest.AddCommandPost
ObjectiveConquest.AddCommandPost = function(cp, ...)
print(">>", cp.name)
uf_print(cp, false, 0)
return aih_backup(cp, unpack(arg))
end
else
print(">> go and find a solution")
end
[/code]
Hidden/Spoiler:
[code]
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
[/code]
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
>> nil
0: uf_print(): Starting: table: 085B5ACC function: 085D2904 false 0
0: Key, Value: totalBleedValue table: 085B5BCC
0: Key, Value: commandPosts table: 085B5BAC
0: Key, Value: multiplayerRules true
0: Key, Value: textDEF game.modes.con2
0: Key, Value: teamDEF 2
0: Key, Value: textATT game.modes.con
0: Key, Value: teamATT 1
0: uf_print(): Finished: table: 085B5ACC false 0
[/code]