Jump to content

Simulating Money in Wherigo


Geldhart

Recommended Posts

I'm looking for a simple way to simulate money in my Wherigo. I would need to be able to do the following.

 

1. Have an NPC give the player a set amount of money (Say you give the book to the merchant, he gives you a $100 reward)

2. Have the Player give an NPC a set amount of money (You buy a sword for $60. I don't need to track the money an NPC has)

3. Have the player choose how much money to give to an NPC (How much money do you want to give the beggar?)

4. The Inventory has the ability to show how much money the player has.

 

With #3, I would then like to be able to do something like this:

 

If the player gives less than $5, the beggar steals your sword

If the player gives between $6 and $9, the beggar says "Thank You"

If the player gives over $10, the beggar gives them a very useful clue

 

I'm using the Earwigo builder if that makes a difference.

Link to comment

I'm working on a game now that is similar. Here's my suggestion.

 

Create a purse or wallet item and put it in the player's inventory. Create two commands for the purse or wallet: Spend and Receive. For each command create an Input to ask how much. Then create a variable to keep track of the money in the wallet. You can add a third command to look in the the wallet to check how much money you have or you can change the Description of the wallet when you spend or receive to display how much money you have.

 

You don't have to have spend and receive commands. In my cartridge, written with the Urwigo build, I wrote a function to add or remove money from my wallet. I call it with a parameter of how much money to add or subtract whenever I need to exchange money. I'm not sure what capability exist in Earwigo for creating a function like this. You probably could write a Lua function that you can call from the Earwigo builder.

Link to comment

Here's a little more information to get you started. Some of my suggestions might require a little hand-coding, though, to get the desired effect.

 

I agree with the "wallet" item. You'll also want a variable to contain the player's balance of funds (i.e. how much money the player has). When the player's available funds change, you can adjust the wallet's description or name to update this. I like the latter option because the player doesn't have to click into the wallet item to discover his/her balance. You could also include this balance on every dialog: "What would you like to buy today? (You have $72.)" Personally, since I'm more into hand-coding my cartridges, I'd create a lua function that would take an amount (negative if the player is spending) and do everything I need: adjust the wallet's name/description and the variable that contains the player's balance of funds.

 

As far as spending is concerned, I don't recommend creating a command on the wallet item, per-se. Instead, the conversation with a merchant would list his/her wares and prices (including a "No, thanks" option) as part of a multiple choice input dialog. Choosing an item would show another multiple choice input dialog: the item's picture would be at the top and two answers at the bottom: "Buy ($60)" and "No, thanks".

 

For a beggar, you could have a multiple choice dialog: "Give Money" or "Ignore". The former choice would lead the player to a text-entry input dialog where the player could type in the amount s/he wishes to give (be sure to check for negatives and text), or you could have another multiple-choice input dialog with set amounts to give to the beggar. For "Ignore", you could have the beggar or player's conscience nagging the player.

 

I'd really like to provide you with a few examples of what I mentioned in a test cartridge, but I'll have to wait until I have the free time.

Link to comment

I had a little time during lunch. Please refer to the attached cartridge. You can purchase weapons. I'll work on items later.

 

You might think the item purchasing feature will be more of the same, but I plan to do some hand-coding for that one in an effort to come up with a more elegant solution.

 

See if you like it so far. I'll do more later. I might even try to make another real cartridge if I keep going. That'll be rare...

Shopping Demo.zip

Link to comment
I'm not sure what capability exist in Earwigo for creating a function like this. You probably could write a Lua function that you can call from the Earwigo builder.

Earwigo lets you write one or more lines of any Lua code you like at any point in any event handler. So you can do almost everything in the interactive, point-and-click editor, and then calculate the square root of the compound interest with a single statement. :) But you can also build functions - either with point-and-click, or in a Lua-syntax-friendly text area - and call them.

 

The point-and-click editor basically mirrors the Groundspeak Builder functionality (not least so that you can give up on Earwigo and go back to the Groundspeak Builder, though not many people do), except that you can also increment or decrement a variable by a number other than 1. :)

Link to comment

I'll post the completed hand-coded part of the cartridge either tomorrow night or Sunday night. Unfortunately, my weekend looks like this (October gets even more interesting, by the way):

Friday: Get off work at 5PM, 1h 15m commute, work a volleyball tournament 6:30-9:15, find one cache

Saturday: Log a few caches, find one cache. work a volleyball tournament 10AM-9PM, do nothing after that

Sunday: Church and either a photo shoot for a card or a caching event in Virginia, get back around 8PM, supper and prep for Monday

 

At the very least, I think I can get some cartridge work done the half hour I have between games.

 

So, anyway, what I'm trying to do with the cartridge code is to create something expandable and intelligent. You set up the "objects" beforehand, then call a PurchaseItem function and provide it the item's name, quantity, and the user's funds. The function will return a PurchaseResult object, containing a Boolean representing success or failure and the user's remaining funds. The PurchaseItem function will handle all the niceties: checking for available funds, verifying the shop has that number in inventory, moving the purchased item to the player's inventory, incrementing the item's quantity, adjusting the item's quantity in the description, and it'll even hide the item in the shop if no more are available. I'm also using a localization object similar to my Battleship cartridge to make translating everything easy.

 

On a side note, I really wish I had learned pseudo-object orientation in lua before I created Whack-A-Lackey. It would have made the code easier to understand and a little more clean. That was one of my reasons for creating Battleship: to provide source code better than Whack-A-Lackey, with little feature loss. Well, that's the process of learning.

Link to comment

I decided to finish the demo tonight than try to fit it in over the weekend.

 

Comments, additions, and refinements are welcome. Please feel free to modify this cartridge, post your changes, and mention what you changed. It would be neat to create code for an entire Wherigo storefront, then make a note of this thread in the Author Scripts thread.

 

Anyway, the weapon shop was made using Groundspeak's Builder and the item shop is hand-coded so you can see the difference. In the end, the user couldn't care less which method you choose as long as the cartridge works and isn't slow.

 

In addition to my helpful code comments, I added a few joke ones to keep things fun. The player also sees a joke comment when s/he tries to purchase arrows.

Shopping Demo.zip

Link to comment

THANK YOU!!!!!!

 

You saved my life... or at least you saved my Wherigo I was under the impression items could have quantity, looking at your demo made me realize I need to make the player believe it is the case when in fact it is a variable hidden under the item!

 

thank you thank you thank you!!!

 

Andouille

Link to comment

You're very welcome! It makes me happy to see my answers/demos help people out!

 

If you have any other problems or want to know if something is possible with Wherigo, please do ask it in the forum.

 

Actually, I do have a question, Based on your build (I imported you LUA in URWIGO to see exactly how it was build, I am doing the following:

 

I have one zone becoming active on start, the player has a backpack with zero meal at the start.

 

In my active zone I have an item called a cantine

 

From that item there is 2 command

 

Add one meal to your pack

Store one meal to the cantine

 

If you look at the add a meal to your pack it goes like this:

 

post-359905-017786000 1331601984_thumb.jpg

 

Now when I run this in the internal simulator:

 

if I open my cantine I see that I have 2 actions possible, I go to actions, I select take a meal (prendre un repas)I end up with this screen:

 

post-359905-085027800 1331602010_thumb.jpg

 

I just can't figure out why and how I can remove it. it appears on both commands and whatever if there is something wrong in the quantities, the message will be shown only after I click the (Cantine du campement de base" button which is in fact my item!

 

Any idea???

 

Thank you,

 

Andouille

 

EDIT: I FOUND!!! I had targeted my zone in my itemm's task instead of leaving the at NONE! thanks!

Edited by andouille
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...