Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Problem sending variable (https://forums.graalonline.com/forums/showthread.php?t=134265646)

sssssssssss 01-29-2012 05:30 AM

Problem sending variable
 
So, kind of going off of my last post about gui images and such, I am now needing to send one of the temp/this variables I have to another weapon's function to continue my process and system. I have this:

I used both temp and this variables attempting to get it to work, as well as this and thiso, because I don't really get what they are and was desperate. :)

I tried posting code but incapsula kept stopping me for some reason.

Basically i have tempvars creating the gui image, then using a catchevent to catch right mouse click, then setting the obj.var to a this.var, and using GuiControl.onSelect in a pop up that shows up when right clicking to switch the 2 selections and either drop the item or send to a shop. Dropping the item works fine and so does everything else, but sending to shop (which is a public function in a different weapon, the shop weapon) results in null. :(

I'm thinking that the var has just been passed to much, or however you put it, but I don't really know, and if it has been, I don't know another way to make this work.

cbk1994 01-29-2012 06:16 AM

Put the code on pastebin.graalcenter.org and post a link.

sssssssssss 01-30-2012 12:37 AM

http://pastebin.graalcenter.org/read...d=329451868910

Note the last function, where it sends to -Player/Shop. Every other single thing works fine with how it is, and even to that last function, obj.wep has the correct value to send to -Player/Shop. It's just when it sends its 0.

Also I forgot to change temp.sendtosell to this.clickedright, it doesn't work as this.clickedright. :/

cbk1994 01-30-2012 03:06 AM

Temporary variables don't transcend functions, you'll need to find some other way to store it. Probably store it as a variable of the weapon or the GUI object.

fowlplay4 01-30-2012 03:32 AM

Looked through your code and made my changes, and what I think could fix your logic issues.

http://pastebin.graalcenter.org/read.php?id=53670813760

sssssssssss 01-30-2012 03:56 AM

With that, everything still works, even drop, and temp.wep in player chat is correct, but its still 0 value when it pulls to -Player/Shop.

fowlplay4 01-30-2012 04:00 AM

Quote:

Originally Posted by sssssssssss (Post 1683168)
With that, everything still works, even drop, and temp.wep in player chat is correct, but its still 0 value when it pulls to -Player/Shop.

Post -Player/Shop's code then.

sssssssssss 01-30-2012 04:28 AM

PHP Code:

public function bringInSell(temp.item) {
  
PLShopSell_Window.destroy();
  
//player.chat = item;
  
new GuiWindowCtrl("PLShopSell_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "178,104";

    
canmove true;
    
canclose true;
    
destroyonhide canresize canmaximize closequery false;
    
text "Sell Item";
    
319;
    
165;

    new 
GuiTextCtrl("PLShopSell_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Please enter price to sell ";
      
width 143;
      
14;
      
3;
    }
    new 
GuiTextCtrl("PLShopSell_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text item;
      
width 143;
      
14;
      
15;
    }
    new 
GuiTextEditCtrl("PLShopSell_TextEdit1") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 91;
      
18;
      
37;
    }
    new 
GuiTextCtrl("PLShopSell_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Rupees";
      
width 37;
      
109;
      
42;
    }
    new 
GuiButtonCtrl("PLShopSell_Button2") {
      
profile GuiBlueButtonProfile;
      
text "Sell";
      
width 63;
      
12;
      
66;
    }
    new 
GuiButtonCtrl("PLShopSell_Button3") {
      
profile GuiBlueButtonProfile;
      
text "Cancel";
      
width 64;
      
85;
      
66;
    }
  }



This worked just fine with our old inventory system using images with showimg. :/

fowlplay4 01-30-2012 06:00 AM

Try: temp.item and echo(temp.item);

Instead of just using item.

sssssssssss 01-30-2012 06:28 AM

nothing, no chat at all that time, no echo, and changed the text =temp.item as well and still comes up null.

fowlplay4 01-30-2012 06:35 AM

Try changing the variable from temp.item to something else like temp.selling_item.

If you: echo(params); does anything show up?

sssssssssss 01-30-2012 07:00 AM

Changed, and still not working. Player chat is 0/null, no echo in rc or scripts (for player/shop), and the gui still shows 0/null for the text. tried with and without temp. in it as well.

fowlplay4 01-30-2012 07:17 AM

If you change:

findweapon("-Player/Shop").bringInSell(temp.wep);

to:

findweapon("-Player/Shop").trigger("TestSellItem", temp.wep);

and add:

PHP Code:

// To the bottom of -Player/Shop
function onTestSellItem(temp.selling) {
  echo(
temp.selling);


does the weapon name show up in F2?

sssssssssss 02-01-2012 03:16 PM

Yep, but I tried referring it to the other function bringInSell in -Player/Shop from the trigger in player shop and it still didnt show up, echoes 0. :/

callimuc 02-01-2012 03:31 PM

Quote:

Originally Posted by sssssssssss (Post 1683350)
Yep, but I tried referring it to the other function bringInSell in -Player/Shop from the trigger in player shop and it still didnt show up, echoes 0. :/

While using .trigger make sure that the function looks like
PHP Code:

function onFoo() 

instead of
PHP Code:

function Foo() 

So you will have to name it
PHP Code:

function onbringInSell() 


sssssssssss 02-02-2012 05:02 AM

I should have known to do that. xD


All times are GMT +2. The time now is 01:29 AM.

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