Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Kerrida
Newbie


Joined: 15 Nov 2004
Posts: 8

PostPosted: Mon Nov 15, 2004 3:10 am   

New to zMUD scripting, not sure where to begin
 
I play on Lusernia and have a script Idea I'm wanting to try to implement. However Im new to zMUD scripting and not sure where to begin on it.

Basically, I want it to scan the rooms everytime I enter them searching for a specific set of strings one of which is:

Struggling to grow, a young moonhart sapling pushes up from the ground.

It would then subtract the number of sapling from 5, giving the numebr elft to be planted.

It would also capture the room name:

Young pines.
The stars twinkle in the clear night sky. The pine trees are smaller and
younger here, clustered densely together.

It would then look in the database for that roomname, if found, compare the number of saplings hat need plating (in the example four need to be planted), if it has changed it updates and sends a message to another player.

If the Room doesnt exist, it adds it and messages said player.

Not asking for this tobe done for me, but would appreciate a bit of advice on how to get started (ALready got the database with no problems)
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Mon Nov 15, 2004 10:09 am   
 
There's a really good example in the finished scripts section.

http://forums.zuggsoft.com/phpbb/viewtopic.php?t=2164

Although it's geared towards propagating an equipment database it serves as a good example and shows how you can use a data record to update your db. You should be able to adapt
parts of this for your needs.

One way i might try to do this is :-

Create a class folder with all the triggers you need

I would use 3 triggers for this

Trigger for capturing the room name
Trigger for capturing number of saplings
Trigger to end script and transfer data to DB - If you have Exits shown in you room description you could use this.

#CLASS {SaplingCount|SapTriggers}
#TRIGGER {^Struggling to grow, a young moonhart sapling pushes up from the ground.} { #MATH count (@count+1)}
#TRIGGER {^Exits:*$} {#T- SapTriggers;storeData}
#CLASS 0

Make an alias for moving North, South, East, West.

#ALIAS mvnorth {#VAR newRecord %null;#VAR count 0;#t+ SapTriggers;#TEMP {^(*).} {#ADDKEY RoomName %trim(%1)};north}
etc

An Alias to store data

#ALIAS storeData {
#ADDKEY newRecord SaplingCount @count
Record=""
#IF !%null( %query(&RoomName=@newRecord.RoomName)) {
Record=%query((&RoomName=@newRecord.RoomName), All|<optional db name here>)
existing_sap_count=%db(@Record,SaplingCount)
//Do necessary maths here and send tell or chat with player//
#dbput @Record @newRecord
} {
#new all||<optional db name here> @newRecord
}

NB- None of this is tested BTW.

If you use the automapper you could configure this to run a script on entering each room.
You could have the script extract the room name for instance and use this in junction with the triggers
to capture the saplings.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net