Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-14-2014, 09:55 PM
Spikedude Spikedude is offline
Senator Amsel Zephlyn
Spikedude's Avatar
Join Date: Jul 2006
Posts: 283
Spikedude will become famous soon enough
What is findimg()?

I feel I've gotten a lot better at scripting over the years, but a couple of things still don't make sense to me. I was hoping some of the pros around here could give me a better explanation of findimg() in particular.

What exactly do you create by doing findimg()? I've started to notice some of the cool things you can do, but I'm still not sure why some things work. If the NPC has its own image, what are you referring to with "findimg(1)" or "findimg(100)," and is there a limit to the indexes? I'm sure I sound really stupid about this, I just haven't ever understood what I'm doing when I use findimg() in a script.

Thanks everyone!
__________________
Reply With Quote
  #2  
Old 04-28-2014, 12:41 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Hey there!

findimg() basically returns the object of an image displayed at the given index, and there's really no limit to indices, besides the fact that from 0 to 200 will draw images relative to the level (0-64 x and y grid) and above will draw on a screen level (0 to screenwidth and screenheight)

You can also create images using findimg(#), as it will simply return an image object even though you have not created that said image beforehand.

PHP Code:
with(findimg(200)) {
  
image "block.png";
  
width height 42;
  
screenheight/width/2;
  
screenheight/height/2;

When you assign variables inside the with() statement, there's no need to prepend variables with this. as all the variables are in scope with the object you give with()

You can also use it for referencing,

PHP Code:
// say you have a health bar on your GUI and you want to update it

function onCreated() {
  
// create gui, health bar is index 202 for example, assign it a maxwidth on creation
  // for easier updating later on, or you can use the imagewidth function

  
this.healthbar findimg(202);
}

function 
updateHealthBar() {
  
temp.php max(player.health/player.maxhealth1); // player health percentage
  // does not take into account bonuses like extra health or whatever you have in your system
  // this is just an example

  
this.healthbar.width temp.php ? (temp.php this.healthbar.maxwidth) : 0;

And if my memory isn't wrong, showimg() will also return the image object, so you can do something like

NPC Code:
this.healthbar = showimg(200, "healthbar.png", 0, 0, 64, 16);



I didn't have a place to test this on, but if there's something more, just ask
__________________
Reply With Quote
  #3  
Old 04-28-2014, 01:42 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Great future reference, I had no idea that 0-200 was relative to the level. Side note, does anyone know why findimg() allows using drop shadows, but GuiMLTextCtrl for example prevents using shadows. It's always bothered me.
__________________
Reply With Quote
  #4  
Old 04-30-2014, 08:55 PM
Sage_Shadowbane Sage_Shadowbane is offline
Graal Developer
Sage_Shadowbane's Avatar
Join Date: Mar 2004
Posts: 585
Sage_Shadowbane will become famous soon enough
Quote:
Originally Posted by Tim_Rocks View Post
Great future reference, I had no idea that 0-200 was relative to the level. Side note, does anyone know why findimg() allows using drop shadows, but GuiMLTextCtrl for example prevents using shadows. It's always bothered me.
Are you assigning the shadow to the GUIctrl's profile? eg: profile.textShadow = true; profile.shadowOffset = {1, 2};?

I've never had a problem getting shadows to work with my GUIctrl's?
Reply With Quote
  #5  
Old 04-30-2014, 09:49 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Yeah, it just doesn't seem to work with GuiMLTextCtrl.

Edit: Just tried what you provided, and it worked.......
__________________

Last edited by Tim_Rocks; 04-30-2014 at 10:14 PM..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:50 AM.


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