Difference between pages "KoLmafia Guide: PvP (Beating Up People)" and "Append"
(Difference between pages)
Jump to navigation
Jump to search
imported>Bale |
imported>Cheesecookie m (Append returns the result, it does not change the original.) |
||
Line 1: | Line 1: | ||
− | + | {{ | |
+ | #vardefine:name|append}}{{ | ||
+ | #vardefine:return_type|buffer}}{{ | ||
− | + | FunctionPage| | |
+ | name={{#var:name}}| | ||
− | + | function1={{Function| | |
+ | name={{#var:name}}| | ||
+ | aggregate={{#var:aggregate}}| | ||
+ | return_type={{#var:return_type}}| | ||
+ | return_also={{#var:return_also}}| | ||
+ | parameter1={{Param|buffer|original}}| | ||
+ | parameter2={{Param|string|add}}| | ||
+ | p1desc={{Pspan|original}} is the buffer to add to| | ||
+ | p2desc={{Pspan|add}} is a string to add on| | ||
+ | }}| | ||
− | + | 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) | ||
+ | gear = append(gear, ", "); | ||
+ | gear = append(gear, to_string(equipped_item(slot))); | ||
+ | } | ||
− | + | print("I am wearing: "+ gear); | |
+ | </syntaxhighlight> | ||
+ | }}| | ||
− | + | see_also={{SeeAlso|append_tail}}| | |
+ | }} | ||
− | + | [[Category:String Handling Routines]] | |
− | |||
− | |||
− | |||
− | [[Category: |
Revision as of 22:32, 7 August 2018
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)
gear = append(gear, ", ");
gear = append(gear, to_string(equipped_item(slot)));
}
print("I am wearing: "+ gear);