Disable Bombs [In-Game Scripting]

#1
A problem has been noted by several people that there is no not-unreasonably heavy sphere in the game that does not explode. This In-Game Scripting script will disable all bombs in a machine, and as a bonus shows some things you can do that could be useful for future scripts. By no means does it preclude other scripts, and the simStart of it can be copied into the simStart of other another script in order to use their effects simultaneously, assuming that is not too long or Spaar has added a scrollbar to In-Game Scripting by then.

Code:
import('UnityEngine')

simStart = function ()
  blocknum = GameObject.Find('BlockCounter/BlockCounter'):GetComponent('TextMesh').text
  i = 0;  j = 0; blocknum = tonumber(blocknum)
  while true do
    k = GameObject.Find('bgeL'..i)
    if k then GameObject.Destroy(k:GetComponent('ExplodeOnCollide')); j=j+1  end
    k = GameObject.Find('bsg'..i)
    if k then GameObject.Destroy(k:GetComponent('ExplodeOnCollide')); j=j+1 end
    if (j == blocknum) then break end
    i=i+1
  end
end

frame = function ()
end
Note that this does not affect any save files; if you get rid of the script and then reload your creation, the affected bombs will explode as normal.

I realize that I am basically using the scripting mod to write other mods at this point, and that that is not the intended use of IGS, but I prefer this to trying to find my way around an IDE. Maybe I'll look into that "Reflexil" thing ITR mentioned...

EDIT: It has been brought to my attention by ITR that this may not work if you have their ModifyExplosion mod installed. The slightly longer, slightly hackier, very slightly laggier script below definitely should, though. Probably.

Code:
import('UnityEngine')
inelegantbuteffective = true

simStart = function ()
  inelegantbuteffective = true
end

frame = function ()
  if inelegantbuteffective then
    blocknum = GameObject.Find('BlockCounter/BlockCounter'):GetComponent('TextMesh').text
    i = 0;  j = 0; blocknum = tonumber(blocknum)
    while true do
      k = GameObject.Find('bgeL'..i)
      if k then GameObject.Destroy(k:GetComponent('ExplodeOnCollide')); j=j+1  end
      k = GameObject.Find('bsg'..i)
      if k then GameObject.Destroy(k:GetComponent('ExplodeOnCollide')); j=j+1 end
      if (j == blocknum) then break end
      i=i+1
    end
    inelegantbbuteffective = false
  end
end
I really should just learn Modloader...
 

spaar

Active Member
#2
Nice work. Thanks for mentioning the scrollbar, I hadn't even thought about that :D But it should be pretty easy to do.
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#3
Just to note, this probably doesn't work with the modify explosion mod (remote explosion), since it removes explode on touch completely, including the "explodey" function.

If you decide on creating a mod, you could use Spaar's mod-loader to first destroy the component, then replace it with a modified version.
 
#4
I don't understand what you mean by "won't work with"; disabled bombs don't exactly need timers. Do you mean that it will crash the game, or what?
EDIT: Nevermind, I gotcha. I will edit the post presently
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#5
Not sure if that changed anything :p

Not that you had to do anything, just thought I should mention it since some people wanted the ability to remove explode on touch with my mod, and I thought I should warn them
 
Top