Newbie with scripting problem.

Posted by NinjaKick on Fri 07 Mar 2003 07:17 AM — 6 posts, 23,921 views.

USA #0
I don't really know how to do any scripts, but could someone give me a hand?

I wanted to make it so when I identify an item, I could save certain things into a variable



Taken from a mud I play


Quote:


You wave your arms and utter the words, 'identify'.

/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~\
| | |
| -= cyanite leg mail =- |___/
| Type armor Weight is 1 |
| Value is 0 Level is 33 |
| It is mainly composed of ceramic. |
| Extra flags none. |
| Armor class is 8 pierce, 3 bash, |
| 7 slash, and 0 vs. magic. |
| Affects hit roll by 1. |
| Affects damage roll by 2. |
| |
/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/ |
| | |
\_____________________________________________________\__/




Is there a way to make it so I can have it look for affects on it, armor class, extra flags, material, level of item, item type, weight, value, and item name?

So I could do something like this for an alias

"say ident"

which would do something like this:



Quote:


sprintf( output, "%s type: %s, weight %d, value %d, level %d, material %s, extra %s, ac %d %d %d %d, affects: %s%s%s%s%s%s", item_name, type, weight, value, level, material, extras, ac_pierce, ac_bash, ac_slash, ac_magic, affect1 != NULL ? affect1:"", affect2 != NULL ? affect2:"", affect3 != NULL ? affect3:"", affect4 != NULL ? affect4:"", affect5 != NULL ? affect5:"", affect6 != NULL ? affect6:"");

do_say (output)




(Sorry for using the C language to do that, it is the only language I know)

Something to those sorts

Any help will be very appreciated.
Australia Forum Administrator #1
First I would make a trigger that matches on:


You wave your arms and utter the words, 'identify'.


I would use that trigger in a small script to enable a group of other triggers, see the function:


http://www.gammon.com.au/scripts/function.php?name=EnableTriggerGroup


Then I would make a batch of other triggers, putting them into the same group (eg. "ident" group), like this:


Type armor Weight is *
It is mainly composed of *.


Each one of those would call a small script that would capture the variable part (from the wildcard), using wildcards (1). See examples on this forum, or the supplied script file to see exactly how to do that.

When the last line appeared ("Affects damage roll by *." in your example) I would disable the trigger group, and then display all the values you found.
USA #2
Are ou wanting to save the info indefinately for a database of sorts? If so a standard variable script won't quite do what you're looking for, but if all you need is to highlight certain features on the object it would be fine.
USA #3
I want it to be able to save it. Then when I use the alias say... idensay it would output the stuff.

Or I could do something like identell ninjakick, and it would tell the character ninjakick the stats.

Or idenauction and it would auction all the information, basicly the info for the item would be saved until mushclient/that world is closed.(if possible)
USA #4
Problem with using a trigger to grab the info like this is that your variable will be reset every time you ID another item, unless you design some kind of database or array to store them in. Personally I'd just put together a database and set up a script to call obj data on command. Yes, I realize thats probably far more in depth than you wanted this project to get but doing a simple trigger, even with MC variable isn't going to do what you want unless you don't care if you can only store info for a single item.
USA #5
Yeah that is what I want. For it to only store one item at time.