Paying for a bill not in the shop
demonboy
19 Jan 2013, 19:49I've set up The Pixie's shop so I can buy items, but I want to be able to settle a bill for something completely different in another room (so another verb, 'pay', would be used). The main requirement is to add 1,000 units to the purse when the player finds some money (they start with 50), and then 'pay bill' in the reception, which is a different room to my shop. Right now it returns, 'what do you think this is, a shop?'
I assume I have to say 'when player has got the 1,000 in inventory, add 1,000 units to the purse', and then 'deduct 1,000 units from purse when bill and add a receipt to the inventory'.
I assume I have to say 'when player has got the 1,000 in inventory, add 1,000 units to the purse', and then 'deduct 1,000 units from purse when bill and add a receipt to the inventory'.
HegemonKhan
20 Jan 2013, 17:34you've no need for a library for doing this, so leave pixie's library as it is, lol.
as this is easy and non-complicated to do, hopefully.
------------
(Pixie's library is more for the difficulty of the transfer of the items and to their buying price, as this isn't something noobs can create or figure out on their own, mostly due to the use of the "if templates", if scripts, and shop boolean, for the coding to produce a shopping~shop function)
-------------
5.3 change: player -> game.pov
I'll do it though for 5.2 so you can follow along easier:
create your Receptionist object:
add verb for receptionist: Pay
and then give the verb this script (you can adjust it, as it's only an example, lol):
and to reward yourself with money:
(an example, as there's unlimited things you can do, as all you need is this scripting code line: player.money = player.money + "amount of money")
create object: demonboy_games_inc
add verb: work
add script:
-----------
you can also do the reverse, of~by adding "selling" to pixie's library, lol, but this would probably too complicated for you to do on your own, I think I could probably do it, I hope, but maybe I can't either.
if you want to do this, I can try to work on it for you, seeing if I can do it or not, hehe.
as this is easy and non-complicated to do, hopefully.
------------
(Pixie's library is more for the difficulty of the transfer of the items and to their buying price, as this isn't something noobs can create or figure out on their own, mostly due to the use of the "if templates", if scripts, and shop boolean, for the coding to produce a shopping~shop function)
-------------
5.3 change: player -> game.pov
I'll do it though for 5.2 so you can follow along easier:
create your Receptionist object:
add verb for receptionist: Pay
and then give the verb this script (you can adjust it, as it's only an example, lol):
<Script>
if (player.money >= 1000) {
player.money = player.money - 1000
msg ("You have paid the 17000000000000 USA debt off, finally after many milleniums of pooling all the other countries of the world money together!")
msg ("You have won the game, and helped out the USA, and thus the entire world too!")
finish
} else {
msg ("You don't have enough yet!")
}
</script>
and to reward yourself with money:
(an example, as there's unlimited things you can do, as all you need is this scripting code line: player.money = player.money + "amount of money")
create object: demonboy_games_inc
add verb: work
add script:
<script>
player.money = player.money + 100
msg ("You have created a blockbuster game, earning 100 money, for all your hard work")
</script>
-----------
you can also do the reverse, of~by adding "selling" to pixie's library, lol, but this would probably too complicated for you to do on your own, I think I could probably do it, I hope, but maybe I can't either.
if you want to do this, I can try to work on it for you, seeing if I can do it or not, hehe.
demonboy
21 Jan 2013, 02:43That's a really comprehensive reply, thanks HegemonKhan. I've managed the first part ok but I'm a noob to script and I'm using 5.3, so what I need to know is which expression do I use on the wallet? The wallet contains €1000 so I want to add that to the purse once the wallet is picked up (and I guess the player should lose the €1000 if they drop the wallet). Using the WYSIWYG I'm on the wallet object, under 'After taking the wallet' I want to apply that line player.money = player.money + 1000. Alternatively, what would the script look like and where would it be placed?
HegemonKhan
21 Jan 2013, 19:10demonboy wrote:That's a really comprehensive reply, thanks HegemonKhan. I've managed the first part ok but I'm a noob to script and I'm using 5.3, so what I need to know is which expression do I use on the wallet? The wallet contains €1000 so I want to add that to the purse once the wallet is picked up (and I guess the player should lose the €1000 if they drop the wallet). Using the WYSIWYG I'm on the wallet object, under 'After taking the wallet' I want to apply that line player.money = player.money + 1000. Alternatively, what would the script look like and where would it be placed?
-------------------------
5.3 changes:
http://quest5.net/wiki/Showing_a_map
http://quest5.net/wiki/Changing_the_player_object
http://quest5.net/wiki/Showhealth
http://quest5.net/wiki/Pov_alias
http://quest5.net/wiki/Pov_alt
http://quest5.net/wiki/Pov_article
http://quest5.net/wiki/Pov_gender
http://quest5.net/wiki/Pov_look
so, just replace "player" with "game.pov" or maybe you can do just "POV" too (I'm not sure myself)
5.2 = player <---> game.pov or POV = 5.3
but, this is mainly for if you want to have multiple characters to control by switching amongst them
------------
so you can just ignore this stuff (the above) entirely, by setting up your game like this:
Game -> Player (Tab) -> Player Object (its a drop down box) -> (select) Player (or whatever you named it) (this sets which player object, you are currently controlling and seeing through their eyes, which is known as the POV, game.pov)
Player (or whatever you named it) -> Options (Tab) -> Player (drop down box) -> [ Can be a player ] (just to make sure of this, and if you were to want to make more such player objects, this is how you do it, by this option here)
--------------
I'll be using 5.2, as let's ignore 5.3, for this, lol
I understand you're using Pixie's Shop Library, correct?
so your player (or whatever you named it) should have (add) the attribute:
name=money
type=integer (int)
amount set: 0
and then also for your player, (add) the status attribute: money (ignore the second box question that comes up about format, just click okay without typing anything in for it)
this acts as your "purse", so you have no need to actually make and carry an actual object called "purse".
also, this attribute "money" acts as your, well, money, lol, so you do not need to actually create an object to be your money (no need to create "gold coins" and "silver coins" objects, lol)
therefore, your "wallet" object doesn't need to be a container, as there's no gold coins or silver coins or paper money objects for it to hold within it.
(actually, you have no need for a wallet object, as your player's money attribute is your wallet/purse, however, I'll pretend you do, so you can see how it would work, lol, as instead of a wallet, this can be anything, as what is important is just having something to add the script to it, as it's the scripts that move your attribute money around, there's no physical transfer of money, unless you want such a system, which is much more complicated! As it involves the complex stuff of Pixie's libraries)
(you simply need to use the scripts, they're your rewards and fines, this is how money works in this game, via reward and fines scripts, so there's no actual physical objects moving around, only DATA amounts, from one object's money attribute to another object's money attribute)
but, so, instead, for the wallet all we have to do, is the same thing we did with the player, give the "wallet" its own "purse", by:
for your "wallet" object, give it the attribute:
name=money
type=integer (int)
amount set: 1000
---------
the two scripts you need to know~use:
object = player, receptionist, wallet, or demonboy_games_inc
"reward script" :
object.money = object.money + (X amount)
for example : demonboy_games_inc.money = demonboy_games_inc.money + 10
"fines script" :
object.money = object.money - (X amount)
for example : demonboy_games_inc.money = demonboy_games_inc.money - 10
and their applications:
if player.money >= 1000
for ex : ">=" means "greater than" and~or "equal to"
for ex : 1000 or 2000 (player's money) >= 1000 (the amount of money you need to pay off the bill)
then player.money = player.money - 1000 (you are paying off the bill)
for ex : 0 or 1000 (your new amount of money) = 1000 or 2000 (your initial amount of money) - 1000
and receptionist.money = receptionist.money + 1000
for ex : receptionist.money = 0 (receptionist's initial amount of money)
for ex : receptionist.money = 0 + 1000 (you're paying off the bill to receptionist, by adding the 1000 to receptionist)
for ex : receptionist.money = 1000 (receptionist's new amount of money)
"You paid off the bill to the receptionist, you are 1000 money less and the receptionist is 1000 money more"
else "You don't ahve enough to pay off the bill to the receptionist"
you take the wallet object, which has the attribute name "money" of its type "int" of "1000"
run script for taking object: player.money = player.money + 1000
run script for taking object: wallet.money = wallet.money - 1000
you drop the wallet object:
run script for droping object: player.money = player.money - 1000
run script for droping object: wallet.money = wallet.money + 1000
---------------------------------------------
applying the scripts:
--------
In GUI mode:
example: wallet object
Wallet (Object) -> Inventory (Tab) -> check/set ON "take" and "drop" (though drop is or should be already ON by default)
Wallet (Object) -> Inventory (Tab) -> you can use either the "take" and "drop" boxes (change to "Run Script") or the "take" and "drop" 's "after taking and droping, scripts" (Add new script)
as for the scripts to choose:
Variable -> Set Variable or Attribute
(the "Set Variable or Attribute" and the "If" scripts are used for A LOT of stuff, these are probably the two main scripts used of all the scripts for all coding!)
-> Take -> set variable player.money [Expression] = player.money + 1000
-> Take -> set variable wallet.money [Expression] = wallet.money - 1000
-> Drop -> set variable player.money [Expression] = player.money - 1000
-> Drop -> set variable wallet.money [Expression] = wallet.money + 1000
--------
In Code View mode:
(you can just do this in the GUI, and then hit the mode toggle button to see what it looks like in code)
(Also, notice how I'm *NOT* using pixie's shop library at all for any of this)
(and, I've had a bit fun with this, adding in some extra stuff, hehe)
(so copy and paste, and go ahead and play it, wink. even though I set it to 50%, I was caught like 5/6 times, but I did steal the money on my 6th try, so it does work)
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>7cc2a9d5-04d5-409f-b55a-1e824dc63972</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<pov type="object">player</pov>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<drop type="boolean">false</drop>
<money type="int">0</money>
<statusattributes type="stringdictionary">money = </statusattributes>
</object>
<object name="wallet">
<inherit name="editor_object" />
<take />
<money type="int">1000</money>
<ontake type="script">
player.money = player.money + 1000
wallet.money = wallet.money - 1000
</ontake>
<ondrop type="script">
player.money = player.money - 1000
wallet.money = wallet.money + 1000
</ondrop>
</object>
<object name="receptionist">
<inherit name="editor_object" />
<money type="int">1000</money>
<drop type="boolean">false</drop>
<pay type="script"><![CDATA[
msg ("If you don't got my 1000 money that you owe me, I'm going to kill you!")
if (player.money >= 1000) {
msg ("You pay off the bill to the receptionist.")
player.money = player.money - 1000
receptionist.money = receptionist.money + 1000
}
else {
msg ("I told you, now die!")
msg ("GAME OVER")
finish
}
]]></pay>
<steal type="script"><![CDATA[
if (receptionist.money >= 1000) {
if (RandomChance (50) = true) {
msg ("You steal more money from the receptionist!")
player.money = player.money + 1000
receptionist.money = receptionist.money - 1000
}
else {
msg ("You thief, I'm going to kill you! Now die!")
msg ("GAME OVER")
finish
}
}
else {
msg ("The receptionist has no money left to steal.")
}
]]></steal>
</object>
</object>
<verb>
<property>pay</property>
<pattern>pay</pattern>
<defaultexpression>"You can't pay " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>steal</property>
<pattern>steal</pattern>
<defaultexpression>"You can't steal " + object.article + "."</defaultexpression>
</verb>
</asl>
-------
as scripts in their "purest" form (by themselves, not attached to or within anything, this is what they would look like):
<script>
player.money = player.money + 1000
</script>
<script>
player.money = player.money - 1000
</script>
<script>
receptionist.money = receptionist.money + 1000
</script>
<script>
receptionist.money = receptionist.money - 1000
</script>
<script>
wallet.money = wallet.money + 1000
</script>
<script>
wallet.money = wallet.money - 1000
</script>
<script>
if (player.money >= 1000) {
}
</script>
<script>
if (receptionist.money >= 1000) {
}
</script>
<script>
RandomChance (50)
</script>
<script>
if (RandomChance (50) = true) {
}
</script>
<script>
if (RandomChance (50) = false) {
}
</script>
<script>
if (RandomChance (100) = true) {
}
</script>
<script>
if (RandomChance (0) = false) {
}
</script>
<script>
if (RandomChance (100) = false) {
}
</script>
<script>
if (RandomChance (0) = true) {
}
</script>
<script>
if (RandomChance (25) = true) {
}
</script>
<script>
if (RandomChance (75) = false) {
}
</script>
<script>
if (RandomChance (25) = false) {
}
</script>
<script>
if (RandomChance (75) = true) {
}
</script>
---------------
P.S.
just to restate the concept:
while you can actually move/transfer around physical objects, such as like gold coins for currency,
it is far easier to simply use the DATA of attributes, in adding to or subtracting from that data of attributes, to produce the same effect as if you actually moved the amount of DATA from one object's attribute to another object's attribute. But there's no actual transfer of the DATA from one object's attribute to another object's attribute, you add to one and minus to another.
you want to be doing this (or at least it is far easier to do, lol):
player.money = player.money +1000
wallet.money = wallet.money - 1000
instead of the more difficult way of:
wallet.money = wallet.money - 1000 -> now move this 1000 to -> 1000 + player.money = player.money
or in terms of physical objects:
wallet's inventory object of 2 Gold Coins = move 1 wallet's inventory object Gold Coin to = player's inventory object of 0 Gold Coins -> player's inventory of 0 object gold coins now being of 2 object Gold Coins
-------------
P.S.S.
if you're confused by any of this, or want to understand about the extra stuff I added, please ask away, and I'll help you with it!
demonboy
24 Jan 2013, 07:47Hey HegemonKhan, just wanted to say a massive 'thank you' for your reply. I'm tied up with other things right now so my Quest project is on the back-burner until next week. By then I'll be able to go through your response and hopefully implement it properly. Much appreciated.