Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   What is findimg()? (https://forums.graalonline.com/forums/showthread.php?t=134269159)

Spikedude 04-14-2014 09:55 PM

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!

Chompy 04-28-2014 12:41 PM

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 :)

Tim_Rocks 04-28-2014 01:42 PM

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.

Sage_Shadowbane 04-30-2014 08:55 PM

Quote:

Originally Posted by Tim_Rocks (Post 1726969)
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?

Tim_Rocks 04-30-2014 09:49 PM

Yeah, it just doesn't seem to work with GuiMLTextCtrl.

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


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

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