Moving objects

NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Locked
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Moving objects

Post by Donfrow »

Just curious if UI_move_object/obj->move_obect([pos]) is currently working as intended as I cannot seem to get it to work anymore. An example of the code is such,

Move_Test()
{
UI_move_object(241, [1731, 1894]);
}

which appears to do nothing.

I noticed that there was a change to UI_move_object on Feb 28, but I have no idea what Freedom is or if that change would have affected this.

If it isn't something on my end I will submit a bug.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by marzo »

241 is supposed to be an NPC, I take it? If so, it should be a negative number (-241) instead as Exult no longer tries to convert positive numbers to NPCs in any instances -- the originals demonstrably did not do this, and doing so causes problems due to SI's buggy usecode.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by Donfrow »

Yes, NPC number.

That did the trick. Now to make a whole bunch of negative NPC numbers in scripts and movements!

Thanks, yet again.
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by Donfrow »

One more thing... does that mean for things like UI_clear_item_flag(obj, flag) if I am clearing an NPC flag it must be negative as well?
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by marzo »

For all intrinsics and scripts everywhere, only numbers that need to be treated as an NPC must be negative; in the terms of the intrinsic documentation, that would be any 'object' or 'actor' parameter. Everything else is unaffected, and can be positive or negative as needed.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by Donfrow »

Well lots of work ahead of me then in fixing the disaster that is my code! Thanks again.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by marzo »

I seem to remember strongly suggesting in the past the use of negative numbers when you asked about it; but maybe that is my memory playing tricks. And anyways, I don't want to dig around dozens of threads just to confirm (or refute) that memory...
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by Donfrow »

It is not a memory trick, you are correct that you mentioned that to me in the past.

I never went back and fixed any of the ones I had completed previously as I had a lot of them like that and they worked at the time. It seems I was delaying the inevitable though.

I think I will finally get around to another piece of advice you had given me and final update my ucc.exe since I am going through a bunch of the code anyway.

When ucc gives the warning "You should prepend 'void' for functions that do not return a value" does that just mean functions such as:

Example object#()() and Example2()

would simply become

void Example object#()() and void Example()

I see that gets rid of the error message but I'm hoping that if I go through and do all that it won't cause issues later on.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by marzo »

Re: void: Yes, that is it. The idea comes from C/C++, with 'void' meaning 'has no return'. It has the advantages of making this fact explicit and of maintaining notational consistency. There is the added bonus that 'the Void' is an integral part of Ultima :-)
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by Donfrow »

That would not include a function where a static variable is updated/set would it? I tend to use those a few times for various reasons.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Moving objects

Post by marzo »

A function has a return only if, somewhere, it uses 'return X;', where X is any variable or expression. If the function never has such a statement, or if it has a simple 'return;', then it is a 'void' function. It has nothing at all to do with static variables or anything of the sort.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Locked