Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Item description (https://forums.graalonline.com/forums/showthread.php?t=134267523)

brokk 12-08-2012 07:04 AM

Item description
 
How do I make the Gui display the item description?

In the actual weapon I have this

PHP Code:

//#CLIENTSIDE
function onCreated() {
 
obj.description "This is a test.";
 } 

In the inventory I have this for the display text part

--This is done after item is clicked.
PHP Code:

      new GuiTextCtrl("Inventory_Item_Text") {
        
profile GuiBlueTextProfile;
        
text obj.description;
        
screenwidth/2-700+480;
        
screenheight/2-350+140;
        
layer 2;
      } 

I may be way off. But I'm still trying to learn

Gunderak 12-08-2012 11:44 AM

Under onCreated put this.description = "whatever"; then in the inventory put findweapon("wepname").description;

cbk1994 12-08-2012 02:26 PM

You need to set the text of Inventory_Item_Text to the weapon's description each time the player selects an item. In other words, when the player selects the item, do something like...

PHP Code:

Inventory_Item_Text.text weapon.description

where weapon is a weapon object (e.g. from findWeapon as above).

Additionally, the description needs to be a flag on the weapon object, so use this.description inside the weapon like Gunderak showed above.

greggiles 12-22-2012 03:48 PM

Instead of starting a new thread, I thought I'd post in this one. I am also doing a weapon description in a similar way. But I had another idea but I need some help to complete it.

In the Weapon, I have this:

PHP Code:

function onSetDescription() {
 
player.description "blah, blah, blah";
 } 

In my Inventory, I have this for Weapon clicked:
This is the script where I need the help

PHP Code:

function onItemPressed(obj,bla,bla,bla,clickcount) {
  if (
clickcount == 1) {
    if (
IsObject("Inventory_Main")) {
      new 
GuiBitmapCtrl("Inventory_Item_Icon") {
      
play("age_click");
      
//TRIGGER THE 'onSetDescription()' on the clicked weapon  
      //What code would I put to do this???
        
screenwidth/2-615+500;
        
screenheight/2-340+100;
        
width height 32;
        
bitmap obj.normalbitmap;
        
layer 2;
      } 

And of course this displays the text in the INV script:

PHP Code:

 showText(213screenwidth/2-50screenheight/2+50"showg""b""DESCRIPTION:" @(player.description));
   
with (findImg(212)) {
    
textshadow true;
    
shadowoffset "-2 2";
    
shadowcolors "0 0 0";
    
font "showg";
    
style "b";
    
layer 23;
    
zoom 1;



BboyEatsbacon 01-10-2013 12:54 AM

Quote:

Originally Posted by greggiles (Post 1710251)
PHP Code:

function onSetDescription() {
 
player.description "blah, blah, blah";
 } 


It would be better to do something like:
PHP Code:

function onSetDescription() {
    
player.client.description "hihihihihi";
    
showText(213screenwidth/2-50screenheight/2+50"showg""b""DESCRIPTION:" @(player.client.description)); 
 } 

I'd recommend updating the text right when you update the description with onSetDescription, then have the original launch read from the var, which is why it is still being set here.

Add that to your inventory script, you can't cross-reference other scripts whilst on clientside, as that is provoking serverside data.

You can use a trigger to the server then back to the client, but that's just a waste of time when you have a shorter, less complex way of completing your task that still is as efficient.


All times are GMT +2. The time now is 03:53 PM.

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