Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Getting center of level (makescreenshot) (https://forums.graalonline.com/forums/showthread.php?t=134264777)

pig132 10-12-2011 06:33 AM

Getting center of level (makescreenshot)
 
Alright i've run into a little problem making my own screenshot weapon.

Everything works fine except when trying to get the center of the level. I've tried fowlplay4's line of:
PHP Code:

temp.center = {player.+ (screenwidth 32), player.+ (screenheight 32)}; 

And i've also tried things like:
PHP Code:

temp.center = {(screenwidth 2), (screenheight 2)} 

And also 30, 30 for the center but no matter what i set it to, it always outputs the same image.

Why is this?

PHP Code:

//#CLIENTSIDE
function onWeaponFired() {
  
temp.filename "screenshot_" int(random(100001000000)) @ ".png";
  
temp.center = {player.+ (screenwidth 32), player.+ (screenheight 32)};
  
ShowFlash();
  
makescreenshot2(temp.filename0x3ftemp.center[0], temp.center[1], player.zscreenwidthscreenheight);
}

function 
ShowFlash() {
  
with (findimg(200)) {
    
polygon = {
      
00640,
      
6464064
    
};
    
    for (
temp.1temp.>= 0temp.-= 0.1;) {
      
alpha -= 0.1;
      
sleep(0.05);
      
      if (
temp.== 0) {
        
hideimg(200);
      }
    }
  }


Thank you ^^

0PiX0 10-12-2011 07:14 AM

A level's center position is { level.width / 2, level.height / 2 }

pig132 10-12-2011 07:27 AM

Still, for some reason not taking the screenshot from the center :(

Tricxta 10-12-2011 08:22 AM

Are the co-ordinates a screen co-ord or a tiles co-ord?

pig132 10-12-2011 08:27 AM

Screen, i believe. But regardless, if i did screenheight and screenwidth its still the same position

Tricxta 10-12-2011 08:36 AM

No clue as to how to how you would take a screenshot of the whole level unless your screen's that big sorry.

0PiX0 10-12-2011 08:52 AM

Assuming your resolution is high enough, this screenshots a level, at it's center, when alt + 1 is pressed.
PHP Code:

//#CLIENTSIDE
function GraalControl.onKeyDown(temp.keycodetemp.keystringtemp.scancode) {
  if (
keycode == 1073)
    
makescreenshot2("screenshot" int(random(100000,999999)) @ ".png"0x3fplayer.level.width 2player.level.height 2player.zplayer.level.width 16player.level.height 16);



pig132 10-12-2011 09:01 AM

Not looking for it to take a shot of the whole level, just have the center of the screenshot, the center of the level.

cbk1994 10-12-2011 09:11 AM

No idea if it will work, but what about doing this...

PHP Code:

setFocus(player.level.width 2player.level.height 2); 

right before taking the screenshot?

pig132 10-13-2011 01:31 AM

Quote:

Originally Posted by cbk1994 (Post 1670649)
No idea if it will work, but what about doing this...

PHP Code:

setFocus(player.level.width 2player.level.height 2); 

right before taking the screenshot?

Nope...:cry:

Emera 10-13-2011 05:06 PM

Are you trying to find the center of the players screen or the center of the players level?

Finding the middle of the players screen would be half of the screen width.

Finding the center of a specific level would be half of the height (64) and half of the width (64) since a levels height and width are both 62 :D

0PiX0 10-13-2011 05:15 PM

Quote:

Originally Posted by Emera (Post 1670772)
Are you trying to find the center of the players screen or the center of the players level?

Finding the middle of the players screen would be half of the screen width.

Finding the center of a specific level would be half of the height (62) and half of the width (62) since a levels height and width are both 62 :D

The makescreenshot2 parameters take level x and y. One level (nw) is 64 by 64.

Emera 10-13-2011 05:16 PM

Quote:

Originally Posted by 0PiX0 (Post 1670774)
The makescreenshot2 parameters take level x and y. One level (nw) is 64 by 64.

Yeah that's what I was saying. I might play around with it and see what I can do :D

0PiX0 10-13-2011 05:43 PM

Solution.
PHP Code:

//#CLIENTSIDE
function GraalControl.onKeyDown(temp.keycodetemp.keystringtemp.scancode) { 
  if (
keycode != 1073// ALT + 1
    
return;
  
  
// Limit size to level size or screen res
  
temp.pixel_width = (player.level.width screenwidth 16) ? screenwidth player.level.width 16;
  
temp.pixel_height = (player.level.height screenheight 16) ? screenheight player.level.height 16;
  
  
// Get coordinates for screenshot
  
temp.level_x player.level.width pixel_width 32;
  
temp.level_y player.level.height pixel_height 32;
  
  
makescreenshot2("screenshot" int(random(100000,1000000)) @ ".png"
    
0x3f// include everything
    
level_x
    
level_y
    
player.z
    
pixel_width
    
pixel_height); 



ff7chocoboknight 10-13-2011 05:55 PM

Quote:

Originally Posted by Emera (Post 1670775)
Yeah that's what I was saying. I might play around with it and see what I can do :D

Wouldn't it have been awesome if you actually said 64x64 instead of 62x62?


All times are GMT +2. The time now is 04:56 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.