Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - yankscally

#1
Your scripts / Character Selection Screen
January 07, 2018, 01:33:12 PM
I'm making the first game on solarus with 2 player co-op multiplay, but to begin with, and to learn Lua, I will start to code a character selection screen over the next few weeks.. I will post updates here.



something quite simple like this will do fine. only going to use 4 characters for now.

although I was going to use the 'tunic1, tunic2, tunic3' there is no tunic4, hopefully I can figure out what I need to do instead.

#2
Your scripts / Re: New rain script
January 07, 2018, 10:52:46 AM
Hi, I'm trying to impelement this into my project, but run into problems with putting it into my game manager, I'm still learning lua so the code I'm trying to put in game manager is this


-- Rain manager script.
-- Author: Diarandor (Solarus Team).
-- License: GPL v3-or-later.
-- Donations: solarus-games.org, diarandor at gmail dot com.

--[[   Instructions:
To add this script to your game, call from game_manager script:
    require("scripts/weather/rain_manager")
The functions here defined are:
    game:get_rain_mode()
    game:set_rain_mode(rain_mode)
    game:get_world_rain_mode(world)
    game:set_world_rain_mode(world, rain_mode)
Rain modes: "rain", "storm", nil (no rain).
--]]

-- This script requires the multi_event script and the teleporters meta:
require("scripts/multi_events")
local rain_manager = {}

local game_meta = sol.main.get_metatable("game")
local map_meta = sol.main.get_metatable("map")

--- ECT



in the instructions part, it doesnt say where to put it in game manager. I used to have a bit more lua knowledge last year after you guys showed me how to set up a P2 control and custom entity....
#4
Development / hero hurt duration
May 07, 2017, 11:21:32 PM
how do I make the duration of the hero hurt quicker? I want to have less time between enemy attacks but I can't seem to change that bit of code?
#5
paint.net, a trick I've picked up after trial and error is using the photoshop layering system with the sheets. When making a sheet its very tedious to get the sprites in the right place, but if you copy in one layer and change the opacity of the original you get some cue points where to place them, and when you are finished you can delete the first layer so you only have your sprites left.
#7
Development / Re: 2 Player
May 02, 2017, 11:28:26 PM
Quote from: Zefk on May 02, 2017, 11:03:05 PM
@Diarandor
Ah! I did not notice that tricky math variable.

@yankscally
No need for the math variable.

Your code worked, straight up. Thank you Zefk! A little bit of time writing that code for you would have taken me days to figure out, but I would have got there eventually. I'm from an music/art background so im no wizard but I do know the basics of code, I really appreciate the help! If you need some sounds for your game, I will happily supply them I'm working on some sound packs that are pretty neat, including a very nice sounding dialog menu, I could show you if you are interested!
#8
Development / Re: 2 Player
May 02, 2017, 04:17:02 PM
after fine tuning the code, trying to edit out mistakes I made and such, I now get these error messages, similar.
Error: In on_key_pressed: [string "entities/player_2.lua"]:57: attempt to index upvalue 'math' (a nil value)
Error: In on_key_pressed: [string "entities/player_2.lua"]:66: attempt to index global 'straight' (a nil value)


player 2 code so far
Code ( lua) Select
local entity = ...
local game = entity:get_game()
local map = entity:get_map()
local hero = map:get_hero()
local sprite
local math



---CREATE
function entity:on_created()
  sprite = entity:create_sprite("hero/tunic3"):set_animation("stopped")
  entity:set_can_traverse("hero", false)
  entity:get_direction(2)
end

--------------CONTROLS GO HERE
--- UP

function player_up()
local straight = sol.movement.create("straight")
straight:set_angle(math.pi / 2)
straight:start(entity)
end
menu = false
function sol.main:on_key_pressed(key)
  if key == "i" and menu == false then
    player_up()
    entity:get_sprite():set_animation("walking")
  else
    straight:stop()
    entity:get_sprite():set_animation("stopped")
  end
end

-- DOWN

function player_down()
local straight = sol.movement.create("straight")
straight:set_angle(3 * math.pi / 2)
straight:start(entity)
end
menu = false
function entity:on_key_pressed(key)
  if key == "k" and menu == false then
    player_down()
    entity:get_sprite():set_animation("walking")
  else
    straight:stop()
    entity:get_sprite():set_animation("stopped")
  end
end
--- Left

function player_left()
local straight = sol.movement.create("straight")
straight:set_angle(math.pi)
straight:start(entity)
end
menu = false
function sol.main:on_key_pressed(key)
  if key == "j" and menu == false then
    player_left()
    entity:get_sprite():set_animation("walking")
  else
    straight:stop()
    entity:get_sprite():set_animation("stopped")
  end
end

-- right

function player_right()
local straight = sol.movement.create("straight")
straight:set_angle(0)
straight:start(entity)
end
menu = false
function entity:on_key_pressed(key)
  if key == "l" and menu == false then
    player_right()
    entity:get_sprite():set_animation("walking")
  else
    straight:stop()
    entity:get_sprite():set_animation("stopped")
  end
end


--- on restart

function entity:on_restarted()
  movement:set_speed(48)
  movement:start(entity)
end

#9
Game art & music / Re: Plexa Heroine
May 02, 2017, 02:40:58 PM
I really like this, love the wings!
#10
Game art & music / Re: Original art
May 02, 2017, 02:29:05 PM
Quote from: Diarandor on May 02, 2017, 10:27:55 AM
Some of the cool features planned for soldiers with helmet:
-Allow their helmet to fall appart (and break) with certain probability if the enemy is hurt by the sword. A new head sprite will be shown in that case.
-Allow to steal their helmet with the hookshot. The hero could then throw it as a destructible to hurt enemies! This is still not posible since there is no function to start carrying a destructible, but will be possible in future versions of the engine, I guess.


hey! I have uploaded a video of your soldier as a playable character, check my project post..
http://forum.solarus-games.org/index.php/topic,961.0.html
#11
Development / Re: 2 Player
May 02, 2017, 01:28:16 PM
http://www.solarus-games.org/doc/latest/lua_api_movement.html

what about the code described here??
Quotemovement:get_direction4()

From the four main directions, returns the closest one to the current trajectory.

East is 0, North is 1, West is 2, South is 3. As the real trajectory does not necessarily follows one of the four main directions, it will be converted to the closest one.

If you use this movement to control a sprite (or a map entity that has a sprite), you can use this function to make the sprite face the direction of the movement.

Return value (number): The closest direction corresponding to the angle of this movement.
Example of use:

-- Example of code from an enemy script.

-- This function is called when the enemy should start or restart its movement.
function enemy:on_restarted()

  -- Create a movement that makes random straight trajectories.
  local movement = sol.movement.create("random")

  -- This function is called when the trajectory has changed.
  function movement:on_movement_changed()
    -- The angle of the movement has changed: update the sprite accordingly.
    local direction = movement:get_direction4()
    enemy:get_sprite():set_direction(direction)
  end

  movement:start(enemy)
end
#12
Development / Re: 2 Player
May 02, 2017, 01:13:09 PM
Code ( lua) Select
local entity = ...
local game = entity:get_game()
local map = entity:get_map()
local hero = map:get_hero()
local sprite
local movement


function entity:on_created()
  sprite = entity:create_sprite("hero/tunic3"):set_animation("stopped")
end

function player_up()
local straight = sol.movement.create("straight")
straight:set_angle(math.pi / 2)
straight:start(entity)

end

function player_down()
local straight = sol.movement.create("straight")
straight:set_angle(3 * math.pi / 2)
straight:start(entity)
end

function player_left()
local straight = sol.movement.create("straight")
straight:set_angle(math.pi)
straight:start(entity)
end

function player_right()
local straight = sol.movement.create("straight")
straight:set_angle(0)
straight:start(entity)
end

menu = false

function sol.main:on_key_pressed(key)
  if key == "i" and menu == false then
    player_up()
    entity:get_sprite():set_animation("walking")
  else
    straight:stop()
    entity:get_sprite():set_animation("stopped")
  end
end

function sol.main:on_key_pressed(key)
  if key == "j" and menu == false then
    player_left()
    entity:get_sprite():set_animation("walking")
  else
    straight:stop()
    entity:get_sprite():set_animation("stopped")
  end
end

function sol.main:on_key_pressed(key)
  if key == "l" and menu == false then
    player_right()
    entity:get_sprite():set_animation("walking")
  else
    straight:stop()
    entity:get_sprite():set_animation("stopped")
  end
end

function sol.main:on_key_pressed(key)
  if key == "k" and menu == false then
    player_down()
    entity:get_sprite():set_animation("walking")
  else
    straight:stop()
    entity:get_sprite():set_animation("stopped")
  end
end

function entity:on_restarted()


end



I got this so far thanks to Zefk, and it loads in a sprite, it does not move but pressing the left key makes the sprite "walking"
I get this error

Error: In on_key_pressed: [string "entities/player_2.lua"]:85: attempt to index global 'straight' (a nil value)


I thought it would be easier to use IJKL for the movement at the minute so I could test quickly with both hands
#13
Development / Re: 2 Player
May 02, 2017, 12:32:26 PM
Quote from: Diarandor on May 02, 2017, 10:08:54 AM
Note that french keyboards have some differences in the position of the letters. Since there are many french people in the Solarus community, I recommend to use as default keys some of the keys that have the same position for both english and french keyboards.
Quote from: Christopho on May 02, 2017, 10:32:01 AM
For networking multiplayer, you don't need to change the C++ code of the engine. You can use a Lua networking library like LuaSocket. It is true that there is no direct networking support in the Solarus API yet: you will have to do a lot of things manually, but no C++.
Quote from: Zefk on May 02, 2017, 06:20:05 AM
@yankscally

I am making an ally Ai project, so the functions I make might help you with making a second player. I will be start making functions (probably a custom entity metatable library) after the first release of the Solarus book project I am working on.

This would be unrelated to controlling your player 2 character. It is common to have "wasd" for keyboard related second players. Key 'd' is default for pausing the game...you will need to probably use "wqes".

w = up
s = down
a = left
d = right

w = up
s = down
q = left
e = right

Straight Movement:


Wow, this is really helpful info guys, thanks for the support, and so quickly too. I guess I can do a lot today with this. I will code a 1P/2P system for now and think about luasocket multiplayer when I understand it all a bit better. I'm using an enemy script for now but changing the code to controlling it with set keys seems like about x20 multiplied the lines of code I expected. I will probably use the custom entity.
#14
Game art & music / Re: Female Eldran Update
May 02, 2017, 12:16:49 PM
Quote from: Zefk on May 02, 2017, 05:03:55 AM
About:
The shaded version is done! Also, I updated the archives with a license.txt. The push animation did not work for the previous unshaded version 2, so this shaded version is now v2 instead of v3.

Downloads: (Login to download)

eldrina_v1 (unshaded)

eldrina_v2 (Shaded)

V2 Preview:



Next:
I will be working on another heroine named Plexa. Plexa is a sprite I made. She is on my profile image and is my business website's mascot. I need another hero for my ally Ai project because Eldran will be the third.

@Diarandor
QuoteWell, this Eldrina sprite was made 97% by Zefk and 3% by me. That must be said.

I was only able to get her done so quickly because you put a lot of time into Eldran and still are. I am pretty sure your work will inspire many more heroes.

@yankscally

Nice work on your hero sprite! I am glad this post has helped you.


The pleasure is all mine! I'm currently trying to code in a 1P/2P system. I'm using Link's tunic2 and tunic3 **edit-using an enemy script to code in the extra players (i think im doin it wrong lel) but I'd love to use the eldrina sprite for 2P, would help me learn how to implement sprites for extra players, and the sprite is awesome!!
#15
Game art & music / Re: Original art
May 02, 2017, 12:12:34 PM
Quote from: Diarandor on April 16, 2017, 01:24:09 AM
Let's go on-topic again: I made some new (original) soldier sprites!!!
These will be used for normal soldiers in the project "Children of Solarus". Testing video here:
https://youtu.be/WbGFNsvQwLs

I just now saw this!

nice addition with the feather on the helmet  :)