TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

How to Use Lua Functions

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
new_to_tin_tin



Joined: 05 Jan 2011
Posts: 36

PostPosted: Wed May 24, 2017 6:21 pm    Post subject: How to Use Lua Functions Reply with quote

I have a Lua function that takes two string arguments and then returns a number.

I'm trying to call it from Tintin, but can't figure out how to get it to work. Ideally I'd be able to pass two tintin variables to it and get the return value into another tintin variable.

Any clue how to do this?

I tried this page:
http://tintin.sourceforge.net/scripts/lua.php

But I can't even get the example to run, I don't use the "gts" session, but another one, but couldn't get it work on either sessions....By not work I mean, I didn't get any display OR error messages when I load the commands in a script file using #read, or by typing manually #lua pi("gts") with both session names.
Back to top
View user's profile Send private message
new_to_tin_tin



Joined: 05 Jan 2011
Posts: 36

PostPosted: Wed May 24, 2017 9:14 pm    Post subject: Reply with quote

Not sure if there is an EASIER way to do this, but I figured out A way using #script.

From this page:
https://stackoverflow.com/questions/30426650/how-to-pass-aruments-to-a-lua-function-from-command-line

I made a Lua file testlua that was:
Code:
m = {}

print("before function")
function m.calc(n)
    print("in function")
    print(10*n)
end

m[arg[1]](arg[2])


I then used this inside Tintin:
Code:
#script {tester} {lua /home/myuser/tt_scripts/testlua.lua calc 10}


Which stores the results in a tintin variable in a list format:
Code:
#VARIABLE {tester}={{1}{before function}{2}{in function}{3}{100}}

Oh and I got a Permission denied error until I did:
Code:
chmod u+x testlua.lua
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group