Axe Software Forums
  Quest Developer Forum
  gold


Author Topic:   gold
0 Ste 0 posted 23-02-2003 20:15 GMT     
i need the players to start off with 200 gold. when they buy an item from a shop, i will need some gold to be taken, if they dont have enough, it will need to say "you do not have enough gold". im using QDK for this (is there a topic in the manual about this?)
MaDbRiT posted 24-02-2003 08:11 GMT          
Hi 0 ste 0

Yes there is - try looking under STATUS VARIABLES, they are intended for this kind of thing and there is a good example if I remember correctly.

Al

0 Ste 0 posted 24-02-2003 19:19 GMT          
lol, i got that far, all i need to know now is how to take gold away from people when they buy an item (im using QDK by the way, not coding in ASL).

and, i need to know how to make it so when they die, they return to The Local Pub and lose all their gold, and have to start again.

MaDbRiT posted 24-02-2003 20:36 GMT          
If you code it so that your player starts in 'The Pub' with no money, when he/she loses the game (i.e. when you invoke 'playerlose' - they will automatically be offered a "start again" option - and they'll start in "The Pub" - with no money...

So I don't see where there is a problem on that one!

To reduce the amount of 'gold' your player has when he buys something, you set the status variable exactly as if it were a regular numeric one. e.g.

set <money;%money%-20>

would reduce the amount of money by 20.

Al

MaDbRiT posted 24-02-2003 21:01 GMT          
Here's a very simple 'buying stuff' demo, made with QDK. I've used a 'custom player command' to do the work. You can see it by selecting the room, click "Edit Room", then select the "Misc" tab and click "Edit custom player commands". This is where I built the command that does the work.

quote:

' "Buying Demo"
' Created with QDK Pro 3.12

define game <Buying Demo>
asl-version <311>
start <Shop>
game author <MaDbRiT>
game version <1.0>
game copyright <� 2003 MaDbRiT>
game info <Buying things demo>
define variable <money>
type numeric
value <100>
display <$$! dollar*s*>
onchange if ( %money% <= 0 ) then playerlose
end define
end define

define synonyms
end define

define room <Shop>
prefix <The Hardware>
look <a small hardware shop.>
command <buy widget> {
set <money;%money%-50>
move <widget;inventory>
msg <You hand over a fifty, and take the widget.>
}

define object <widget>
look msg <it's a blue widget, priced at 50 dollars.>
prefix <a>
end define

end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define


Hope that helps.

Al

0 Ste 0 posted 24-02-2003 22:43 GMT          
slight problem. when the player has 0 gold, and he tries to buy another, is goes to minus, making it so the player has infinate gold, and can get infinate items.
0 Ste 0 posted 24-02-2003 23:20 GMT          
ive made it so that if he already has a long sword, he cant buy another. i trying to figure out how to make so that if he dont have a long sword he cant sell one lol.

im still trying to find out how to stop the player from buying stuff when he has 0 gold. i guess ill have to use conditions for every buying system lol.

0 Ste 0 posted 24-02-2003 23:45 GMT          
ok, after lots of fiddling i came up with it. for every buying system, i have to use this condition...

IF player has object "sword"
OR string 1 "money" is less than or equal too "0"

THEN msg "you cannot buy this"

ELSE "blah dee blah dee blah" lol

MaDbRiT posted 25-02-2003 07:29 GMT          
WHOAA!!

You are making this MUCH too difficult!

All you need is ONE 'buy' command, and to give every object you want it possible to buy at any time a 'price' property.

Then in your buy command you...

a: check the object has a price property (if it doesn't it isn't buy-able).
b: check it is available to the player
c: check the player doesn't already have it
d: check the player has enough money.

If all the conditions are O.K. then you give the player the object and remove the value of its 'price' property from the player's money. If it fails at any stage you print an appropriate message to the player telling him why. This way coding one buy command will deal with all objects that have a price - makes sense - yes?

By the same method, you can code one SELL command to deal with all the possible sell-able items, testing the price property again as a key and of course ensuring the player actually HAS the item he's trying to sell.

I was well aware that the demo didn't prevent the player buying more than he has money to afford, I wasn't trying to offer you a complete solution, only to point you in the right direction so that you could solve it yourself! :-)

Al

0 Ste 0 posted 25-02-2003 11:29 GMT          
and i did, just in a more....slightly of course kind of way lol.

thanks Al :)