bravespiritz
Member
- Joined
- Aug 10, 2023
- Messages
- 33
- Reaction score
- 5
Put all of your desires in the first post.Yes so it rotates, but after rotworm it has a delay on 20sec
local delay = 20
local monsterIndex = 1
local spawnPosition = Position(1000, 1000, 7)
local monsterList = {
"rat",
"cave rat",
"troll",
"rotworm"
}
local function createCreatureFromExternalTable(index)
local monster = Game.createMonster(monsterList[index], spawnPosition)
monster:registerEvent("SpawnRandomMonsterOnDeath")
end
local creatureevent = CreatureEvent("SpawnRandomMonsterOnDeath")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
monsterIndex = monsterIndex < #monsterList and...
local spawnPosition = Position(1000, 1000, 7)
local monsterList = {
"rat", "cave rat", "troll",
"demon", "rotworm"
}
local creatureevent = CreatureEvent("SpawnRandomMonsterOnDeath")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
local rand = math.random(#monsterList)
local monster = Game.createMonster(monsterList[rand], spawnPosition)
monster:registerEvent("SpawnRandomMonsterOnDeath")
return true
end
creatureevent:register()
local globalevent = GlobalEvent("SpawnRandomMonsterOnStartup")
function globalevent.onStartup()
local rand = math.random(#monsterList)
local monster = Game.createMonster(monsterList[rand], spawnPosition)
monster:registerEvent("SpawnRandomMonsterOnDeath")
return true
end
globalevent:register()
TFS 1.4.2Do not forget to leave information about the engine you are using:
For example:
TFS 1.x+ / TFS 0.4 / Canary / ect...
This is very important so that we can fast help you.
in what file am I writing this?Something like this should work.
Lua:local spawnPosition = Position(1000, 1000, 7) local monsterList = { "rat", "cave rat", "troll", "demon", "rotworm" } local creatureevent = CreatureEvent("SpawnRandomMonsterOnDeath") function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified) local rand = math.random(#monsterList) local monster = Game.createMonster(monsterList[rand], spawnPosition) monster:registerEvent("SpawnRandomMonsterOnDeath") return true end creatureevent:register()
TFS 1.4.2
in what file am I writing this?
data/scripts
it works thanks, but If I dont want it to be random. If I want in this order. how would I go about changing itdata/scripts
So that it rotates? 1-2-3-4, 1-2-3-4?it works thanks, but If I dont want it to be random. If I want in this order. how would I go about changing it
1. rat",
2. "cave rat",
3. "troll",
4."rotworm"
local monsterIndex = 1
local spawnPosition = Position(1000, 1000, 7)
local monsterList = {
"rat",
"cave rat",
"troll",
"rotworm"
}
local creatureevent = CreatureEvent("SpawnRandomMonsterOnDeath")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
monsterIndex = monsterIndex < #monsterList and monsterIndex + 1 or 1
local monster = Game.createMonster(monsterList[monsterIndex], spawnPosition)
monster:registerEvent("SpawnRandomMonsterOnDeath")
return true
end
creatureevent:register()
local globalevent = GlobalEvent("SpawnRandomMonsterOnStartup")
function globalevent.onStartup()
local monster = Game.createMonster(monsterList[monsterIndex], spawnPosition)
monster:registerEvent("SpawnRandomMonsterOnDeath")
return true
end
globalevent:register()
Yes so it rotates, but after rotworm it has a delay on 20secSo that it rotates? 1-2-3-4, 1-2-3-4?
Like this I guess.
Lua:local monsterIndex = 1 local spawnPosition = Position(1000, 1000, 7) local monsterList = { "rat", "cave rat", "troll", "rotworm" } local creatureevent = CreatureEvent("SpawnRandomMonsterOnDeath") function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified) monsterIndex = monsterIndex < #monsterList and monsterIndex + 1 or 1 local monster = Game.createMonster(monsterList[monsterIndex], spawnPosition) monster:registerEvent("SpawnRandomMonsterOnDeath") return true end creatureevent:register() local globalevent = GlobalEvent("SpawnRandomMonsterOnStartup") function globalevent.onStartup() local monster = Game.createMonster(monsterList[monsterIndex], spawnPosition) monster:registerEvent("SpawnRandomMonsterOnDeath") return true end globalevent:register()
Put all of your desires in the first post.Yes so it rotates, but after rotworm it has a delay on 20sec
local delay = 20
local monsterIndex = 1
local spawnPosition = Position(1000, 1000, 7)
local monsterList = {
"rat",
"cave rat",
"troll",
"rotworm"
}
local function createCreatureFromExternalTable(index)
local monster = Game.createMonster(monsterList[index], spawnPosition)
monster:registerEvent("SpawnRandomMonsterOnDeath")
end
local creatureevent = CreatureEvent("SpawnRandomMonsterOnDeath")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
monsterIndex = monsterIndex < #monsterList and monsterIndex + 1 or 1
addEvent(createCreatureFromExternalTable, (monsterIndex == 1 and delay or 0) * 1000)
return true
end
creatureevent:register()
local globalevent = GlobalEvent("SpawnRandomMonsterOnStartup")
function globalevent.onStartup()
local monster = Game.createMonster(monsterList[monsterIndex], spawnPosition)
monster:registerEvent("SpawnRandomMonsterOnDeath")
return true
end
globalevent:register()
Put all of your desires in the first post.
Scattering them along like this is annoying.
Lua:local delay = 20 local monsterIndex = 1 local spawnPosition = Position(1000, 1000, 7) local monsterList = { "rat", "cave rat", "troll", "rotworm" } local function createCreatureFromExternalTable(index) local monster = Game.createMonster(monsterList[index], spawnPosition) monster:registerEvent("SpawnRandomMonsterOnDeath") end local creatureevent = CreatureEvent("SpawnRandomMonsterOnDeath") function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified) monsterIndex = monsterIndex < #monsterList and monsterIndex + 1 or 1 addEvent(createCreatureFromExternalTable, (monsterIndex == 1 and delay or 0) * 1000) return true end creatureevent:register() local globalevent = GlobalEvent("SpawnRandomMonsterOnStartup") function globalevent.onStartup() local monster = Game.createMonster(monsterList[monsterIndex], spawnPosition) monster:registerEvent("SpawnRandomMonsterOnDeath") return true end globalevent:register()