RPG Maker universe
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le Deal du moment :
Cartes Pokémon : la prochaine extension ...
Voir le deal

Onidouza monnai

2 participants

Aller en bas

Onidouza monnai Empty Onidouza monnai

Message par Nicolas Lun 21 Fév - 23:30

Ce script de Onidouza permet d'avoir 3 monnai, comme nous avec les centimes et les €.
1Or = 10 argent, 1 argent = 10 cuivre , sachant que l'argent normal = cuivre

Code:
#=============================================
# ** Oni Monetary System
#---------------------------------------------
# Developed by Onidsouza
# Remember: MAX_GOLD always is 999.999
# Do not make a item that costs more than that
#==============================================

module OnidsouzaGold
 
  # ▼ OPTIONAL ▼
 
  #If not using icons
  GOLD = "G"
  SILVER = "S"
  BRONZE = "B"
 
  USE_ICON = true
 
  #L'ID des icones
  GOLD_ICON = 102
  SILVER_ICON = 98
  BRONZE_ICON = 97
 
end

class Game_Party < Game_Unit
 
  alias onidsouzagoldinit initialize
 
  def initialize
    onidsouzagoldinit
    @gold = [0, 0, 0]
  end
 
  def gold_array
    return @gold
  end
 
  def gold
    return total_gold
  end
 
  def gain_gold(n)
    @gold[2] += n
    update_gold
  end
 
  def lose_gold(n)
    gain_gold(-n)
  end
 
  def total_gold
    return (@gold[2] + (@gold[1]*100) + (@gold[0]*1000000))
  end
 
  def gold_to_silver
    return (@gold[2]/100) + (@gold[1]) + (@gold[0]*100)
  end
 
  def gold_to_gold
    return @gold[0] + (@gold[1]/100) + (@gold[2]/100000)
  end
 
  def update_gold
      times = @gold[2] / 100
      @gold[2] -= times * 100
      @gold[1] += times
      times = @gold[1] / 100
      @gold[1] -= times * 100
      @gold[0] += times
      if @gold[0] > 99
        @gold[0] = @gold[1] = @gold[2] = 99
      end
  end
   
  def make_gold_text
    return to_monetary_system(total_gold)
  end
   
end

class Window_Base < Window
 
  def draw_currency_value(value, x, y, width, gold = true)
    if not OnidsouzaGold::USE_ICON
      self.contents.font.color = normal_color
      self.contents.draw_text(x, y, width, WLH, to_monetary_system(value), 2)
    elsif OnidsouzaGold::USE_ICON and gold
      self.contents.font.color = normal_color
      xx = 20
      draw_icon(OnidsouzaGold::GOLD_ICON, x, y)
      self.contents.draw_text(x + 20, y, xx, WLH, $game_party.gold_array[0])
      x += 40
      draw_icon(OnidsouzaGold::SILVER_ICON, x, y)
      self.contents.draw_text(x + 20, y, xx, WLH, $game_party.gold_array[1])
      x += 40
      draw_icon(OnidsouzaGold::BRONZE_ICON, x, y)
      self.contents.draw_text(x + 20, y, xx, WLH, $game_party.gold_array[2])
    else
      arr = to_monetary_array(value)
      self.contents.font.color = normal_color
      xx = 20
      draw_icon(OnidsouzaGold::GOLD_ICON, x, y)
      self.contents.draw_text(x + 20, y, xx, WLH, arr[0])
      x += 40
      draw_icon(OnidsouzaGold::SILVER_ICON, x, y)
      self.contents.draw_text(x + 20, y, xx, WLH, arr[1])
      x += 40
      draw_icon(OnidsouzaGold::BRONZE_ICON, x, y)
      self.contents.draw_text(x + 20, y, xx, WLH, arr[2])
    end
  end
 
end


class Window_ShopBuy < Window_Selectable
 
  def draw_item(index)
    item = @data[index]
    number = $game_party.item_number(item)
    enabled = (item.price <= $game_party.total_gold and number < 99)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    if item != nil
      draw_icon(item.icon_index, rect.x, rect.y, enabled)
      self.contents.font.color = normal_color
      self.contents.font.color.alpha = enabled ? 255 : 128
      wid = contents.text_size(item.name).width
      self.contents.draw_text(rect.x + 24, rect.y, wid, WLH, item.name)
    end
    #rect.width -= 4
    price = to_monetary_system(item.price)
    self.contents.draw_text(rect.x + 24 + wid, rect.y, rect.width - 24 - wid, WLH, price, 2)
    # ▼ NEW
    #self.contents.draw_text(rect.x + 30, rect.y, rect.width - rect.x - 30, WLH, to_monetary_system(item.price), 2)
    #draw_currency_value(item.price, rect.x + rect.width + 8, rect.y, rect.width, false, )
  end
 
end

def to_monetary_system(integ)
  data = [0, 0, 0]
  data[2] = integ
  times = data[2] / 100
  data[2] -= times * 100
  data[1] += times
  times = data[1] / 100
  data[1] -= times * 100
  data[0] += times
  return "#{data[0]} #{OnidsouzaGold::GOLD} - #{data[1]} #{OnidsouzaGold::SILVER} - #{data[2]} #{OnidsouzaGold::BRONZE}"
end

def to_monetary_array(integ)
  data = [0, 0, 0]
  data[2] = integ
  times = data[2] / 100
  data[2] -= times * 100
  data[1] += times
  times = data[1] / 100
  data[1] -= times * 100
  data[0] += times
  return data
end

Nicolas
Admin
Admin

Messages : 113
Date d'inscription : 20/02/2011

https://rpguniverse.forumsactifs.com

Revenir en haut Aller en bas

Onidouza monnai Empty Re: Onidouza monnai

Message par Stoplight Mer 16 Nov - 11:37

C'est cool! mais je suis nul en script alors je demande, pour changer le nom des monnaies, par exemple si je veux que "gold" soit "jewels" je change tous les "gold" du script?
Stoplight
Stoplight
Invité
Invité

Messages : 3
Date d'inscription : 15/11/2011
Age : 25
Localisation : Evreux

Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum