intfiction.org

The Interactive Fiction Community Forum
It is currently Mon Nov 12, 2018 4:08 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 12:36 am 
Offline

Joined: Wed Sep 26, 2018 10:10 am
Posts: 12
Ouch... Because the machines are the only way I know how to make multiple copies of potions. Everything else just gives me one item. No matter how many times I get the same item. So I'd love to buy from both. Though, I could have the vendors set up machines! I just might do that. Yeah, that's probably the best action. :) Okay, thanks a lot! You've been a great help!


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 12:41 am 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 298
Location: Michigan
Here's how it would look restricted to people only as sellers. (I also feel like the reporting bit is adding unnecessary complexity in this case, so I mashed it into the Carry out):

Code:
The store is a room.

Price is a kind of value. $10.99 specifies a price with parts dollars and cents (optional, preamble optional).

A person has a price called wealth. The wealth of the player is $15.

A thing has a price. The price of a thing is usually $5.00.

Buying it from is an action applying to two things. Understand "buy [something] from [someone]" as buying it from.

Vending machine is a transparent unopenable container in the store.

Percy is a man in the store. He carries the watch.

The price of the watch is $10.00.

A candy bar is an edible thing in the vending machine. The price of the candy bar is $5.50.
Some chips is an edible thing in the vending machine. The price of the chips is $10.00.
Some cookies is an edible thing in the vending machine. The price of the cookies is $20.00.

[Hooo Boy! Those are some expensive snacks!]

Carry out buying it from:
   if the wealth of the player is greater than the price of the noun:
      decrease the wealth of the player by the price;
      move the noun to the player;
      say "You bought [the noun].";
   else:
      say "You can't buy that! The price is [price of the noun] and you only have [wealth of the player]!";
      stop the action.

After taking inventory, say "You have [the wealth of the player]."

When play begins: now right hand status line is "Cash: [wealth of the player]".



Example output:

Code:
store
You can see Vending machine (in which are a candy bar, some chips and some cookies) and Percy here.

>buy candy bar from vending machine
You can only do that to something animate.

>buy the watch from percy
You bought the watch.

>i
You are carrying:
  a watch

You have $5.

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 12:55 am 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 298
Location: Michigan
CrazyFlitz wrote:
Ouch... Because the machines are the only way I know how to make multiple copies of potions. Everything else just gives me one item. No matter how many times I get the same item. So I'd love to buy from both. Though, I could have the vendors set up machines! I just might do that. Yeah, that's probably the best action. :) Okay, thanks a lot! You've been a great help!


Ha! Saw this after my last post. :)

You're welcome :)

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 11:36 am 
Offline
User avatar

Joined: Mon Jun 11, 2018 3:15 pm
Posts: 17
howtophil wrote:
Code:
Carry out buying it from:
   if the wealth of the player is greater than the price of the noun:
      decrease the wealth of the player by the price;
      move the noun to the player;
   else:
      say "You can't buy that! The price is [price of the noun] and you only have [wealth of the player]!";
      stop the action.


Hey howtophil (and others), I've been meaning to ask somebody about this. Your code above, seems to be equivalent to the code below. It seems like I have often seen this kind of checking done both ways. Am I missing a subtle difference? From a compiler perspective, is one approach preferred over the other? Is one approach better in some circumstances but not others? (When?) etc...

Code:
Check buying it from:
   if the wealth of the player less than the price of the noun:
      say "You can't buy that! The price is [price of the noun] and you only have [wealth of the player]!" instead.

Carry out buying it from:
   decrease the wealth of the player by the price of the noun;
   move the noun to the player.

_________________
~Esad


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 12:15 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 298
Location: Michigan
Well, they can help keep things separate conceptually. There's also a matter of which "comes first" during execution.

I tend to use "Check" only in cases with a large number of things that might stop the action, but I'm sure others use it every time.

http://inform7.com/learn/man/WI_12_9.html

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 12:19 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 298
Location: Michigan
I'd say it's "mostly stylistic" but I'm relatively new to inform 7, so Zarf or Hanon or someone might have a "more mature" view on the subject.

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 12:49 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 5796
My experienced view is that it's mostly stylistic. :)


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 12:56 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 298
Location: Michigan
zarf wrote:
My experienced view is that it's mostly stylistic. :)


Well, I'll take that as confirmation of my viewpoint :D

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Thu Sep 27, 2018 1:08 pm 
Offline
User avatar

Joined: Mon Jun 11, 2018 3:15 pm
Posts: 17
Alrighty then. I guess that settles it. Thank you.

_________________
~Esad


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Fri Sep 28, 2018 3:40 am 
Offline

Joined: Wed Sep 26, 2018 10:10 am
Posts: 12
I used your code and it worked perfectly, so thank you very much. The problem is, I can still only buy one of each item. Like, if I wanted more than one health potion, I can't do it. Tried combining the original code where it gave me multiple copies of the same item with this code, and it didn't work. Any suggestions?


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Majestic-12 [Bot] and 13 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group