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

Topics - zutokaza

#1
I am wondering how to get the hero in an item script.

I want to do this:

Code ( lua) Select
--slow the hero down
function item:on_map_changed(map)
  hero:set_walking_speed(30)
end


I tried:
Code ( lua) Select
local item = ...
local game = item:get_game()
local hero = game:get_hero()


and

Code ( lua) Select
local item = ...
local game = item:get_game()
local map = item:get_map()
local hero = map:get_entity("hero")


and

Code ( lua) Select
local item = ...
local game = item:get_game()
local map = item:get_map()
local hero = map:get_hero()
#2
Development / [Solved]Get all map entities?
June 01, 2017, 09:44:18 PM
Is it possible make a NPC target entities with a prefix?

Code ( lua) Select
target_movement:set_target(map:get_entities("bird_"))
#3
How would I do something like this?

Code ( lua) Select
function test(a = 5, b = "hey", c = true)
  if a == 5 then
    print("Letter A is",a)
  end
end

test()


I know it can be done like this:

Code ( lua) Select
function test(a, b, c)
a = 5
b = "hey"
c = true
  if a == 5 then
    print("Letter A is",a)
  end
end

test()
#4
I want to create a custom entity with script, but I am having trouble creating it. I want to create a new entity at the position of an already existing entity.

Code ( lua) Select
  map:create_custom_entity({
    name = "box",
    direction = 2,
    layer = 0,
    x = entity:get_position(),
    y = entity:get_position(),
    sprite = "entities/box",
    })
#5
Development / [Solved]Disable spin Attack?
April 12, 2017, 12:16:54 AM
is it possible to disable the spin attack?
#6
Development / [Solved]Movements with camera?
April 07, 2017, 04:44:24 AM
I was trying to move the camera, but how do I move an entity without a name? Is it possible to create a name for the camera?

Code ( lua) Select
local straight = sol.movement.create("straight")
straight:set_angle(3)
straight:start(camera)
#7
Development / (Solved)Table?
April 03, 2017, 03:23:56 AM
I have been trying to figure out the error with my table for the pixel movement.
Quotetrajectory (table): An array of all successive translations to make. Each translation should be an array of two integers (x and y).


Code ( lua) Select
local table1 = {244,270}
pixel:set_trajectory(table1)
pixel:start(gerf)


and I tried:

Code ( lua) Select
pixel:set_trajectory{244,270}
pixel:start(gerf)



[2150] Error: In on_started: [string "maps/Map_4.lua"]:83: bad argument #3 to set_trajectory (table expected, got number)

#8
I am having trouble with this because my npc is not making a circle movement. I want the NPC (gerf) to circle around a entity (chest1).

Code ( lua) Select
local circle = sol.movement.create("circle")
circle:set_center(chest1,248,357)
circle:start(gerf)

#9
Development / (Solved)Sword variants?
March 24, 2017, 11:54:20 PM
Can a sword have different variants? For example, variant 2 for a red sword graphic?

Code ( lua) Select
game:set_ability("sword", 2)
#10
Development / Key save error message
March 06, 2017, 05:12:58 AM
I made a key item. I require the key for opening the door, but I get this error message. The door entity never shows.

Code ( lua) Select
2140] Error: In create_door: bad argument #1 to ? (Bad field 'opening_condition' (equipment item 'key' is not saved))
#11
Development / Hit box size?
January 10, 2017, 01:26:15 AM
What is the size of the hit box?
#12
Development / (Solved)How do I overwrite array strings?
November 28, 2016, 06:44:30 AM
Basically the sol.surface font text is equal to test for displaying words test1,2,3,4, etc. I am trying to overwrite the first 0-7 tests.

Code ( lua) Select
local test = {}
local testing

test[0] = "test1"
test[1] = "test2"
test[2] = "test3"
test[3] = "test4"
test[4] = "test5"
test[5] = "test6"
test[6] = "test7"
test[7] = "test8"

for i = 0,7 do
     show_test[rep] = sol.text_surface.create({
      text = test[i],
    })
end

function sol.main:on_draw(screen)

--clear and overwrite
test = {}

if testing == true then
test[0] = "test_overwrite1"
test[1] = "test_overwrite2"
test[2] = "test_overwrite3"
test[3] = "test_overwrite4"
test[4] = "test_overwrite5"
test[5] = "test_overwrite6"
test[6] = "test_overwrite7"
test[7] = "test_overwrite8"
end

for i = 0,7 do
    show_text[i]:draw(screen,x_test_pos,y_test_pos[i])
  end
end

end
#13
Hello,

I want to print a string to a text file.

For example,

Code ( lua) Select
print("hello world")

txt file:
1 hello world
#14
Development / (Solved) For loop embedding question
November 10, 2016, 08:21:59 AM
Is it possible to do this in a shorter way?
Code ( lua) Select
for rep = 1, 15 do
--blah different coordinate calculations
for rep = 15, 30 do
   --blah different different coordinates calculations
  for rep = 30,45 do
   --blah different coordinates calculations
   for rep = etc....... do
    --blah different coordinates calculations
   end
  end
end
end


My first thought was to use arrays. Will this work? If yes, how would I have starter begin 0 and ender begin at 15?

Code ( lua) Select
for 1,15 do

it would end up being:
15,30
30,45
45,60
etc

Code ( lua) Select

local starter={}
local ender ={}

for rep 1,15 do
starter[rep] = 0
ender[rep] = 0
end

for reprep = 1,15 do
starter[reprep]=starter[reprep] +15
ending[reprep] = starter[reprep] +15
for rep = starter[reprep], ending[reprep] do
--blah different coordinates calculations arrays
end
end
#15
General discussion / Secret of Mana?
October 30, 2016, 12:38:03 PM
This is unrelated to Solarus. Has anyone got a gb(secret of mana currency) glitch in the game? I noticed it does not add up correctly and the same glitch happens during item purchase.
#16
Development / How do I do Mouse inputs?
October 19, 2016, 04:24:42 AM
I was wondering if I can have a simple script example for mouse input.
http://www.solarus-games.org/doc/latest/lua_api_input.html#lua_api_input_get_mouse_position

EX:
How would I do this?

Code ( lua) Select
local mouse_position = sol.input.get_mouse_position(96,128)

local pressed_right_mouse = sol.input.is_moutton_button_pressed("right")

if mouse_position and pressed_right_mouse == true then
  print("Pressed")
end
#17
local w = "W"
local h = "H"
local a = "A"
local t = "T"
local foo

foo = w .. h .. a .. t

print(foo)

I get "WHAT," but my issue is with order. What if I press a button called "t" and I want "t" to appear first?

"TWHA"

or other buttons

"TAHW"

Basically, how to have strings order appear by what button is pressed and have them equal the "foo" variable?
#18
I want to make my code shorter because I basically have 3 long scripts in one lua file and it is a bit crazy.

For example,

Code ( lua) Select


--mymodule.lua
local mymodule = {}
--variables

function mymodule.foo()

--solarus image function
blah blah
end

--solarus on_key_pressed function
blah blah
end

end

--map.lua

local mymodule = require "mymodule" -- Will it be out of scope if local?

--solarus on_key_pressed function
mymodule.foo()
end


return mymodule
#19
Is it possible to grab certain place values in a variable?

Example:

soda = 9478

punch = soda place[4]

print(punch)

9

Another example:

punch = soda place[3]

print(punch)

4

I would like to grab 9,4,7, and 8 place values from soda and assign them to variables.
#20
I was wondering if it was possible to fill the whole screen with dialog or at certain coordinates. I want to make a stat menu. Is it possible to pass the value of $v for more than one variables in one dialog? Would it be possible to show more than one dialogs at once and have them vanish at the same time?

example:

ATK: 20
DEF: 40
SP.ATK: 30
SP.DEF: 100
Speed: 60