1

I've got an controller code that says:

             $player->town_id = $input['town'];

         // this is located mostly in the config.lua

         $player->posx = '95';  // posx (X)
         $player->posy = '117';   // posy (Y)
         $player->posz = '7';  // posz (Z)

also here's the view (part of view that you need):

       <div class="control-group">
    {{ Form::label('town', 'Town:') }}
      <div class="controls">
{{ Form::select('town', array('1' => 'Main Town', '2' => 'Second Town'), '1'); }}
 </div>
</div>

You see, what I want is to set a config or something like an if statement. If the town is set to Main Town (which is equals to 1) then it will be like this:

         $player->posx = '95';  // posx (X)
         $player->posy = '117';   // posy (Y)
         $player->posz = '7';  // posz (Z)

else if the user selects Second Town (which is equals to 2), it'll use a different postion:

         $player->posx = '1000';  // posx (X)
         $player->posy = '1000';   // posy (Y)
         $player->posz = '7';  // posz (Z)

Is there an if statement or something that I could use in this case?

5
  • Where do you want to put that condition (if statement)? In the controller, the view or the select? Commented Aug 1, 2013 at 2:20
  • Where do you want to use it (if condition) ? Commented Aug 1, 2013 at 2:21
  • @Rubens Mariuzzo In the controller. Commented Aug 1, 2013 at 2:26
  • Are you submitting the form ? Commented Aug 1, 2013 at 2:27
  • Yeah, I have a submit button. Commented Aug 1, 2013 at 2:29

1 Answer 1

1

In your controller you can use

// Other code, assuming that $player already exists

if(Input::has('town')) {
    if(Input::get('town') == 1) {
        $player->posx = '95';
        $player->posy = '117';
        $player->posz = '7'; 
    }
    elseif(Input::get('town') == 2) {
        $player->posx = '1000';
        $player->posy = '1000';
        $player->posz = '7';
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.