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

Where can I read more about #class?

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
tlund



Joined: 27 Jun 2014
Posts: 17

PostPosted: Tue Jul 01, 2014 4:27 pm    Post subject: Where can I read more about #class? Reply with quote

I have been away from tt++ since around 1.64 and this #class concept is new to me. I am trying to find a text that explains the whole idea behind it, but I cant seem to find anything Sad

I understand the idea about quickly reading in a bunch of variables, actions and aliases and then being able to wipe them out, as a group - awesome, but I am unsure how I am supposed to use them.

I normally start my game by doing "tt++ SomeChar". The script will set a few variables, like the character name and the password and then it will #read in 5+ different files.

Since there doesn't seem to be a default class, should I create one (and what should I call it?!) from this file?

I noticed that after I used #class blah read from a script to pull in some data, I could not simply use /read to reload a script from disk after I edited it...
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Tue Jul 01, 2014 5:14 pm    Post subject: Reply with quote

The online manual might help.

http://tintin.sourceforge.net/manual/class.php
Back to top
View user's profile Send private message Send e-mail
tlund



Joined: 27 Jun 2014
Posts: 17

PostPosted: Wed Jul 02, 2014 1:26 am    Post subject: Reply with quote

Scandum wrote:
The online manual might help.
No, that only has the same as #help in the client. It shows, in brief, what commands are available and what they do - but it does not explain HOW to use it.

For example, if I don't use any classes and #read a file that contains an action that is already defined, that action is replaced.

If I try to #read the same file, but now wrapped in a #class open statement, that action is not loaded into the class.

I am looking for some documentation that explains how this works and why. HOW am I supposed to work with #class?
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Wed Jul 02, 2014 6:36 am    Post subject: Reply with quote

You open a class and every new trigger and variable that is created is added to it.

If you redefine an action or variable #class is indeed not taken into account.

You can get rid of a triggers belonging to a class using #class kill. It's fairly straight forward.
Back to top
View user's profile Send private message Send e-mail
tlund



Joined: 27 Jun 2014
Posts: 17

PostPosted: Wed Jul 02, 2014 7:03 am    Post subject: Reply with quote

Expected behaviour:
Code:
#class test open
#CLASS {test} HAS BEEN OPENED.

#action test test1
#OK. {test} NOW TRIGGERS {test1} @ {5}.

#class new open
#CLASS {new} HAS BEEN OPENED.

#action test test2
#OK. {test} NOW TRIGGERS {test2} @ {5}.

#action
#############################################
#ACTION {test}={test2} @ {5}


Unexpected behaviour (for me):
Code:
#system echo '#action test test3' > foo.tt
#OK: EXECUTING 'echo '#action test test3' > foo.tt'

#class foo read foo.tt
#CLASS {foo} HAS BEEN OPENED.
#CLASS {foo} HAS BEEN CLOSED.

The "test" action is ignored?

and if "test" is not defined, it works:
Code:
#kill
#KILL - ALL LISTS CLEARED.

#class foo read foo.tt
#CLASS {foo} HAS BEEN OPENED.
#OK:   1 ACTION LOADED.
#OK:   1 CONFIG LOADED.
#CLASS {foo} HAS BEEN CLOSED.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Wed Jul 02, 2014 4:42 pm    Post subject: Reply with quote

Many people use scripts that change variables, actions, and aliases on the fly. So only new triggers are added to the class.
Back to top
View user's profile Send private message Send e-mail
tlund



Joined: 27 Jun 2014
Posts: 17

PostPosted: Thu Jul 03, 2014 6:12 am    Post subject: Reply with quote

Any suggestions for how to temporary override an action?

What I used to do was I had my default action in the file I loaded at start up. To temporarily override I loaded a new file on top of that with #load.

To revert back to the original, I #zap and re-start
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Thu Jul 03, 2014 6:44 am    Post subject: Reply with quote

If #zap and re-start works I'd stick with that.
Back to top
View user's profile Send private message Send e-mail
nya



Joined: 25 Jun 2012
Posts: 39

PostPosted: Fri Jul 04, 2014 6:03 am    Post subject: Reply with quote

You could also create a temporary action with a functionally equivalent yet technically different regular expression, and give it a higher priority, eg:

For the normal action:
Code:
#action {test} {#echo {do normal stuff}}


Then later on for the temporary action:
Code:
#class {temp} {open}
#action {{test}} {#echo {do special stuff} {4}
#class {temp} {close}


And then to go back to the normal action:
Code:
#class {temp} {kill}
Back to top
View user's profile Send private message
tlund



Joined: 27 Jun 2014
Posts: 17

PostPosted: Fri Jul 04, 2014 7:19 am    Post subject: Reply with quote

Yeah, this was more or less my solution for actions, but I want to temporarily replace aliases as well.

so i made a hack like this:

Code:
#alias test {test.normal}
#alias test.normal {say normal}


and then in my file I load:
Code:

#class special open
#alias test.special {say special}
#unalias test
#alias test test.special
#class special close


The problem is how to revert to calling the test.normal alias after i #class special kill.
Back to top
View user's profile Send private message
nya



Joined: 25 Jun 2012
Posts: 39

PostPosted: Fri Jul 04, 2014 7:45 am    Post subject: Reply with quote

Could just use a variable in that case, eg.

Code:
#alias {test} {$test}
#alias {test.normal} {say normal}
#alias {test.special} {say special}


Then

Code:
#var {test} {test.normal}


or

Code:
#var {test} {test.special}


That's true of actions too though.
Back to top
View user's profile Send private message
tlund



Joined: 27 Jun 2014
Posts: 17

PostPosted: Fri Jul 04, 2014 7:57 am    Post subject: Reply with quote

ah! I did not think of doing #alias {test} {$test}, very smart! thanks!
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 -> General Discussion 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