Samarium
Thanks for the reply. Sorry I'm a bit new to how all these classes are structured..
How my current file looks is:
import { RpgMap, MapData } from '@rpgjs/server'
import { NpcEvent } from '../events/npc'
...
import { ChestEvent } from '../events/chest';
import { EnviroEvent } from '../events/enviro';
import { Potion } from '../database/items/potion';
...
Funct1(){
}
Funct2(){
}
const environEvents: any[] = []
for (let x1=0 ; x1 < 100 ; x1++) {
for (let y1=0 ; y1 < 100 ; y1++) {
// Funct1 & 2 here to determine if to push event
environEvents.push({
x: x1*32,
y: y1*32 + 16,
event: EnviroEvent({
name: 'treeEV-' + x1 + '_' + y1,
text: 'You got some wood!',
gain: {
item: Wood
},
graphic: 'bush'
})
})
}
}
@MapData({
id: 'samplemap',
file: require('./tmx/samplemap.tmx'),
name: 'samplemap',
events: [
Villager1Event,
Villager2Event,
...environEvents,
ChestEvent({
name: 'chest-1',
text: 'You got a potion!',
gain: {
item: Potion
}
}),
],
//sounds: ['town']
})
class SampleMap extends RpgMap {
onLoad() {
const tile = this.getTileByPosition(0, 0)
}
}
So where do these event generating functions (Funct1 + 2) which are used to determine if the tile should populate with the event sit to access this "const tile" part?
I was thinking of moving it within the SampleMap class, but then the @MapData can't access the ...environEvents?