How do I make Trading

  • Here's the story. I have 4 items that i can trade at a shop. Each item has a fixed basic price (5, 10, 15, 20 as placeholders-you sell and buy stuff at the same price). On that price is added random number and that final number is the displayed one and the item's actual price.

    I've set up that item count goes up and down when you're buying/selling (i still need to set the limit so that you can't sell items that you don't have-could use some help on that too )

    The thing is, i can't for the life of me set things up so that when you buy/sell stuff, the final money value is added / substracted from your inventory. Finding out how to limit the trade so that you can't buy things you can't afford would be great too!

    Also, i have some questions about randomizing prices, so help with that would be great!

  • I've set up that item count goes up and down when you're buying/selling (i still need to set the limit so that you can't sell items that you don't have-could use some help on that too )

    If you store the amount of items the player is carrying in your player object as variables. (Item_1, Item_2, Item_3...etc) you can check against these to see whether the player have enough of them to sell. Simply but doing a Item_1 > 0.

    And you can do the same for the shop.

    [quote:3a80ffxz]The thing is, i can't for the life of me set things up so that when you buy/sell stuff, the final money value is added / substracted from your inventory. Finding out how to limit the trade so that you can't buy things you can't afford would be great too!

    This can be done the same way as above. In this case you just make a variable called "Player_money" and you add/subtract from this and again you can use this value to test vs the price of the item the player want to buy.

    Player_money >= Item_1_cost

    [quote:3a80ffxz]Also, i have some questions about randomizing prices, so help with that would be great!

    You can create random numbers using the following code:

    Random(Number)
    Random(10)   <- Will give you a random number between 0 and 10, including decimal numbers.
    
    Int(Random(Number))
    Int(Random(10))  <- Will give you a random integer between 0 and 10.
    
    Int(Random(Number) + 1)
    Int(Random(10) + 1)  <- Will give you a random integer between 1 and 10.
    [/code:3a80ffxz]
    So you can create random prices for your items like so:
    
    Item_1_cost = int(random(100) + 1)
    
    Will set the price to a random number between 1 and 100.
    
    But I might have misunderstood how your inventory works and that this is not what you meant.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • dl.dropboxusercontent.com/u/48563442/SimpleTrade.capx

    It says that it's made in Construct version 219 or newer and that i have 216. I've tried reinstalling it, still nothing

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)