Page 17 of 390

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 10:41 am
by Drakkan
upping my questions:

1. I´d like to clone object forest_oak_cluster just with some offset (it will be placed outside the map -it should be done with offset parameter), please somebody help me define it.

defineObject{
name = "offset_oak",

components = {
{

offset = vec(4,0,4),
}
},
}


2. I´d like to have script which will prevent party to take out torch from torch_holder. on log1 it was

function keepTorch5(holder1)
holder1:addItem(spawn(\"torch\"))\
setMouseItem(nil)\
hudPrint(\" This is not your property ;)\")\
end")


3. Somebody figured out how to place water surface in different height than just -1 ? For example creating clone of some water object just with different height placement ?

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 10:42 am
by Matlock19
This is a pretty dumb question but:

I know how to use the console to find the model file for each item:

print(spawn("item_name").model:getModel())

but how do I use the console to find the "gfxIndex" and "gfxAtlas" for an item? Everything I try returns a nil or some error. I'm trying to define some new keys and stuff.
QuintinStone wrote:Question: I thought I saw a thread where a defineObject block was posted for a single example of each object type; can anyone help me find it?
Seconding this. This would be incredibly helpful.

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 12:33 pm
by Grimfan
I'm getting to the stage of modding where I want to try harder stuff, however with that comes added levels of hair-tearing. For instance while the current script works it is horribly inefficient and wordy (just look at all those unneeded ends):

Code: Select all

function alternateSpikes()
    for i=22,28 do
	for n=29,35 do
	for d=36,42 do
	local l = findEntity("floor_spike_trap_"..i)
	local m = findEntity("floor_spike_trap_"..n)
	local p = findEntity("floor_spike_trap_"..d)
	counter_6.counter:getValue()
	if counter_6.counter:getValue() == 3 then
	l.controller:activate()
	else
	if counter_6.counter:getValue() == 2 then
	m.controller:activate()
	else
	if counter_6.counter:getValue() == 1 then
	p.controller:activate()
	else
	if counter_6.counter:getValue() == 0 then
	counter_6.counter:setValue(3)
	end
	end
end
end
end
end
end
end
How do I make this code more elegant and less wordy?

By the way, forget about the numbering of the spike traps. These are going to be changed to unique ids once the script becomes better.

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 2:24 pm
by Prozail
Grimfan wrote:I'm getting to the stage of modding where I want to try harder stuff, however with that comes added levels of hair-tearing. For instance while the current script works it is horribly inefficient and wordy (just look at all those unneeded ends):
I'm curious, what are you trying to do? have three spiketraps activate one by one in a loop? I don't really get the three nested for-loops.

For a 3x7 setup where you want to activate each line.. maybe something like this??
First of all name your spiketraps after their x-y position somehow like trap_0_3
Then think about the pattern you want them to activate in.
If its some kind of loop.. use a counter and modulus operator.

Code: Select all


counter = 0
function triggerPlates()
	local line = counter % 3 --gives you 0..2 depending on value of counter
	for x = 1,7 do 
		local trap = findEntity("trap_"..line.."_"..x)
		if trap then
			trap.controller:activate()
		end
	end
	counter=counter + 1
end


Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 2:50 pm
by Grimfan
What you see above is what you get when someone learns scripting from trolling messageboards - a strange mess of cobbled together facts that sometimes works. :lol:

Thanks for the information Prozail. I will try and put it into practice. :)

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 5:00 pm
by Jackard
Why does scripting refer to tga files when the files are dds extension? I picked up the dds plugin for Photoshop but there's some error when trying to open the files.

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 5:04 pm
by NutJob
Grimfan wrote:What you see above is what you get when someone learns scripting from trolling messageboards - a strange mess of cobbled together facts that sometimes works. :lol:

Thanks for the information Prozail. I will try and put it into practice. :)
There is (or at least, was) quite a lot of misinformation, but trolling, not so much.

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 7:25 pm
by NutJob
Is there a way to retrieve the top-level class of *any* entity?

LoG1 had this: '“class” returns the class name of the entity'

How do I get the class for an object in LoG2?

Code: Select all

function testFunction(id)
	local o = findEntity(id)
	print(o.class)
	print(o.Class)
	print(o.type)
end
Returns nil, always. "o.name" is also unhelpful because that would just mean I would have to setup a definition table.

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 9:08 pm
by Doridion
Aaa ...... NutJob ? When I want to know all the classes of something in the editor, i just add the item/object/etc on the map, and see names of all the classes in the object properties :D

Re: Ask a simple question, get a simple answer

Posted: Mon Nov 10, 2014 9:56 pm
by NutJob
Yes, as do I. I want to send an ID to a function, I made, and anonymously get it's foundational class the object represents [or even better yet var_dump(anObject)]. I understand that objects can have many classes, thus, why, the field accessible in LoG1 "obj.class" is not available in LoG2. Though it would be relatively easy to implement (on their side) so long as the objects top-level defining class is first in the order (then simply assign that "Class" to the field obj.class).