• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Weeird Error

Ahilphino

Excellent OT User
Joined
Jun 5, 2013
Messages
1,667
Solutions
1
Reaction score
734
Ok. So I have a script which I have registered on every monster like this:

Code:
<event type="death" name="extraLoot" script="monsterdeath.lua"/>

and in every monster.xml file:
Code:
<script>
<event name="extraLoot"/>
</script>

now everything actually works but still, when I start my server the console is spammed with

"[Warning - Monster::Monster] Unknown event name: extraLoot"

if I remove the lines from the monsters, the errors obviously goes away but the scripts also stop working.

The weird part is that even though it says it's an unknown event name, it still registers and makes the script work.

What can be wrong? And it's not the script. If I simply make the script into like this
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    print("Test")
    return true
end
its the same thing

maybe everything needs to be lowercase? <---- nvm didnt help :(
 
Last edited:
ok so i removed this line from all monsters
<script>
<event name="extraLoot"/>
</script>

and solved it via adding this to creatures.lua
Code:
if self:isPlayer() and target:isMonster() then
    target:registerEvent("extraLoot")
end

but now my question is also, wont this register it multiple times in each monster kinda? since everytime u deal dmg to it it seems like it would register? or is there already some inbuilt check for that? or maybe it just doesnt matter cuz in my server u atk real fast and im worried about lagg xD
 
Last edited:
If you're worried about performance, why haven't you considered creating a new event specifically for monsters where you easily can register creature events?

e.g Monster.onSpawn
 
If you're worried about performance, why haven't you considered creating a new event specifically for monsters where you easily can register creature events?

e.g Monster.onSpawn
ok ty! this seems best :)
personally i cant code that so didnt think about it, but ill add that code to my serv and hopefully it will work :)
 
Last edited:
What version are you using? I also do a similar thing on my 1.x test server and it works just fine o_O

Code:
<event type="death" name="MonsterDeathSystem" script="monster_death_system.lua"/>

<script>
    <event name="MonsterDeathSystem"/>
</script>
 
What version are you using? I also do a similar thing on my 1.x test server and it works just fine o_O

Code:
<event type="death" name="MonsterDeathSystem" script="monster_death_system.lua"/>

<script>
    <event name="MonsterDeathSystem"/>
</script>

idk men its some random tfs 1.1 rev from some months back o_O so its probably some bugged rev

the thing is there were no errors some months ago, but i cant remember what i changed that caused the errors since its so long ago
maybe i will remove some chunks from spawns.xml to narrow it down to some mob or maybe its in the sources probably, which i will update when next tfs release is

for now i use this ghettosolution that ninja gave me
 
Back
Top