Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-04-2012, 12:21 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Help: makescreenshot2 selection

Hey there, here's my issue. I'm having some issues using makescreenshot2(). I'm attempting to create a screenshot of a selected size made by the player dragging their mouse in the level. I've got the selecting thing finished, but the makescreenshot2 function isn't behaving as I'd like it to!



Here's the code I'm using.

PHP Code:
//#CLIENTSIDE

function onMouseDown() {
  
this.opx int(mousex);
  
this.opy int(mousey);
}

function 
GraalControl.onMouseDragged() {
  
this.npx int(mousex);
  
this.npy int(mousey);
  
with(findimg(200)) {
    
polygon = {
      
thiso.opxthiso.opy,
      
thiso.npxthiso.opy,
      
thiso.npxthiso.npy,
      
thiso.opxthiso.npy
    
};
    
alpha 0.45;
  }
  
with(findimg(201)) {
    
text thiso.opx SPC "|" SPC thiso.opy;
    
layer 5;
    
screenwidth 2;
    
10;
    
style "c";
  }
  
with(findimg(202)) {
    
text thiso.npx SPC "|" SPC thiso.npy;
    
layer 5;
    
screenwidth 2;
    
30;
    
style "c";
  }
}

function 
onMouseUp() {
  
hideimgs(200202);
  
calculateImage();
}

function 
CalculateImage() {
  
temp.iw this.npx this.opx;
  
temp.ih this.npy this.opy;
  
makescreenshot2(player.level.name@"_"@random(0999999999)@".png"0x3fthis.opxthis.opyplayer.ztemp.iwtemp.ih);

This was really another attempt this thread, but I don't want to draw just the tiles.
Reply With Quote
  #2  
Old 06-04-2012, 01:18 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Well, first of all, you're calling calculateImage() when the function is named CalculateImage(), which in it's own is an error.

You also seem to be using level values rather than screen relative values, which might be the issue - I don't remember how the screenshot commands work exactly.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #3  
Old 06-04-2012, 01:26 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by xXziroXx View Post
Well, first of all, you're calling calculateImage() when the function is named CalculateImage(), which in it's own is an error.

You also seem to be using level values rather than screen relative values, which might be the issue - I don't remember how the screenshot commands work exactly.
calculateImage and CalculateImage will work either way.
The second point sounds like it might fix it thanks for the tip, I'll try it out.
Reply With Quote
  #4  
Old 06-04-2012, 03:02 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Emera View Post
calculateImage and CalculateImage will work either way.
Even so, it's wrong and shouldn't be practiced.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 06-04-2012, 09:58 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by xXziroXx View Post
Even so, it's wrong and shouldn't be practiced.
+1, he's right that it won't actually make a difference (the engine doesn't care) but ambiguity is always bad in code.
__________________
Reply With Quote
  #6  
Old 06-04-2012, 10:19 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by cbk1994 View Post
+1, he's right that it won't actually make a difference (the engine doesn't care) but ambiguity is always bad in code.
On top of this, it DOES matter in many languages(like Java) which you may eventually find yourself moving on to after Graal/GS2.

Habits die hard, may as well crush them early.
Reply With Quote
  #7  
Old 06-04-2012, 10:22 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by /scripthelp
makescreenshot2(str, int, float, float, float, int, int) - makes a screenshot without gui, parameters are filename, render bit flags (1 (local player) + 2 (other players) + 4 (npcs) + 8 (particles from removed objects) + 0x10 (weapon showimgs) + 0x20 (daynight effect), or 0x3f for everything), levelx, levely, levelz, pixelwidth and pixelheight
This makes it work as intended:

PHP Code:
//#CLIENTSIDE

function onMouseDown() {
  
this.opx int(mousex); 
  
this.opy int(mousey);


function 
GraalControl.onMouseDragged() { 
  
this.npx int(mousex); 
  
this.npy int(mousey); 
  
with (findimg(200)) { 
    
polygon = { 
      
thiso.opxthiso.opy
      
thiso.npxthiso.opy
      
thiso.npxthiso.npy
      
thiso.opxthiso.npy 
    
}; 
    
alpha 0.45
  } 
  
with (findimg(201)) { 
    
text thiso.opx SPC "|" SPC thiso.opy
    
layer 5
    
screenwidth 2
    
10
    
style "c"
  } 
  
with (findimg(202)) { 
    
text thiso.npx SPC "|" SPC thiso.npy
    
layer 5
    
screenwidth 2
    
30
    
style "c"
  } 


function 
onMouseUp() { 
  
hideimgs(200202); 
  
generateImage(); 


function 
generateImage() {
  
// Determine Pixel Width and Height
  
temp.iw = (this.npx this.opx) * 16
  
temp.ih = (this.npy this.opy) * 16;
  
// Take Screenshot
  
makescreenshot2(extractfilebase(player.level.name) @ "_" @random(0999999999) @ ".png"0x3fthis.opxthis.opyplayer.ztemp.iwtemp.ih);
  
// Clean up variables
  
this.npx this.npy this.opx this.opy "";

__________________
Quote:
Reply With Quote
  #8  
Old 06-04-2012, 10:23 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
If I was releasing this code to the community (which I'm not) then I would correctly fix it up and what not. I'm only trying to test something out so a lowercase letter doesn't really have to cause so much hassle.
Reply With Quote
  #9  
Old 06-05-2012, 01:13 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Emera View Post
If I was releasing this code to the community (which I'm not) then I would correctly fix it up and what not. I'm only trying to test something out so a lowercase letter doesn't really have to cause so much hassle.
With that attitude you'll soon learn how we'll suddenly stop responding to your threads in these parts of the forums.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #10  
Old 06-05-2012, 01:25 AM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Quote:
Originally Posted by xXziroXx View Post
With that attitude you'll soon learn how we'll suddenly stop responding to your threads in these parts of the forums.
Although I have no business in this section whatsoever, I think you're not being any better with that response, but I do agree with you, don't get me wrong.

Emera, Try a "thank you".

Ziro, You gave your advice on the matter, simply tip your hat and bow out with the class you entered with.
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #11  
Old 06-05-2012, 04:03 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Fulg0reSama View Post
Although I have no business in this section whatsoever, I think you're not being any better with that response, but I do agree with you, don't get me wrong.

Emera, Try a "thank you".

Ziro, You gave your advice on the matter, simply tip your hat and bow out with the class you entered with.
I was just being brutally honest, far too often people come here and ask questions with scripts without ever wanting to learn. I think I speak for the majority of us when I say that we don't mind giving advice or helping with minor codesnippets, as long as it's actually helpful. In this particular case of Emera, he was told what he doing was wrong and brushed it off like it didn't matter, so of course I will comment on it.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #12  
Old 06-05-2012, 04:39 AM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Quote:
Originally Posted by xXziroXx View Post
I was just being brutally honest, far too often people come here and ask questions with scripts without ever wanting to learn. I think I speak for the majority of us when I say that we don't mind giving advice or helping with minor codesnippets, as long as it's actually helpful. In this particular case of Emera, he was told what he doing was wrong and brushed it off like it didn't matter, so of course I will comment on it.
Understood.
Now that I've responded to that...

__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #13  
Old 06-05-2012, 05:51 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by xXziroXx View Post
I was just being brutally honest, far too often people come here and ask questions with scripts without ever wanting to learn. I think I speak for the majority of us when I say that we don't mind giving advice or helping with minor codesnippets, as long as it's actually helpful. In this particular case of Emera, he was told what he doing was wrong and brushed it off like it didn't matter, so of course I will comment on it.
A lot of people have had that attitude lately in these forums. Some of them even get mad at the person helping them because what they've said is not directly related to their problem.

I'm not putting Emera in this category, just saying that it's very annoying as a scripter to see people using the forum for quick fixes for their server and not to learn.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:55 PM.


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