• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Tech's Oddities

Resource Tech's Oddities 2023-05-17

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
Well, since you can't find the "pbReceiveCoin" method, maybe it's because it doesn't exist.

As for where the player receives coins... I think this is the place?
In Minigame_SlotMachine, by the end of def pbMain:
1694414858959.png

This appears twice in Minigame_VoltorbFlip:
1694414833759.png

One appears in lines 370-374 and the other in lines 417-421.

I guess you'll have to make those additions.
In Minigame_SlotMachine lines 363-369:
Ruby:
Expand Collapse Copy
    old_coins = $player.coins
    $player.coins = @sprites["credit"].score  # Score = $player.coins + coins won
    if $player.coins > old_coins
      $stats.coins_won += $player.coins - old_coins
      $player.coins += $stats.coins_won * 1 if $bag.has?(:SLOTCHARM)  # Total coins = $player.coins + (coins won * increase)
    elsif $player.coins < old_coins
      $stats.coins_lost += old_coins - $player.coins
    end
In Minigame_VoltorbFlip lines 370-374 and/or lines 417-421:
Ruby:
Expand Collapse Copy
        old_coins = $player.coins
        @points = @points * 2 if $bag.has?(:SLOTCHARM)  # Charm increases coins won
        $player.coins += @points
        $stats.coins_won += $player.coins - old_coins if $player.coins > old_coins
        @points = 0
        pbUpdateCoins

EDIT: Added comments in the lines added so people understand better what they do. Change the number after the * to increase or decrease the amount of coins won with the charm.

Note: Since the slot machine doesn't add the coins won like in the voltorb flip, you have to add the extra coins won with the charm afterwards. Multiplying this by 2 would mean that with the charm, the player is winning 4 times the coins instead of the double the 2 would imply. Be aware of this detail if you are changing the amount of coins won with the charm in the slot machine.
 
Last edited:

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
Well, since you can't find the "pbReceiveCoin" method, maybe it's because it doesn't exist.

As for where the player receives coins... I think this is the place?
In Minigame_SlotMachine, by the end of def pbMain:
View attachment 21012
This appears twice in Minigame_VoltorbFlip:
View attachment 21011
One appears in lines 370-374 and the other in lines 417-421.

I guess you'll have to make those additions.
In Minigame_SlotMachine lines 363-369:
Ruby:
Expand Collapse Copy
    old_coins = $player.coins
    $player.coins = @sprites["credit"].score  # Score = $player.coins + coins won
    if $player.coins > old_coins
      $stats.coins_won += $player.coins - old_coins
      $player.coins += $stats.coins_won * 1 if $bag.has?(:SLOTCHARM)  # Total coins = $player.coins + (coins won * increase)
    elsif $player.coins < old_coins
      $stats.coins_lost += old_coins - $player.coins
    end
In Minigame_VoltorbFlip lines 370-374 and/or lines 417-421:
Ruby:
Expand Collapse Copy
        old_coins = $player.coins
        @points = @points * 2 if $bag.has?(:SLOTCHARM)  # Charm increases coins won
        $player.coins += @points
        $stats.coins_won += $player.coins - old_coins if $player.coins > old_coins
        @points = 0
        pbUpdateCoins

EDIT: Added comments in the lines added so people understand better what they do. Change the number after the * to increase or decrease the amount of coins won with the charm.

Note: Since the slot machine doesn't add the coins won like in the voltorb flip, you have to add the extra coins won with the charm afterwards. Multiplying this by 2 would mean that with the charm, the player is winning 4 times the coins instead of the double the 2 would imply. Be aware of this detail if you are changing the amount of coins won with the charm in the slot machine.
I did glance through there. Haven't really sat down to draw something up.
I was asking about pbReceiveCoin because the hidden items on the floor of the game corner call that to give coins, so it's got to be somewhere, right?
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
674
What hidden items? I'm looking at the Game Corner map and I don't see any hidden item.
 

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
What hidden items? I'm looking at the Game Corner map and I don't see any hidden item.
Ah, disregard. I need a vacation. I think it was something I put in that I was going to implement and never did. My apologies.

I added this in to mimic the coins scattered around like in the games:
def pbReceiveCoins(quantity)
$player.coins += quantity
pbMessage("You have received #{quantity} coins!")
end
 
Last edited:

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
I'm not sure if the slot machine modification will work properly. If you multiply the value of payout before it's displayed, not only does it display the proper "Won" amount on the slot machine, it also gives you the proper amount.

Ruby:
Expand Collapse Copy
        if combinations[i][0] == 0   # Left cherry
          if combinations[i][1] == 0   # Centre cherry as well
            payout += 4
          else
            payout += 2
          end
        else
          wonRow[i] = false
        end
      end
    end
#Multiples if has charm
    payout *= 3  if $bag.has?(:COINCHARM)
#End change
    @sprites["payout"].score = payout
    frame = 0
    if payout > 0 || @replay
      if bonus > 0
        pbMEPlay("Slots big win")
      else
        pbMEPlay("Slots win")
      end
In the image it's displaying:
puts #{payout}
#Multiples if has charm
payout *= 3 if $bag.has?(:COINCHARM)
#End change
@sprites["payout"].score = payout
puts #{payout}
for reference

Untitled.png
 

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
Quickly thrown together background for displaying the proper values if you have the COINCHARM (Or whatever you decide to call it), for those of you who are like me and are bothered by the wrong values being displayed.
Change this line:
Ruby:
Expand Collapse Copy
addBackgroundPlane(@sprites, "bg", "Slot Machine/bg", @viewport)
into this:

Ruby:
Expand Collapse Copy
bg_image = $bag.has?(:COINCHARM) ? "Slot Machine/bg1" : "Slot Machine/bg"
addBackgroundPlane(@sprites, "bg", bg_image, @viewport)
Obviously, if you change the path, or image name, you'll have to change it in the code.

bg1.png
 

wrigty12

Tester-Coder Hybrid
Member
Joined
Jul 24, 2022
Posts
547
It doesn't look like something like pbReceiveCoin exists, so I made one that should work. To make it also apply to coins given during Slots or other minigames, you'll want to look where $player.coins has values added to it and replace $player.coins += <value> or whatever it may look like with pbReceiveCoin(value,false). Just doing pbReceiveCoin(value) is for something like picking up coins on the ground and will show a message.

EDIT: :O When I was writing this, I didn't notice the second page from early this morning. So I didn't see any of them. Oh well, here's the function I made for my own game still xD

Ruby:
Expand Collapse Copy
def pbReceiveCoin(value, showMessage = true)
  return if value <= 0
  value *= 1.5 if $bag.has?(:COINCHARM)
  value = value.floor
  if !showMessage
    $player.coins += value
    $player.coins == Settings::MAX_COINS if $player.coins > Settings::MAX_COINS
  else
    if value > 1
      if !$bag.has?(:COINCASE)
        pbMessage(_INTL("It's some Coins, but you don't have anything to put them in!."))
      elsif $player.coins == Settings::MAX_COINS
        pbMessage(_INTL("It's some Coins, but your Coin Case is full!"))
      elsif $player.coins + value <= Settings::MAX_COINS
        $player.coins += value
        pbMessage(_INTL("You found {1} Coins!",value.to_s_formatted))
      else
        diff = Settings::MAX_COINS - $player.coins
        $player.coins += diff
        pbMessage(_INTL("You found {1} Coins, but you only had room for {2}!",value.to_s_formatted,diff.to_s_formatted))
      end 
    else
      if !$bag.has?(:COINCASE)
        pbMessage(_INTL("It's a Coin, but you don't have anything to put it in!."))
      elsif $player.coins == Settings::MAX_COINS
        pbMessage(_INTL("It's a Coin, but your Coin Case is full!"))
      else
        $player.coins += value
        pbMessage(_INTL("You found a Coin!"))
      end
    end
  end
end
 
Last edited:

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
It doesn't look like something like pbReceiveCoin exists, so I made one that should work. To make it also apply to coins given during Slots or other minigames, you'll want to look where $player.coins has values added to it and replace $player.coins += <value> or whatever it may look like with pbReceiveCoin(value,false). Just doing pbReceiveCoin(value) is for something like picking up coins on the ground and will show a message.

EDIT: :O When I was writing this, I didn't notice the second page from early this morning. So I didn't see any of them. Oh well, here's the function I made for my own game still xD

Ruby:
Expand Collapse Copy
def pbReceiveCoin(value, showMessage = true)
  return if value <= 0
  value *= 1.5 if $bag.has?(:COINCHARM)
  value = value.floor
  if !showMessage
    $player.coins += value
    $player.coins == Settings::MAX_COINS if $player.coins > Settings::MAX_COINS
  else
    if value > 1
      if !$bag.has?(:COINCASE)
        pbMessage(_INTL("It's some Coins, but you don't have anything to put them in!."))
      elsif $player.coins == Settings::MAX_COINS
        pbMessage(_INTL("It's some Coins, but your Coin Case is full!"))
      elsif $player.coins + value <= Settings::MAX_COINS
        $player.coins += value
        pbMessage(_INTL("You found {1} Coins!",value.to_s_formatted))
      else
        diff = Settings::MAX_COINS - $player.coins
        $player.coins += diff
        pbMessage(_INTL("You found {1} Coins, but you only had room for {2}!",value.to_s_formatted,diff.to_s_formatted))
      end
    else
      if !$bag.has?(:COINCASE)
        pbMessage(_INTL("It's a Coin, but you don't have anything to put it in!."))
      elsif $player.coins == Settings::MAX_COINS
        pbMessage(_INTL("It's a Coin, but your Coin Case is full!"))
      else
        $player.coins += value
        pbMessage(_INTL("You found a Coin!"))
      end
    end
  end
end
Lol. I might still add in all the extra stuff. I was just trying to get it into the game. I've been jumping between 5 different things to take breaks between each of them.
 

drdoom76

Cooltrainer
Member
Joined
Aug 1, 2023
Posts
212
We need a charm discussion page or something. I've got a few of them, and I want to add a ton more. 😅
 
Back
Top