Forum

> > CS2D > Scripts > monster spawn error
Forums overviewCS2D overview Scripts overviewLog in to reply

English monster spawn error

1 reply
To the start Previous 1 Next To the start

old monster spawn error

superygorss
User Off Offline

Quote
I created a monster he is not born over the error is this:

tilex, tiley = math.random(m.spawn1[1], m.spawn2[1]), math.random(m.spawn1[2], m.spawn2[2])

how to solve?

my map:

RPG_Pokemon_World by kiss the shot ( my map )

monsters.lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("ms100", "MONSTERms100")
function MONSTERms100()
	t = t + 1
	if t % 100 == 0 then
		while #MONSTERS < CONFIG.MAXMONSTERS do
			local rand
			repeat 
				rand = math.random(#CONFIG.MONSTERS)
			until math.random(0, 100) < CONFIG.MONSTERS[rand].spawnchance
			local m = deepcopy(CONFIG.MONSTERS[rand])
			local x, y, tilex, tiley
			repeat
				if m.spawn1 then
					tilex, tiley = math.random(m.spawn1[1], m.spawn2[1]), math.random(m.spawn1[2], m.spawn2[2])
				else
					tilex, tiley = math.random(map'xsize'), math.random(map'ysize')
edited 1×, last 02.12.12 09:54:36 pm

old Re: monster spawn error

Yates
Reviewer Off Offline

Quote
Replace it with this:
1
tilex, tiley = math.random(spawn[1][1], spawn[2][1]), math.random(spawn[1][2], spawn[2][2])
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview