Difference between revisions of "Append"
Jump to navigation
Jump to search
imported>StDoodle m |
imported>Bale |
||
Line 20: | Line 20: | ||
function_description=Returns a buffer containing {{pspan|original}} with {{pspan|add}} tacked on to the end.| | function_description=Returns a buffer containing {{pspan|original}} with {{pspan|add}} tacked on to the end.| | ||
− | + | code1={{CodeSample| | |
+ | title=Code Sample| | ||
+ | description=Print a list of all items currently equipped.| | ||
+ | code= | ||
+ | <syntaxhighlight> | ||
+ | buffer gear; | ||
+ | |||
+ | foreach slot in $slots[] | ||
+ | if(equipped_item(slot) != $item[none]) { | ||
+ | if(length(gear) != 0) | ||
+ | append(gear, ", "); | ||
+ | append(gear, to_string(equipped_item(slot))); | ||
+ | } | ||
+ | |||
+ | print("I am wearing: "+ gear); | ||
+ | </syntaxhighlight> | ||
+ | }}| | ||
see_also={{SeeAlso|append_tail}}| | see_also={{SeeAlso|append_tail}}| | ||
}} | }} |
Revision as of 09:04, 10 March 2010
Function Syntax
buffer append(buffer original ,string add )
- original is the buffer to add to
- add is a string to add on
Returns a buffer containing original with add tacked on to the end.
Code Sample
Print a list of all items currently equipped.
buffer gear;
foreach slot in $slots[]
if(equipped_item(slot) != $item[none]) {
if(length(gear) != 0)
append(gear, ", ");
append(gear, to_string(equipped_item(slot)));
}
print("I am wearing: "+ gear);
See Also