Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

My script doesnt work and i dont know why..

I was trying to creat admin commands script using Switches and the switches doesnt change from Off to On when i do this :

if Input_trigger?(Input::P)
$game_switches [1501] = true
end

it was supports to be a script for NP+ 2.0 on my game (I just need the Global Switches and it will work)...

Here is the script please help me out..

Code:
#===============================================================================
# ** Admin_Commands
#-------------------------------------------------------------------------------
# Version 1.0 by kRECKER (Kick all and Summon monster commands)
#-------------------------------------------------------------------------------
# Admin_Commands script let you do simple admin commands as Summon Monsters,
# kick \ Kick All and start \ stop Special Events.
# Requides : SDK Script and Global Switches (starting from 1500)
#-------------------------------------------------------------------------------
SDK.log("Admin Commands", "kRECKER", 1.0, "16.4.07")
#==============================================================================

if SDK.state("Admin Commands") == true

class Admin_Commands
  
  def Call_Commands
  
  if Input_trigger?(Input::P) #kick all
    $game_switches [1501] = true
  end
  
  if Input_trigger?(Input::O) #after all kicked click "O"
    $game_switches [1501] = false
  end
  
  if Input_trigger?(Input::I) #Summon Night
    $game_switches [1502] = true
  end
  
  if Input_trigger?(Input::U) #Stop Night
    $game_switches [1502] = false
  end
  
  if Input_trigger?(Input::Y) #Summon Monster
    $game_switches [1503] = true
  end
  
  if Input_trigger?(Input::T) #Make the monster go away
    $game_switches [1503] = false
  end
  
  if Input_trugger?(Input::R)
    $game_switches [51] = true #Kick
  end
  
  if Input_trigger?(Input::E)
    $game_switches [51] = false #after 2 seconds use (if you used kick)
  end
end
end
end

Thanks alot to the one that will help me..
 
I found 2 errors:
1. The method is Input.trigger?.
2. You need an external script to use keys like E and U.

also, don't use this $game_switches [1], use this instead: $game_switches[1].
 
jbrist;192267 said:
No idea if this is the problem, But perhaps you need a Keyboard Input Script for this to work ?

Of course he has one, he is using NP+

Also this probably doesn't matter now, but here:
Code:
  if Input_[COLOR=Red]trugger[/COLOR]?(Input::R)
    $game_switches [51] = true #Kick
  end

You spelt it with a U.
 
Trickster frowns at
Code:
def Call_Commands
(tip: don't name your methods starting with a capital letter you may confuse the ruby interpreter into thinking it is a constant instead of a method)

Also The code is never called you must call it in order for it to work so instead of a class use a method

next this is something that needs to be called on every frame since it is input stuff. A way to do this is to add it to the update method of any scene you need to

if it must run in all scenes however this will be a bit tougher If you need this instead I suggest aliasing the Input module's update method and then add your code there

next I would suggest that you not use in game switches for this, since if you used the above method what if the user presses one of those buttons in say Scene_Title you will get an undefined method error since $game_switches is not initialized to a value yet

edit also why are you still calling the SDK.state method you should be using the SDK 2 method enabled? O_o
 
/\ Because if he is using Netplay+ 1.x, it has SDK 1.5 (I think) as that is what was around at release. A new Netplay+ hasn't come out for a while but 2.0 is coming out v. soon hopefully, which will most likely have SDK 2.x.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top