|
Map entity not spawning where it should Displaying 1-11 of 11 total.
1
Code
|
I've got a bit of a n00b question here, I'm afraid. The entity the player controls is not spawning where I'm telling it to.
This is the script that is called by the map as denoted in MapEd:
int currentplayer=EntitySpawn(30,30,'res/chr/alasdair.chr');
setPlayer(currentplayer);
PlayMusic('res/music/icecave.mid');
Render();
ShowPage();
I've set the Player Start Position in MapEd. Is there something I'm missing?
Posted on 2005-08-09 20:03:59
|
Overkill
|
Try this:
int currentplayer = EntitySpawn(curmap.startx, curmap.starty, 'res/chr/alasdair.chr');
SetPlayer(currentplayer);
PlayMusic('res/music/icecave.mid');
curmap.startx and curmap.starty are the builtins to get the start location specified by Maped3. In addition, ew... midi, replace it with an OGG! ;__; Also, Render() and ShowPage() aren't necessary if right after you're returning control to the map engine.
Posted on 2005-08-09 21:31:24
|
Code
|
Yarrgh! My chr is still showing up in that same spot. Any other thoughts as to why it's not working correctly?
And listen, Mr. Smart Guy, if you know a good free program that can compose OGGs, then I'd like to hear it. ;\
Also, thanks for your critique. I'm still a little unclear about the functions of Render() and ShowPage().
Posted on 2005-08-09 23:38:32
|
Kildorf
|
Where is it showing up, and where are you expecting it to show up? You could stick in a line at the end of that code snippet:
log(str(entity.x[currentplayer]) + ',' + str(entity.y[currentplayer]));
That should print, in v3.log, a line that shows you the entity's map location, in pixels (so divide by 16 to get the tile location).
Also, Render() draws the map and entities and so on into the image screen. ShowPage() displays screen on the player's display. As overkill said, if you're not currently in a function and Verge is just doing it's thing, you don't need to worry about calling those.
Posted on 2005-08-10 05:38:39
|
Code
|
I did as you suggested, Kildorf, and inserted that log() command at the end of my code. When I ran it and checked v3.log, I didn't see anything new in the log file. So I put a MessageBox() command at the end of my code too, and that didn't get executed either.
Yet, I am getting a player-controlled entity on the map, just not in the location I would like it to appear in. I ran the map without the Start() function that I'm using for my startup script and the entity did not appear at all, so the function is definitely being executed, as are the EntitySpawn() (-questionably so) and SetPlayer() commands.
Is there a specific format that the startup script needs to be in? When I declare the startup script in MapEd, I don't include the parentheses at the end, correct? It's ok for different maps to have startup scripts with the same name, right?
Well... yikes, sorry for wasting your time. I didn't #include the map's vc script in my include file. I guess because of this, it was running some of the code, but not all of it. D'oh.
Posted on 2005-08-10 11:03:50
|
Code
|
And thank you both for your patient helpfulness. I have no doubt I will be calling upon it again soon! :/
Posted on 2005-08-10 11:08:35
|
Overkill
|
Quote:Originally posted by Code
Well... yikes, sorry for wasting your time. I didn't #include the map's vc script in my include file. I guess because of this, it was running some of the code, but not all of it. D'oh.
You don't need to #include a map's vc. It will be compiled automatically as long as the map of the same name exists. You just gotta make sure that EVERYTHING in your map's VC code is inside of your functions.
Also, if your character's spawning at a wrong point, look at the coordinates at the bottom in Maped. It tells you what tile coordinate your cursor's at. Copy the coordinates of the point that looks right to your start position :D.
Posted on 2005-08-10 12:24:07
|
Code
|
Oh, really? That's strange, because the minute I explicitly #included my map's vc in my list of #includes, everything in my map's startup function was executed the way I intended it to be, and my entity spawned where I told it to spawn. (Hurrah!)
All my code is inside of my startup function, and before, when I was trying to get the entity to spawn in the correct location, I tried outlandish coordinates like (10,160), but it wouldn't budge. Still, everything seems to be working now, so no worries.
Posted on 2005-08-10 15:57:50
|
CrazyAznGamer
|
Quote:Originally posted by Code
Oh, really? That's strange, because the minute I explicitly #included my map's vc in my list of #includes, everything in my map's startup function was executed the way I intended it to be, and my entity spawned where I told it to spawn. (Hurrah!)
All my code is inside of my startup function, and before, when I was trying to get the entity to spawn in the correct location, I tried outlandish coordinates like (10,160), but it wouldn't budge. Still, everything seems to be working now, so no worries.
That means you made the map VC global, which... really shouldn't do anything, other than take up more RAM during runtime and... =/
I dunno.
Posted on 2005-08-11 18:49:46
|
vecna
|
Quote:Originally posted by CrazyAznGamer
Quote:Originally posted by Code
Oh, really? That's strange, because the minute I explicitly #included my map's vc in my list of #includes, everything in my map's startup function was executed the way I intended it to be, and my entity spawned where I told it to spawn. (Hurrah!)
All my code is inside of my startup function, and before, when I was trying to get the entity to spawn in the correct location, I tried outlandish coordinates like (10,160), but it wouldn't budge. Still, everything seems to be working now, so no worries.
That means you made the map VC global, which... really shouldn't do anything, other than take up more RAM during runtime and... =/
I dunno.
No, I can see why it would work. Basically mapvc is the same as system vc, just loaded as a temporary namespace. So #including it into system.vc, while not something I would have thought about doing, would work, except that you'd have to name everything uniquely across all your maps if you did it that way.
My suspicion is that uh... I dont think you can put maps in a subdirectory and have it auto-compile them? That was one of those things I meant to fix.. maybe Jesse did it already... what do I know. Thats my guess as to why the map-vc isn't being compiled into the map.
Posted on 2005-08-11 19:42:16
|
Jesse
|
I don't think I fixed this, for the record!
Posted on 2005-08-11 23:55:14
|
Displaying 1-11 of 11 total.
1
|
|