lsc_shop.lsc
snippets · 2.1 KB · 2010-03-30
lsc_shop.lsc: sample LSC script for a shop (not inspected).
Download « Back to the snippets list
% a simple lsc shop sample program
%-----------------------------------
% |
% players' |
% requests | what would you do?
% |
/list {
(square) eq {
(yes, master, let me see...) say
} {
(Oh, let me see... ) say
} ifelse
show_goods
end
} def
/myvalue {
/item exch def
/name exch def
% evaluate pushes the estimated value onto stack
% it may fluctuate....
item evaluate
3 mul 4 div dup set_desired_buy_price
} def
/value {
% call myvalue which has been defined above
myvalue
% convert the result into comprehensible string
convert_amount_str
(I'd pay ) exch add say
end
} def
/sell {
/item exch def
/name exch def
buy_price
dup gt 1000 {
(I can't give you that much.) say
pop 1000
} if
buy_it
0 eq {
(thankyou.) say
} {
(too bad.) say
} ifelse
end
} def
/myask {
/item exch def
/name exch def
item cost
3 mul 2 div
dup 0 eq {
pop 1
} if
dup set_desired_sell_price
} def
/ask {
myask
dup
convert_amount_str
(I'd sell at ) exch add say
end
} def
/buy {
/item exch def
/name exch def
sell_price
sell_it
0 eq {
(thankyou.) say
} {
(too bad.) say
} ifelse
end
} def