Attempting to make a mining script.

EDIT:

Edited this to put my current script in

Spoiler
Code:
############# Mining Script by: Bloodmorphed##Here is the attributes you can have in the section.#:name, :regionid, :percent, :item, :quantity: :depleted, :depletedmes#############DEFAULT_MINE = 1ORES ={1 >={ :name >= "Iron",:regionid >= 63,:percent >= 100,:item >= 10,:quantity >= 1,:depleted >= 4,:depletedmes >= "This vein is depleted",}}module MINEmodule MINE_TILE##################################Mining Animation##Animation when mining, Standing is 1.#########MINE_FRAME = 2end # MINE_TILEend # MINEmodule MINEmodule REGEXPmodule TILESET   MINING = /<(?:MINING|mine tile):[ ]*(\d+(?:\s*,\s*\d+)*)>/i  end # TILSETend # REGEXPend # MINE #==============================================================================# ■ RPG::Map#==============================================================================class RPG::Map   #--------------------------------------------------------------------------  # public instance variables  #--------------------------------------------------------------------------  attr_accessor :mine   #--------------------------------------------------------------------------  # common cache: load_notetags_mrr  #--------------------------------------------------------------------------  def load_notetags_mrr    @mine = MINE::MINE_TILE::DEFAULT_MINE.clone       #---    self.note.split(/[\r\n]+/).each { |line|      case line      #---      when MINE::REGEXP::MAP::MINE_TILE        $1.scan(/\d+/).each { |num|        @mine.push(num.to_i) if num.to_i > 0 }      #---      end    } # self.note.split    #---  end end # RPG::Map#==============================================================================# ■ Game_Map#==============================================================================class Game_Map   #--------------------------------------------------------------------------  # alias method: setup  #--------------------------------------------------------------------------  alias game_map_setup_mrr setup  def setup(map_id)    game_map_setup_mrr(map_id)    @map.load_notetags_mrr  end   end # Game_Map #==============================================================================## ▼ End of File##==============================================================================
why not just use terrain tags or region ids instead of notetags?


anyway, following that, you need to save the tileid of mining tiles into the mining array... then on your game, whenever you use the mining command/button, you will check if the tileid is included in that array...


though I really suggest using terrain tags or regions ids for that... maybe regions since there are many of them...
I am doing it by terrain tags, I just haven't gotten to that point yet. Maybe region ID's actually as you can have multiple ones do certain things.

Also I would like to create options, such as:

😮re {1 = iron}

You know, something like that, or similar to vlues random equipment actually.
then you don't even really need that notetag... if you want each terrain tag or region to do a different thing, you can use probably constants for that + if then elses...

you'd do something like this:

Code:
module Blood  #Assuming terrain tags  IRON_TAG = 1  COAL_TAG = 2  #Item ids  IRON_ID = 10  COAL_ID = 11end
then you would add the command in the update processing of Scene_Map (discover it 🙂 )... then to determine if you can mine:

Code:
#assuming you mine in the spot of the player#also assuming 100% chance to obtain itemif $game_map.terrain_tag($game_player.x,$game_player.y) == BLOOD::IRON_TAG  $game_party.gain_item($data_items[BLOOD::IRON_ID],1)elsif $game_map.terrain_tag($game_player.x,$game_player.y) == BLOOD::COAL_TAG  $game_party.gain_item($data_items[BLOOD::COAL_ID],1)end
now if you want to mine in front, then you will need to get first the direction of the player...
Eh? I would still need it to know which tile is the actualy vein though, right? I mean I can have it like this...

😮re { 1 = iron

        region = 1 }

Something like that, and maybe have others come out as a percent? I'm not too sure what you mean by constant and if then statements.

EDIT:

I see in your post, it would have to be in front of the player. I'm still confused on how to actually do this by region...???
I edited the above post with sample codes... 🙂
Yeah see what you have is not quite what I'd like

Fir pushing V would swing, it would only make a sound AND recieve ore on a vein. oh and you can only swing while not moving.

Here is what I would like to happen:

ores

1. Iron

-region id = 1

-percent = 100 (or w/e)

2. Coal

-region id = 2

-percent = 100

3. Sapphire

-region id = 1,2

-percent = 10

Something like that.

perhaps I'm not quite ready to dabble into actually making something like this, lol.
I just posted those as EXAMPLE, as a starting point that you can check... especially since this is Learning section... 🙂


PS: it's actually pretty simple... you can do it... just try and try...
Even the way I would want to do it? Hmmm... Your far more experienced then I am so ofc it would be easy for you 😛
I know this can be technically done by events, but I'd rather not make an event for every single mining thing I want.
I am not sure what is difficult about using an event to represent a mining area. It seems to be a very manage-able solution.


I would not approach it the way you're going about. Just think about the issues you've already run into and whether you really want to go and edit other scripts just to force your solution to work.
yeah, it is quite easy... all you do is catch a key press, check tiles, check if an item will be obtained, done... you're just over thinking it... 🙂


but yeah, it's easily doable via events too... and I don't really see anything wrong with that either... though if you want so many of those per map, then the script becomes a better approach...


you can prototype it maybe using events first, then once you get a bit more understanding of scripting, switch to scripting...
OKay so I have been working on this a bit more, looking through scripts and how to do whatever. But I still am struggling on how to implement what I would like to do.

Spoiler
############# Mining Script by: Bloodmorphed##Here is the attributes you can have in the section.#:name, :regionid, 😛ercent, :item, :quantity: :depleted, :depletedmes#############DEFAULT_MINE = 1ORES ={1 >={ :name >= "Iron",:regionid >= 63,😛ercent >= 100,:item >= 10,:quantity >= 1,:depleted >= 4,:depletedmes >= "This vein is depleted",}}module MINEmodule MINE_TILE##################################Mining Animation##Animation when mining, Standing is 1.#########MINE_FRAME = 2end # MINE_TILEend # MINEmodule MINEmodule REGEXPmodule TILESET   MINING = /<(?:MINING|mine tile):[ ]*(\d+(?:\s*,\s*\d+)*)>/i  end # TILSETend # REGEXPend # MINE#==============================================================================# ■ RPG::Map#==============================================================================class RPG::Map   #--------------------------------------------------------------------------  # public instance variables  #--------------------------------------------------------------------------  attr_accessor :mine   #--------------------------------------------------------------------------  # common cache: load_notetags_mrr  #--------------------------------------------------------------------------  def load_notetags_mrr    @mine = MINE::MINE_TILE:😀EFAULT_MINE.clone       #---    self.note.split(/[\r\n]+/).each { |line|      case line      #---      when MINE::REGEXP::MAP::MINE_TILE        $1.scan(/\d+/).each { |num|        @mine.push(num.to_i) if num.to_i > 0 }      #---      end    } # self.note.split    #---  end end # RPG::Map#==============================================================================# ■ Game_Map#==============================================================================class Game_Map   #--------------------------------------------------------------------------  # alias method: setup  #--------------------------------------------------------------------------  alias game_map_setup_mrr setup  def setup(map_id)    game_map_setup_mrr(map_id)    @map.load_notetags_mrr  end   end # Game_Map#==============================================================================## ▼ End of File##==============================================================================
Also there are a few reasons I don't want this in events. Firstly, this will be a good learning experience, secondly this is a much easier way of going about it, rather then having to call common events and figure out a way to do each thing individually and compile it in one.
get rid of the clone on this line (it serves no purpose):

@mine = MINE::MINE_TILE:😀EFAULT_MINE.cloneand I thought it was => and not >=.

also, put: 

DEFAULT_MINE = 1ORES ={1 >={ :name >= "Iron",:regionid >= 63,😛ercent >= 100,:item >= 10,:quantity >= 1,:depleted >= 4,:depletedmes >= "This vein is depleted",}}into a module of some kind
Thank you for that, but it doesn't really answer my question.
@awesome,: >= is for greater than or equal to... hash set-up uses key => value
@Shana

Isn't OP declaring a hash variable with ORES as the variable name?
yeah, but he used >= instead of =>

Code:
ORES ={1 >={ :name >= "Iron",:regionid >= 63,:percent >= 100,:item >= 10,:quantity >= 1,:depleted >= 4,:depletedmes >= "This vein is depleted",}}
Well, alright. I just misinterpreted your previous post.
It was supposed to be => though. 
Exactly what I said

Original thread: https://forums.rpgmakerweb.com/threads/attempting-to-make-a-mining-script.22920/