[Mod] Carts [carts]

pagliaccio
Member
 
Posts: 65
Joined: Tue Jul 31, 2012 07:38

by pagliaccio » Thu Aug 02, 2012 18:28

we ask at developers some API for maintaining active
some object
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Thu Aug 02, 2012 23:51

[REQUEST] - locked cart / dropoff / pickup

CART - this cart only allows the owner to start/stop and pickup the cart
DROPOFF /PICKUP - instead of just throwing items on the ground, they are placed in a chest that only the player can access
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Aug 03, 2012 08:15

cornernote wrote:[REQUEST] - locked cart / dropoff / pickup

CART - this cart only allows the owner to start/stop and pickup the cart
DROPOFF /PICKUP - instead of just throwing items on the ground, they are placed in a chest that only the player can access

I will add something like this.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Aug 03, 2012 10:24

PilzAdam wrote:
cornernote wrote:[REQUEST] - locked cart / dropoff / pickup

CART - this cart only allows the owner to start/stop and pickup the cart
DROPOFF /PICKUP - instead of just throwing items on the ground, they are placed in a chest that only the player can access

I will add something like this.

Added in version 29.
 

User avatar
Ragnarok
Member
 
Posts: 213
Joined: Thu Mar 22, 2012 12:56

by Ragnarok » Fri Aug 03, 2012 10:51

What about with detecting of kinds of rails? Is it possible?
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Aug 03, 2012 10:56

Ragnarok wrote:What about with detecting of kinds of rails? Is it possible?

What do you mean?
 

User avatar
Ragnarok
Member
 
Posts: 213
Joined: Thu Mar 22, 2012 12:56

by Ragnarok » Fri Aug 03, 2012 11:20

I say about playing carts_straight_rails.ogg when cart is over straight rails, carts_curved_rails.ogg when cart is at the turn and carts_railway_crossover.ogg when cart cross the intersection.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Aug 03, 2012 11:26

Ragnarok wrote:I say about playing carts_straight_rails.ogg when cart is over straight rails, carts_curved_rails.ogg when cart is at the turn and carts_railway_crossover.ogg when cart cross the intersection.

The sounds are to long for that.
 

User avatar
Ragnarok
Member
 
Posts: 213
Joined: Thu Mar 22, 2012 12:56

by Ragnarok » Fri Aug 03, 2012 11:51

The sounds are too long to play them on a single rail - I agree - but you can detect whether the rail is changed, and then play the sound carts_curved_rails.ogg or carts_railway_crossover.ogg for a while according to the type of rail. Over straight rails should be played carts_straight_rails.ogg. The question is: how to detect rails?
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Aug 03, 2012 12:28

Ragnarok wrote:The sounds are too long to play them on a single rail - I agree - but you can detect whether the rail is changed, and then play the sound carts_curved_rails.ogg or carts_railway_crossover.ogg for a while according to the type of rail. Over straight rails should be played carts_straight_rails.ogg. The question is: how to detect rails?

This is possible. Rails use the param2 variable so you can see wether they are curved or straight etc.. And with the get_new_direction() of the cart you can simulate the next 4 to 5 steps so you can detect the rails and check wether they are curved etc.
But I dont want to add this. I want some sounds that are played randomly.
 

User avatar
Ragnarok
Member
 
Posts: 213
Joined: Thu Mar 22, 2012 12:56

by Ragnarok » Fri Aug 03, 2012 12:57

PilzAdam wrote:(...)
But I dont want to add this. I want some sounds that are played randomly.

As you wish. I just care about realistic sound.

Besides, there is nothing to stand in the way the default soundtrack consisted of randomly generated sounds while other sounds are played after the discovery of appropriate events.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Fri Aug 03, 2012 13:18

Ragnarok wrote:
PilzAdam wrote:(...)
But I dont want to add this. I want some sounds that are played randomly.

As you wish. I just care about realistic sound.

Besides, there is nothing to stand in the way the default soundtrack consisted of randomly generated sounds while other sounds are played after the discovery of appropriate events.

Yes i know but i like the sounds as they are.
 

User avatar
Splizard
Member
 
Posts: 220
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard

by Splizard » Sat Aug 04, 2012 02:32

Is it possible to store the items in the cart as inventory? It looks strange with the items teleporting around...
Games: The Hungry Games.
Mods: Lifters (Simple Lifts), Snow Biomes and Gates.
Also checkout my texture pack Gridtoon!
View all of them plus more at http://minetest.splizard.com! (may not always be online).
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Aug 04, 2012 09:13

Splizard wrote:Is it possible to store the items in the cart as inventory? It looks strange with the items teleporting around...

No its not possible.
 

graphics boy
Member
 
Posts: 19
Joined: Fri Jul 27, 2012 08:57
GitHub: Cg-boy

by graphics boy » Sat Aug 04, 2012 12:32

PilzAdam wrote:This is realy strange because in line 390 if init.lua the method is_player() is not used. Try redownload.
I tried redownloading it but It still had the error

Are there any other cart mods?
I like 3d graphics
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Aug 04, 2012 12:44

graphics boy wrote:
PilzAdam wrote:This is realy strange because in line 390 if init.lua the method is_player() is not used. Try redownload.
I tried redownloading it but It still had the error

Are there any other cart mods?

Could you please post the error message again. It is not possible that the error is in line 390 of init.lua
There is a vehicles mod but it is laggy.
 

graphics boy
Member
 
Posts: 19
Joined: Fri Jul 27, 2012 08:57
GitHub: Cg-boy

by graphics boy » Sat Aug 04, 2012 13:04

ServerError: LuaError: error running function 'on_rightclick':
...v-20120606-win32\bin\..\mods\minetest\carts\init.lua:727: attempt to call
method 'is_player' (a nil value)
I like 3d graphics
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Aug 04, 2012 13:11

graphics boy wrote:ServerError: LuaError: error running function 'on_rightclick':
...v-20120606-win32\bin\..\mods\minetest\carts\init.lua:727: attempt to call
method 'is_player' (a nil value)

Do you have latest version (29) of carts installed?
Do you have latest version (0.4.2-rc1) of minetest installed?
 

graphics boy
Member
 
Posts: 19
Joined: Fri Jul 27, 2012 08:57
GitHub: Cg-boy

by graphics boy » Sat Aug 04, 2012 13:18

version 28 of carts
version 0.4.dev of minetest
I like 3d graphics
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Aug 04, 2012 13:19

graphics boy wrote:version 0.4.dev of minetest

Wich 0.4.dev (0.4.2-rc1 is latest)?
 

graphics boy
Member
 
Posts: 19
Joined: Fri Jul 27, 2012 08:57
GitHub: Cg-boy

by graphics boy » Sat Aug 04, 2012 13:24

Minetest-c55 0.4.dev-20120606
I like 3d graphics
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Aug 04, 2012 13:31

graphics boy wrote:Minetest-c55 0.4.dev-20120606

This is maybe too old. Try a newer version.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sun Aug 05, 2012 12:58

The carts are now 3D.
 

User avatar
aFoxNamedMorris
Member
 
Posts: 14
Joined: Sat Aug 11, 2012 15:57

by aFoxNamedMorris » Sat Aug 11, 2012 16:04

I think I may have some input. n.n The minecarts in Minecraft were rectangular boxes, and these are square. Now, let me just say that I don't really care about the shape, but I was considering some general ideas about the carts:

Make 3 points within a rectangular minecart.
<back point (follows track)><player point(stays between the back and front points)><front point (follows track)>

Doing this could (in theory) make a smoother looking minecart, and possibly eliminate some of the lag in the cart's player movement. Just an idea, but thought it might come in handy.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Aug 11, 2012 16:07

aFoxNamedMorris wrote:I think I may have some input. n.n The minecarts in Minecraft were rectangular boxes, and these are square. Now, let me just say that I don't really care about the shape, but I was considering some general ideas about the carts:

Make 3 points within a rectangular minecart.
<back point (follows track)><player point(stays between the back and front points)><front point (follows track)>

Doing this could (in theory) make a smoother looking minecart, and possibly eliminate some of the lag in the cart's player movement. Just an idea, but thought it might come in handy.

This wouldnt fix the lag when transporting players. Its an engine thing and I cant fix that in my mod.
 

User avatar
aFoxNamedMorris
Member
 
Posts: 14
Joined: Sat Aug 11, 2012 15:57

by aFoxNamedMorris » Sat Aug 11, 2012 16:20

Awr... :< Well, would the points at least make a rotating, elongated cart?
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Aug 11, 2012 17:07

aFoxNamedMorris wrote:Awr... :< Well, would the points at least make a rotating, elongated cart?

The cart is roatating but you dont see it. You can change the visuals of the cart by changing the nodebox in box.lua
 

User avatar
aFoxNamedMorris
Member
 
Posts: 14
Joined: Sat Aug 11, 2012 15:57

by aFoxNamedMorris » Sun Aug 12, 2012 01:42

PilzAdam wrote:
aFoxNamedMorris wrote:Awr... :< Well, would the points at least make a rotating, elongated cart?

The cart is roatating but you dont see it. You can change the visuals of the cart by changing the nodebox in box.lua


Ooh! Thanks a ton! ^-^
 

tinoesroho
Member
 
Posts: 570
Joined: Fri Feb 17, 2012 21:55

by tinoesroho » Mon Aug 13, 2012 15:54

Hey PilzAdam,

I've been playing around with code and I've developed an "automated" furnace that allows the cart to drop stuff into it.

-- Based on celeron55's furnace
minetest.register_craft({
output = 'carts:furnace',
recipe = {
{'default:cobble', 'default:cobble', 'default:cobble'},
{'default:cobble', 'default:cobble', 'default:cobble'},
{'default:cobble', 'default:cobble', 'default:cobble'},
}
})

default.furnace_inactive_formspec =
"invsize[8,9;]"..
"image[2,2;1,1;default_furnace_fire_bg.png]"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;in;2,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"

minetest.register_node("carts:furnace", {
description = "Furnace",
tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", default.furnace_inactive_formspec)
meta:set_string("infotext", "Automated Furnace")
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("in", 4)
inv:set_size("dst", 9)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
elseif not inv:is_empty("dst") then
return false
elseif not inv:is_empty("in") then
return false
end
return true
end,
})

minetest.register_node("carts:furnace_active", {
description = "Furnace",
tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "carts:furnace",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", default.furnace_inactive_formspec)
meta:set_string("infotext", "Automated Furnace");
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("in", 4)
inv:set_size("dst", 9)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
elseif not inv:is_empty("dst") then
return false
elseif not inv:is_empty("in") then
return false
end
return true
end,
})

function hacky_swap_node(pos,name)
local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
local meta0 = meta:to_table()
if node.name == name then
return
end
node.name = name
local meta0 = meta:to_table()
minetest.env:set_node(pos,node)
meta = minetest.env:get_meta(pos)
meta:from_table(meta0)
end

minetest.register_abm({
nodenames = {"carts:furnace","carts:furnace_active"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
for i, name in ipairs({
"fuel_totaltime",
"fuel_time",
"in_totaltime",
"in_time"
}) do
if meta:get_string(name) == "" then
meta:set_float(name, 0.0)
end
end

local inv = meta:get_inventory()

local inlist = inv:get_list("in")
local cooked = nil

if inlist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = inlist})
end

local was_active = false

if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
was_active = true
meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
meta:set_float("in_time", meta:get_float("in_time") + 1)
if cooked and cooked.item and meta:get_float("in_time") >= cooked.time then
-- check if there's room for output in "dst" list
if inv:room_for_item("dst",cooked.item) then
-- Put result in "dst" list
inv:add_item("dst", cooked.item)
-- take stuff from "in" list
instack = inv:get_stack("in", 1)
instack:take_item()
inv:set_stack("in", 1, instack)
else
print("Could not insert item'")
end
meta:set_string("in_time", 0)
end
end

if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext","Furnace active: "..percent.."%")
hacky_swap_node(pos,"carts:furnace_active")
meta:set_string("formspec",
"invsize[8,9;]"..
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
(100-percent)..":default_furnace_fire_fg.png]"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;in;2,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]")
return
end

local fuel = nil
local cooked = nil
local fuellist = inv:get_list("fuel")
local inlist = inv:get_list("in")

if inlist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = inlist})
end
if fuellist then
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
end

if fuel.time <= 0 then
meta:set_string("infotext","Furnace out of fuel")
hacky_swap_node(pos,"carts:furnace")
meta:set_string("formspec", default.furnace_inactive_formspec)
return
end

if cooked.item:is_empty() then
if was_active then
meta:set_string("infotext","Furnace is empty")
hacky_swap_node(pos,"carts:furnace")
meta:set_string("formspec", default.furnace_inactive_formspec)
end
return
end

meta:set_string("fuel_totaltime", fuel.time)
meta:set_string("fuel_time", 0)

local stack = inv:get_stack("fuel", 1)
stack:take_item()
inv:set_stack("fuel", 1, stack)
end,
})

minetest.register_abm({
nodenames = {"default:furnace"},
interval = 0,
chance = 1,
action = function(pos)
minetest.env:add_entity(pos,"carts:furnace")
minetest.env:remove_node(pos)
end
})
Last edited by tinoesroho on Tue Aug 14, 2012 03:48, edited 1 time in total.
We are what we create.

I tinker and occasionally make (lousy) mods. Currently building an MMO subgame and updating mods. Pirate Party of Canada member. Sporadic author. 21 years old.

My github:
https://github.com/tinoesroho/
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Tue Aug 14, 2012 00:51

a RAIL FURNACE! NICE! =)
 

PreviousNext

Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 25 guests

cron