Author Topic: A little help :<?  (Read 1099 times)

« Last Edit: July 25, 2009, 07:06:39 AM by Jimmg »

Code: [Select]
$finposy2 = strreplace($finposy," ","");It's the morning but why exactly is that there?

Code: [Select]
$finposy2 = strreplace($finposy," ","");It's the morning but why exactly is that there?
:cookieMonster: I don't know really. Doesnt work with or without so eh.
« Last Edit: July 24, 2009, 09:43:53 AM by Jimmg »

Wait what? It's a map? What do you want it to do? Got any pics?

Oh and couldn't you just do:
Code: [Select]
mapPic.position = $finposx SPC $finposy2;
Instead of all the ""s crap.
« Last Edit: July 24, 2009, 09:53:27 AM by AGlass0fMilk »

Moving things like the terrain object does not work well. It may function for you but I doubt other people will be able to see it...

Well, when setting mapPic.position, change it to this.  This is purely because it annoys the stuff out of me how you did it.
Code: [Select]
mapPic.position = $finposx SPC $finposy2;Also, purely because it looks ugly the way you also make numbers negative, I will do this.
Code: [Select]
$posx2 = ($posx / 2.7) - ($posx / 2.7) - ($posx / 2.7);
$posy2 = ($posy / 2.7) - ($posy / 2.7) - ($posy / 2.7);
Instead of redefining $deposy and $deposx in each statement, simply move them to the top of the script instead of in the functions.  They aren't local and it doesn't seem as if they change.  Also, remove the quotes.  Integers are not strings like that.  Instead of "-550" you use -550 .  Also, you should change pretty much everything except $deposx and $deposy to local variables because defining them globally doesn't make too much sense.  You should also add a
Code: [Select]
return %finposx;To the end of each XPos and YPos function (changing the finpos variable respectively).  You should also change
Code: [Select]
XPos(%pos);
YPos(%pos);
to
Code: [Select]
%x = XPos(%pos);
%y = YPos(%pos);
and use %x and %y in place of the global variables $finposx and $finposy2 you used to use.

I'm just going to rewrite most of the stuff that you should.  A lot of it is nitpicking at things that I cannot stand.  Some of the code is capitalized differently, and so is spacing.  It doesn't really matter as long as it looks fine to you.
Code: [Select]
function refresh()
{
%camera = serverConnection.getControlObject();
%pos = %camera.getPosition();
%x = XPos(%pos);  // Use returned values for the variables we want
%y = YPos(%pos);
mapPic.position = %x SPC %y;  // Much cleaner now, isn't it?
schedule(200,0,'refresh'); // I think a function should be a tagged string, and since you also don't need an argument I removed that.
}

function XPos(%pos)
{
%posx = getWord(%pos,0); // Using local instead of global...
%posx2 = (%posx / 2.7) - (%posx / 2.7) - (%posx / 2.7); // Longer but it makes more sense to me.
%finposx = %posx2 + $deposx;
return %finposx;
}

function YPos(%pos)
{
%posy = getWord(%pos,1);
%posy2 = (%posy / 2.7) - (%posy / 2.7) - (%posy / 2.7);
%finposy = %posy2 + %deposy;
return %finposy;
}

I'd also like to say pretty much all of this is purely optional but makes more sense to me and looks better in most cases.
The problem was also in the YPos function you used the variable %ypos instead of %pos (used in the function)

Moving things like the terrain object does not work well.
No, it's a picture.

The problem was also in the YPos function you used the variable %ypos instead of %pos (used in the function)
Still doesn't work. :<
D: I thought I clicked edit.

Well, what Azi said. I would've coded it like him.

Try removing the strReplace() statement and just use $finposy instead of $finposy2


Echo stuff. Echo the end results. Check out what might be wrong.