RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Mode changing script [REQUEST]

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 88
<Mode change script>
<11/22/09>



Summary
First of all I'm sorry that I'm requesting when I have under ten posts here, I realize this is bound to get me a lot of flack. The problem is that my search-fu is either weak or I'm looking in all the wrong places for this. Also after trying to read the ruby guide, I realized that I am NOT cut out to be a scripter just yet.

I'm making a Rpg/adventure game, and I really need a script to do a disgustingly basic thing. When someone presses "1" it turns switch 1 to On, and turns switches 2 and 3 off. when someone presses "2" on the keyboard it does something similar and turns On switch 2 and turns off 1 and 3. I don't think I really need to go into more detail what pressing "3" does.

Also this is optional, since I can make it an event on all the maps, but I'd rather have it floating in the upper left corner on the screen at all times. If possible I'd like an image (hopefully an animated loop/sprite, but I'll take what I can get) that corresponds with the current mode selected. Touch/use mode is a hand, eye/look is an eye, and mouth/speak is a mouth.

Yes, I probably could do this some way with a auto-run/common event somehow, but I'm trying to hog as little memory as possible. Also using events limits me to using the a,b,c keys. Also Yes, I know I can do this with skills, but it's clunky and at the moment requires the player to bring up the main menu, select skills, select their character, and choose the skill. Considering it's a major factor in the gameplay I could see it becoming frustrating and fast.

Thank you so very, very much if anybody wants to help me up with this.

Features Desired
  • Press keys 1/2/3 to switch between global switches 01 (use), 02 (look), 03 (speak)
  • turning on one "mode" turns off the other two switches
  • Show in upper-left corner of the screen which mode is active

Mockups
An event that's dependent on the global switches (and indicator in the corner)








Games its been in
  • Common in adventure games Like Quest for glory, exc.



Did you search?
Yes

Where did you search?
  • On this site/the database
  • Google
  • Creation asylum

What did you search for?
  • "press button input switch script ruby" and then "rpg maker xp ruby coding basics"

*
Rep:
Level 87
Are you using any other scripts, or just the RTP?  I might take a shot at this later today, if someone else doesn't get in first.
Always remember you're unique.
Just like everybody else.

**
Rep: +0/-0Level 88
No additional scripts. While I'm looking around for a better menu system/status screen, so far the ones I've looked at seem to play well with other scripts.

Edit 11/27/09: Also I hate to be a nag, but are you still considering working on this? So far I've tried scripting it myself or looking at other scripts that modify the switches (and hoping to figure out just how the hell it works), but I haven't found any and my talent at scripting remains as terrible as ever.
« Last Edit: November 27, 2009, 09:52:54 AM by basilmemories »

**
Rep: +0/-0Level 90
I've never figured out how to use keys other than the one in the F1 menu of the game, so I'm not sure how you'd do that, but wouldn't it be simple to make an always on common event that captures a rarely used button like A (z) and have it cycle through the three modes.

Code: [Select]
num_modes = 3
if $game_variables[1] < num_modes
   $game_variables[1] += 1
else
   $game_variables[1] -= num_modes - 1
end

0 is the first mode this way so without setting the variable in events, say at the beginning of a new game, it is automatically in the default mode, I'd put look there.
My strength is that of ten men, for I am wired to the eyeballs on espresso!

*
Rep:
Level 87
I'm sorry - I didn't get notification that this topic had been updated until today (or maybe it's because you edited your post rather than adding a new one?)

I'm pretty flat out at the moment, so won't be able to look at it for a few weeks at least.


If you're keen to try it yourself, take a look at how the Gold window is displayed - I'd base it on that, making the background transparent and putting it in the top left corner.  It's controlled in Scene_Map and uses Window_Gold for the layout.  Do a search for Keyboard Script Cybersam - you won't need the whole thing (this script monitors for ALL keys, so you could remove all of those that you're not interested in).

If I WERE doing this, I'd start with those scripts and modify as needed.
Always remember you're unique.
Just like everybody else.

**
Rep: +0/-0Level 88
Zethzune: There are two problems with using it as a common event.

1. Like I mentioned, I'm trying to keep this game as lag-free as possible. Considering the events on the items/hotspots already have the potential to take up some major space, a constantly-running event would only make it worse.

2. While the cycling idea might be a good idea, the other problem is that with an event you're bound to specific keys. Just about all of the keys don't seem intuitive and using them makes it look pretty obvious that it's shoehorned in. Yeah, the player could get used to it, but it's also likely that they might not care and just ditch the game with the funky controls.

shaz: Sorry about that, I didn't want to get accused of double-posting when I'm so new. Also for some reason I thought an edit would send the same sort of notification as a new comment.

Personally I'd be fine with waiting a few weeks, it gives me time to focus on the art and writing and tweaking the systems already in place. I did look at the keyboard script, but it all looked greek to me. As of now this is the current abomination I'm trying out:

Code: [Select]
class Adventuregame_mode
  def update
   if Input.trigger?(input:e)
    $game_switches[001] = true
    $game_switches[002] = false
    $game_switches[003] = false
    end
   if Input.trigger?(input:r)
    $game_switches[001] = false
    $game_switches[002] = true
    $game_switches[003] = false
    end
   if Input.trigger?(input:t)
    $game_switches[001] = false
    $game_switches[002] = false
    $game_switches[003] = true
    end
  end
end

-Which All I've managed to do is get to NOT crash the game on startup, instead of it actually managing to work.
« Last Edit: January 11, 2010, 10:08:06 AM by basilmemories »

i'll see what i can do.

**
Rep: +0/-0Level 88
Awesome, thanks for taking a look at it. Just let me know if you can't for some reason.

sorry for letting you down but i can't do it.  ;9 ;9 ;9 ;9

**
Rep: +0/-0Level 88
It's all right. I've noticed that not too many requests get answered on here anyway. That is unless the answer is an already-existing script and someone just links the OP to it.

***
Rep:
Level 82
Weeeee!
With the script that you wrote, don't all you need to do is make an event with the trigger "switch 1"?


**
Rep: +0/-0Level 88
If you're suggesting I do it with events, I've already explained why I don't want to do that. If you asking if I can call the script from an auto-run event... well that's a similar problem, plus when I tried it out the script crashes.

***
Rep:
Level 82
Weeeee!
Maybe you could poke around other peoples scripts and see how they do it....

**
Rep: +0/-0Level 88
Maybe you could poke around other peoples scripts and see how they do it....

That's actually how I got to that point. The problem lies in that most initialize/"when button is pressed" aspects of the code is that they're nested inside a very complicated script, and often involving calls to/rendering scenes inside of scenes. to be honest if I had a script that did the following:

Code: [Select]
Always on (not requiring a parallel event or call script from an event)
 Check for activity on buttons X, X, and X.
  when X is pressed
    (insert code posted above)
  repeat process for x and x

I would be fine with using that and then muddling out how the hell to activate the switches. Like I said though, at the moment I can't find anything where I can clearly pick out that bit of code that's self-contained. When I got a look at quckstats (which uses both q and esc to trigger a part of the script, and without a call event/paralel event) I get this:

Code: [Select]
  def update
    # If B button was pressed 
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Map.new
      return
    end
    # If L button was pressed 
    if Input.trigger?(Input::L)
      # Switch to menu screen
      @quickstatus_window.active = false
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new 
      return
    end
    @quickstatus_window.update
  end
end

Looking at code does help someone figure out the inner workings of something (that's how I got better at css, after all), but it's hard to get to that point when the manual doesn't make much sense and people just keep saying "look at the code".