I've got this script: http://rpgmaker.net/scripts/36/code/ (http://rpgmaker.net/scripts/36/code/)
It's made for shops where you can only buy or sell.
Just make an example game and try to make a shop where you only cat sell items.
Then, if you try to sell something, you'll get this message:
(http://oi48.tinypic.com/2eovcyf.jpg)
Quote from: Stray on September 02, 2012, 07:35:22 pm
I've got this script: http://rpgmaker.net/scripts/36/code/ (http://rpgmaker.net/scripts/36/code/)
It's made for shops where you can only buy or sell.
Just make an example game and try to make a shop where you only cat sell items.
Then, if you try to sell something, you'll get this message:
(http://oi48.tinypic.com/2eovcyf.jpg)
maybe you need replace 'vend_desc' to 'sell_discount' ($game_temp.sell_discount).
because there is no 'vend_desc' in class Game_Temp.
i'm not an expert in scripting but from a quick search, vend_desc is called as $game_temp.vend_desc, this means that vend_desc should be defined in $game_temp, based from the name it's gets a description of some sort but not sure what the "vend" part of the name is supposed to be (i'm a firm believer that all functions and non-temp variables should be named which describes what they do, eg, item_desc() would return an item's description)
but the problem is that a description is a string and it's being multiplied to @item.price and then the result is divided by 2, the result i'm guessing is to show the value of an item for when you sell it (thus why your getting an error) so obviously vend_desc is not return a description but a number, i'm assuming it's calling variable rather than a function since it doesn't have () at the end (but from a lot of script i've read this can't be ignored if you don't use arguments.......bad and lazy programming in my eyes)
now, your actual error i know all to well, it pop up when you attempt to call a function which doesn't exist, as i said above, vend_desc should be defined in $game_temp however the only this script does in class Game_Temp is this
class Game_Temp
attr_accessor :type # 2: Sell/1: Buy/0: Both
attr_accessor :buy_discount # Buy discount +- %
attr_accessor :sell_discount # Sell discount +- %
attr_accessor :shop_interface # Sell discount +- %
alias gt_init initialize
def initialize
gt_init
@type = 0
@shop_interface = :default
@buy_discount = 1
@sell_discount = 1
end
# Return shop interface
def act_shop_interface
Wep::Shop_interfaces[$game_temp.shop_interface]
end
end
there's no def vend_desc or attr_accessor :vend_desc to allow a call like $game_temp.vend_desc which means either 1 of 2 things
1) the person forgot to test this properly
2) the person forgot to say you need the SDK to use this script
i can give you a quick fix, see the code i pointed out, replace all of that with this code (search for class Game_Temp in this script, not in every script in the editor)
class Game_Temp
attr_accessor :type # 2: Sell/1: Buy/0: Both
attr_accessor :buy_discount # Buy discount +- %
attr_accessor :sell_discount # Sell discount +- %
attr_accessor :shop_interface # Sell discount +- %
attr_accessor :vend_desc
alias gt_init initialize
def initialize
gt_init
@type = 0
@shop_interface = :default
@buy_discount = 1
@sell_discount = 1
@vend_desc = 1
end
# Return shop interface
def act_shop_interface
Wep::Shop_interfaces[$game_temp.shop_interface]
end
end
this should stop the error but the script may not work to how it should
Quote from: Lukas on September 02, 2012, 07:56:45 pm
maybe you need replace 'vend_desc' to 'sell_discount' ($game_temp.sell_discount).
because there is no 'vend_desc' in class Game_Temp.
if what Lukas says is right and vend_desc is supposed to be sell_discount then instead of using $game_temp.sell_discount after you put in my code use $game_temp.vend_desc, this can be done easily by using the follow Script Call in an event
value = 5 #whatever you wanted sell_discount to be
$game_temp.sell_discount = value
$game_temp.vend_desc = value
this way the 2 will have the same value so if Lukas is right, it'll work properly
i would suggest that it's better to ask the person who scripted this cause they would have a better understanding of their own code
Thank you very, very much for your extremely fast and extensive help!
It's working!
If there are any further problems, I'll post it here again.
P.S.:
Selling items with discount works (thankyou), but buying items with discounts sure is not working quite correct.
Because even if I haven't enough money, I can buy something with the discount price.
descuento = (@item.price * $game_temp.vend_desc) / 2
descuento != english language,
maybe 'vend_desc' forgot to translatable
@item.price * $game_temp.vend_desc =
This is sure to find a discounted price.... maybe.. (http://r17.imgfast.net/users/1712/29/57/59/smiles/906951.gif)
Quote from: Lukas on September 02, 2012, 08:31:50 pm
descuento = (@item.price * $game_temp.vend_desc) / 2
descuento != english language,
maybe 'vend_desc' forgot to translatable
didn't notice that......strange how all the comments are a lot of varibale names are in english and this isn't......would mean that you are right and 'vend_desc' is 'sell_discount' (now i'm seeing why "desc" is being used, it's normally short for description)
since "descuento" would probably mean "discount" then that would mean "vend" is supposed to be "sell", in all fairness vend_desc should be changed to sell_disc but i assume that the reason why that didn't happen was because it would look confusing (i still don't get what the dam difference is between Disc and Disk, is it stupid English difference between the US and UK like with colour = color and mum = mom)
The script was obviously translated from Spanish. Whoever did it just missed a few things.
Quote from: Stray on September 02, 2012, 08:29:55 pm
P.S.:
Selling items with discount works (thankyou), but buying items with discounts sure is not working quite correct.
Because even if I haven't enough money, I can buy something with the discount price.
I didn't get it.
Quote from: Lukas on September 02, 2012, 09:16:21 pm
Quote from: Stray on September 02, 2012, 08:29:55 pm
P.S.:
Selling items with discount works (thankyou), but buying items with discounts sure is not working quite correct.
Because even if I haven't enough money, I can buy something with the discount price.
I didn't get it.
If I buy an item with a discount-price, I can buy it, even if I don't have enough money.
For example I have 20 coins, but I can buy something what costs 21 or higher.
I am quite confused about what I am supposed to replace in the script now...
Locate this line within the script (around 717)
# If item is invalid, or price is higher than money possessed
if @item == nil or @item.price > $game_party.shop_gold
And do this to it:
# If item is invalid, or price is higher than money possessed
if @item == nil or @item.price * $game_temp.buy_discount > $game_party.shop_gold
The author didn't really do a good job making sure his script was well translated and documented. For example, he claims you can use
$game_temp.gold_type in a script call, but there is no evidence of such a variable
gold_type. The script exists here on CP, but he hasn't logged on since May.
Now it's working. You're epic guys, thank you!
(http://cdn.memegenerator.net/instances/250x250/22846524.jpg)
New Prob:
If I use "sell", the items I have in my inventory aren't displayed. The sell category remains empty.
Is any switch occupied with a function in this script?