[3.3.5][c++][Question] menu

User Tag List

Results 1 to 5 of 5
  1. #1
    Borg333's Avatar Member Authenticator enabled
    Reputation
    2
    Join Date
    Dec 2013
    Posts
    33
    Thanks G/R
    6/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [3.3.5][c++][Question]

    Hi everyone, i trying to register own lua function to the game by:
    Code:
    int luafunction() {
    	return 2+2;
    }
    FramescriptRegister("mynewluafunction", (int)luafunction);
    After calling /dump mynewluafunction() in game i have
    PHP Code:
    Dumpvalue=mynewluafunction()
    [
    1]=<function [DevTools_Dump]>,
    [
    2]=value,
    [
    3]=<function>,
    [
    4]=<function [DevTools_Dump]> 
    instead of returning 4
    Also tryed
    Code:
    char* luafunction() {
    	return "test";
    }
    it returns
    HTML Code:
    Dump: value=mynewluafunction()
    empty result
    I feels that question is very stupid but i'm missing something...
    Last edited by Borg333; 08-05-2022 at 04:31 AM.

    [3.3.5][c++][Question]
  2. #2
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thats not how lua works.
    You need to push return values onto the lua stack. The return value of your function is the amount of return values pushed onto the stack.
    Programming in Lua : 26.1
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  3. Thanks aeo, Borg333 (2 members gave Thanks to xalcon for this useful post)
  4. #3
    bonbom1's Avatar Member CoreCoins Purchaser
    Reputation
    3
    Join Date
    Jun 2009
    Posts
    6
    Thanks G/R
    2/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Finally someone added all the proper information to figure out a lua problem. Far too many miss the php and html code

  5. #4
    Borg333's Avatar Member Authenticator enabled
    Reputation
    2
    Join Date
    Dec 2013
    Posts
    33
    Thanks G/R
    6/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [answer]

    Thanks! It works by
    Code:
    int luafunction(int state) {
    	FrameScriptPushNumber(state, 7);       // we want to get 7 as result
    	return 1;                                                      // number of result to be returned
    }
    HTML Code:
    Dump: value=mynewluafunction()
    [1]=7

  6. #5
    Borg333's Avatar Member Authenticator enabled
    Reputation
    2
    Join Date
    Dec 2013
    Posts
    33
    Thanks G/R
    6/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have one missunderstading.
    I trying to get arg value by
    Code:
    inline auto FrameScript_ToNumber(int Lstate, int arg)
    {
    	return ((double(__cdecl*)(int, int))0x0084E030)(Lstate, arg);
    }
    always return 0, if i checks the arg by FrameScript_IsNumber, it can read and return 1 if it is a number, athoerwise 0

    Code:
    inline auto testint(int Lstate, int arg)
    {
    	double arg = FrameScript_ToNumber(Lstate, 1); //always 0
    	return 1; 	//return arg as argument from call
    }
    on return 1, i see my arg, but how can i extract it from argument from call, i cant understand

    -------------------------------------------
    Nvm, its worked, don't know why it didn't work before
    Last edited by Borg333; 08-08-2022 at 03:11 AM.

Similar Threads

  1. Model Changing Question
    By MasterYuke in forum World of Warcraft General
    Replies: 6
    Last Post: 09-17-2006, 09:56 PM
  2. Couple Private Server questions
    By Jboz in forum World of Warcraft General
    Replies: 21
    Last Post: 07-26-2006, 07:37 PM
  3. Sorry..newb mail question
    By nolbishop in forum World of Warcraft General
    Replies: 2
    Last Post: 06-07-2006, 07:21 PM
  4. Question..
    By janzi9 in forum Community Chat
    Replies: 3
    Last Post: 04-02-2006, 10:20 AM
  5. A GALB question
    By bassman in forum World of Warcraft General
    Replies: 4
    Last Post: 03-28-2006, 09:49 AM
All times are GMT -5. The time now is 02:22 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search